Testing mining software on the real ‘live’ pool can be painful these days due to high difficulty and DDoS protection. You don’t want to get your IP banned from the pool while getting mining results more often than once a day. The best way to test new software/hardware in real-time environment would be to use coin daemon’s TestNet. While working on both SHA256 and Blakecoin algos, we’ve had hard time finding public TestNet Stratum pool so we decided to setup private closed TestNet pool on the local in-house server. Unfortunately, private blockchain is not yet supported by Blakecoin developers and I really hope they will introduce this feature in the coming releases.
Another problem with TestNet is that its Blockchain is not as huge as live one, but still it takes time for the daemon to sync with the network and difficulty is not as low as we wanted it to be for the test mode. Digging through docs on general mining and Bitcoind documentation (BIPS-23 and Bitcoin regtest mode) we decided to emulate live Blockchain by setting up server cluster with private Blockchain in regression test mode which eliminated network sync and gave us initial difficulty of 1, exactly what we need for testing!
Below are the steps to setup your very own private Blockchain for testing purposes. Example configuration was tested on Ubuntu Server 16.04.3 and Ubuntu 17.04.
First of all, we will need to have bitcoind installed:
$ sudo apt install bitcoind
Now it is time to setup our main node in regtest mode:
$ $ bitcoind -regtest -server -rpcuser=rpc -rpcpassword=x -rpcport=8332 -daemon
Let’s create BTC address mined coins will go to (i.e. pool address):
$ bitcoin-cli getnewaddress "test"
n26L1UQGT9aK6J1nF5ahh9X6EJ4z8VLDjS
Now we need to create miner address pool will send mining rewards to:
$ bitcoin-cli getaccountaddress "test"
n4Pobsm7gq2jF4CNwangsHXBSwabGLK3Pn
By this time we have our main BTC node up and running in regtest mode. Unfortunately, it is not enough to start actual mining since Blockchain needs more than 1 node to verify transactions and process payments. Let’s setup second aux node on the same server:
$ bitcoind -regtest -server -rpcuser=rpc -rpcpassword=x -rpcport=10340 -daemon --datadir=/home/dev/.bitcoin/regtest2/
and connect 2 nodes together:
$ bitcoin-cli addnode 127.0.0.1:10340 add
Let’s test our new blockchain and create few test blocks:
$ bitcoin-cli setgenerate true 5
$ bitcoin-cli -regtest generate 5
[
"0f77289b3fa2d22c70e8a402a79b0b90f4c3ad2f5ef2e255fd47b91d2b2f9e09",
"25f3fde43ce56fff106b6c14181b0eca351b16b660bc4c9ec4832c8c8b1a89aa",
"3b01302f96e440efae64c319203afe812cda037efd7749218ad8ebf5923ff0a2",
"4fc6223ba2bc7367670733e07425833b361c36902bb0e09440f58636f338d4de",
"21f3e5ea1dc6dc566f258c4143cd90a20564382ef2e2c1774da72772c7243b0e"
]
Check if blocks generated successfully:
$ bitcoin-cli getblockcount
5
Stratum server needs getblocktemplate function to mine on this blockchain:
$ bitcoin-cli -regtest getblocktemplate
{
"capabilities": [
"proposal"
],
"version": 536870912,
"rules": [
],
"vbavailable": {
},
"vbrequired": 0,
"previousblockhash": "21f3e5ea1dc6dc566f258c4143cd90a20564382ef2e2c1774da72772c7243b0e",
"transactions": [
],
"coinbaseaux": {
"flags": ""
},
"coinbasevalue": 5000000000,
"longpollid": "21f3e5ea1dc6dc566f258c4143cd90a20564382ef2e2c1774da72772c7243b0e7",
"target": "7fffff0000000000000000000000000000000000000000000000000000000000",
"mintime": 1495287227,
"mutable": [
"time",
"transactions",
"prevblock"
],
"noncerange": "00000000ffffffff",
"sigoplimit": 20000,
"sizelimit": 1000000,
"curtime": 1495287609,
"bits": "207fffff",
"height": 6
}
Done is done! Next, we need to install required tools and libs to be able to run Stratum server:
$ sudo apt-get install build-essential libtool autotools-dev autoconf pkg-config libssl-dev
$ sudo apt-get install libboost-all-dev git npm nodejs nodejs-legacy libminiupnpc-dev redis-server
$ sudo apt-get update
$ sudo apt-get install libdb4.8-dev libdb4.8++-dev
$ git clone https://github.com/zone117x/node-open-mining-portal nomp
$ cd nomp
$ nvm install 0.10.25
$ sudo npm install node-gyp rebuild
$ npm install stratum-pool
$ npm update
Now it is time to edit config.json and ./pool_configs/bitcoin.json. Make sure to specify IP address, user and password for the following config sections: paymentProcessing, daemons, p2p and mposMode (optional). In this example all the IPs are set to localhost (127.0.0.1). Now it is time to start our new pool:
$ node init.js
All is up and running! You can point your miner to localhost:3333 and start mining on your very own private blockchain with minimal difficulty.


