Bitcoin Mining Pool
- Install bitcoind on your system
- Inside
bitcoin-config/
, run./start.sh
make install
(possibly requires sudo
)
- Unit tests:
make test
- Unit tests with branch coverage:
make coverage
- Install the system library
zeromq
- Install an up-to-date node
npm install -g typescript
npm install -g tsd
npm install -g gulp
- Inside
server/
runtsd install
andnpm install
- Inside
server/
, build with the commandgulp
- Inside
server/
, run with the commandenode release/src/app.js
Let's run through a full example of setting up the network and using the pool leader & miners.
> cd bitcoin-config
> ./start.sh
Taking a look at our 2nd user, we see that he has no bitcoins:
> ./get-balance.sh 2
0.00000000
Let's give him some.
> ./generate-bitcoins.sh
> ./get-balance.sh 2
50.00000000
Note: generate-bitcoins
mined 101 blocks. The reason why our 2nd user only has
50 bitcoins is because mined block rewards need to mature before they can be spent.
As new blocks are mined, the rewards from the other 100 blocks will be added to
our 2nd user's balance.
In another terminal, run the following:
> cd server
> gulp
... wait until it is done, then Ctrl+C
> node release/app.js
In another terminal, run the following:
> python miner.py
Sit back, and enjoy watching the blocks getting mined.
Let's see if our 3rd user is getting rich (in the bitcoind-config
terminal):
> ./get-balance.sh 3
1850.00000000
...
> ./get-balance.sh 3
8368.75000000
🎉
We can add a transaction to the network and our miner will properly add it to a
block that it mines (in the bitcoind-config
terminal):
> ./get-balance.sh 1
0.00000000
> ./get-address.sh 1
...
"address": "mgAEr5mT9ZhWgXxNqeYWXYbdahdY82PZce",
...
> ./generate-transaction.sh 3 mgAEr5mT9ZhWgXxNqeYWXYbdahdY82PZce
> ./get-balance.sh 1
10.00000000