Bitcoin Cash Node Setup Guide
Bitcoin Cash is a fork of Bitcoin aimed at being used for payments and can be mined with SHA256 compatible ASIC’s. In this guide, I cover how to setup a node and configure it as a Miningcore SOLO pool.
NOTE: This walkthrough assumes you are running a system on Ubuntu Linux and are already connected to a shell window either directly on the system or via a SSH session. In order to setup the pool part, you also need to be running an instance of Miningcore. If you need to setup Miningcore, I have a Guide for that here
We’ll start by first making sure we have our packages up to date and then install docker and git
sudo apt update -y
sudo apt install docker.io git -y
Next, we’ll create folders to store our Node application files and also our blockchain data in. I’ll be placing this at /apps and /data paths. You may want to replace those paths if you have multiple drives with different mount points.
sudo mkdir -p /data/.bch
sudo mkdir -p /apps/bch
Now, we’ll clone the Bitcoin Github repository to a local folder and then move into that folder
sudo git clone https://gitlab.com/bitcoin-cash-node/bitcoin-cash-node.git /apps/bch
cd /apps/bch
Next we need to create a Docker config file as the node doesn’t ship with a native docker file.
sudo nano Dockerfile
Paste the following text and then do ctrl+x followed by Y and then press the Enter key. This will save and exit.
FROM ubuntu:22.04
RUN apt-get update -y
RUN DEBIAN_FRONTEND=noninteractive apt-get install build-essential cmake git libboost-chrono-dev libboost-filesystem-dev libboost-test-dev libboost-thread-dev libevent-dev libminiupnpc-dev libnatpmp-dev libssl-dev libzmq3-dev help2man ninja-build python3 libgmp-dev zlib1g-dev libdb-dev libdb++-dev libqrencode-dev qttools5-dev -y
WORKDIR /app
COPY . .
RUN mkdir build
WORKDIR /app/build
RUN cmake -GNinja .. -DBUILD_BITCOIN_QT=OFF
RUN ninja
RUN mv /app/build/src/bitcoind /app/bitcoind
RUN mv /app/build/src/bitcoin-cli /app/bitcoin-cli
CMD /app/bitcoind -printtoconsole
Now we are going to compile it into a local docker image. We are using docker here to simplify starting, stopping, and being able to easily update the node when needed. Please be patient as this step may take 10-20 minutes or more depending on your hardware
sudo docker build -t bch .
Now we need to create a config file for the node. This allows us to define the ports and credentials that the node RPC server runs on that we will use to connect our pool to (if applicable)
server=1
port=8336
rpcport=9003
rpcuser=pooluser
rpcpassword=poolpassword
prune=550
zmqpubhashblock=tcp://127.0.0.1:6003
Let’s break down what the above settings mean
- server – This tells the node to run the JSON-RPC Server. This is needed to interact with the node (such as getting work, submitting blocks, checking balances, sending funds, etc)
- port – This tells the node to run on a custom port. We set this to a custom port so it doesn’t conflict with other direct Bitcoin forks or BTC itself
- rpcport – This defines the port number that JSON-RPC server will accept connections on
- rpcuser – This defines the JSON-RPC credentials we can use to connect to interact with the node and wallet
- rpcpassword – This defines the JSON-RPC credentials we can use to connect to interact with the node and wallet
- prune – This enables pruning to save storage. 550 is the minimum amount and the value is defined in MB. If you want to run an archival node, you will want to exclude this setting, but for running a mining node, we don’t need the full blockchain history.
- zmqpubhashblock – This defines a endpoint that our node can push new block notifications too. When running a pool or stratum service, we subscribe to this endpoint so the pool gets real-time notifications that it’s time to switch to the next block instead of having to poll the node multiple times a second.
Now we can create and run the docker container for the node. We set restart to always so if the node crashes or system reboots, it will auto start itself back up
sudo docker run -d --network host --name bch --restart always --log-opt max-size=10m -v /data/.bch:/root/.bitcoin bch
The container should now be running and start syncing the blockchain. You can check the logs with the following command
sudo docker logs bch
You will now need to wait for the node to fully sync. If you want to interact with the node or node wallet, you can do so like this:
sudo docker exec bch /app/bitcoin-cli getnewaddress
After running the above getnewaddress command, make note of the address. You will need it if you are going to configure Miningcore for Bitcoin.
If you want to use this node with Miningcore, here is an example pool config that you can put in the “Pools” array of your Miningcore config file. Replace the address values with what you copied from the “getnewaddress” command earlier
sudo nano /data/.miningcore/config.json
{
"id": "bch",
"enabled": true,
"coin": "bitcoin-cash",
"address": "bitcoincash:xxxxxxxxxxxxxxxxxxxxx",
"addressType": "bcash",
"rewardRecipients": [
{
"address": "bitcoincash:xxxxxxxxxxxxxxxxxxxxx",
"percentage": 0.001
}
],
"enableAsicBoost": true,
"blockRefreshInterval": 0,
"jobRebroadcastTimeout": 10,
"clientConnectionTimeout": 600,
"banning": {
"enabled": true,
"time": 600,
"invalidPercent": 50,
"checkThreshold": 50
},
"ports": {
"5003": {
"name": "General ASIC",
"listenAddress": "0.0.0.0",
"difficulty": 1024,
"varDiff": {
"minDiff": 1,
"targetTime": 15,
"retargetTime": 90,
"variancePercent": 30
}
},
"5903": {
"name": "NerdMiner",
"listenAddress": "0.0.0.0",
"difficulty": 0.001,
"varDiff": {
"minDiff": 0.0001,
"targetTime": 15,
"retargetTime": 90,
"variancePercent": 30
}
}
},
"daemons": [
{
"host": "127.0.0.1",
"port": 9003,
"user": "pooluser",
"password": "poolpassword",
"zmqBlockNotifySocket": "tcp://127.0.0.1:6003"
}
],
"paymentProcessing": {
"enabled": true,
"minimumPayment": 0.001,
"payoutScheme": "SOLO",
"payoutSchemeConfig": {
"factor": 2
}
}
}
In this example, we created 2 stratum ports that miners can connect to. One for general ASIC’s and a very low difficulty stratum to support NerdMiners / ESP32’s
If you added the coin to Miningcore, make sure you restart the miningcore service
sudo docker restart miningcore
If you added the coin to Miningcore, you can now connect your miners to the port configured. If you are exposing over the internet, make sure you open up the stratum port configured (5003 and 5903), Miningcore API port (4000), and Miningcore Web UI port (80)
Congrats, you now have your Bitcoin Cash Node setup and optionally your own mining pool with Miningcore. If you find youself wanting to update to the latest version of Bitcoin Cash at some point in the future, you can run these commands:
cd /apps/bch
sudo git pull
sudo docker build -t bch .
sudo docker run --rm -v /var/run/docker.sock:/var/run/docker.sock containrrr/watchtower --run-once bch
If you found this guide valueable, please consider donating to help me continue to create similar guides