This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import BlockModel from 'models/Block'; | |
import SHA256 from 'js-sha256'; | |
import find from 'lodash/find'; | |
import { getAddress } from 'utils/makeWallet'; | |
import request from 'utils/request'; | |
import { unlockTransaction } from 'utils/verifySignature'; | |
const COIN = 100000000; | |
export async function getWalletData(address) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SHA256 from 'js-sha256'; | |
import { getAddress } from 'utils/makeWallet'; | |
import { unlockTransaction } from 'utils/verifySignature'; | |
const COIN = 100000000; | |
export async function getWalletData(address) { | |
//////////////////////////////// | |
// | |
// TODO: retrieve all transactions |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import BlockModel from 'models/Block'; | |
import { isBlockValid } from 'utils/validateBlock'; | |
import store from 'store/store'; | |
export const DL = `~~~~~`; | |
async function wait(s) { | |
return new Promise((resolve, reject) => { | |
setTimeout(resolve, s * 1000); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import BlockModel from 'models/Block'; | |
import find from 'lodash/find'; | |
import { verifyUnlock } from 'utils/verifySignature'; | |
const COIN = 100000000; | |
const COINBASE_REWARD = 50 * COIN; | |
export async function areBlocksValid(blocks) { | |
if (!blocks.length) { | |
return false; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Block from 'classes/Block'; | |
import BlockModel from 'models/Block'; | |
import SHA256 from 'js-sha256'; | |
import { unlockTransaction } from 'utils/verifySignature'; | |
import { v1 } from 'uuid'; | |
export const difficulty = 5; | |
export const COIN = 100000000; | |
const uuid = v1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import BlockModel from 'models/Block'; | |
import SHA256 from 'js-sha256'; | |
const GENESIS_HEADER = { | |
version: 1, | |
previousHash: '0000000000000000000000000000000000000000000000000000000000000000', | |
merkleHash: '4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b', | |
difficulty: 22, | |
nonce: 2620954, | |
timestamp: 1231006505000, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createStore } from 'redux'; | |
import findIndex from 'lodash/findIndex'; | |
const initialState = { | |
// Initialization | |
dbLoaded: false, | |
lastBlock: null, | |
numBlocks: 0, | |
allPeers: [ ], // list of { ip: String, port: Number } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'babel-polyfill'; | |
import Express from 'express'; | |
import Pusher from 'pusher-js'; | |
import bodyParser from 'body-parser'; | |
import network from 'network'; | |
import net from 'net'; | |
// variables for Pusher network | |
const PUSHER_APP_KEY = '86e36fb6cb404d67a108'; // connect via public key (this one or your own for localhost) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* package.json | |
{ | |
"name": "nodecoin", | |
"version": "1.0.0", | |
"description": "Implementation of Bitcoin / cryptocurrency using NodeJS", | |
"main": "index.js", | |
"dependencies": { | |
"body-parser": "^1.18.2", | |
"dotenv": "^5.0.0", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import blocks from '__mocks__/blocks'; | |
import { ec } from 'elliptic'; | |
import { getAddress } from 'utils/makeWallet'; | |
import ripemd160 from 'ripemd160'; | |
import sha256 from 'js-sha256'; | |
const ecdsa = new ec('secp256k1'); | |
const COIN = 100000000; | |
const MY_ADDRESS = '1Nd85AnFYDtaQAG6vF9FVWXFWksG5HuA3M'; | |
const FRIEND_ADDRESS = '1PDLNfJq5GAEn5StESZuBpaBe6B3134vmD'; |