Bitcoin (BTC) Node Guide


Bitcoin is the original mineable cryptocurrency 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

  1. 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

  2. Next, we'll create folders to store our Bitcoin 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/.btc
    sudo mkdir -p /apps/btc

  3. Now, we'll clone the Bitcoin Github repository to a local folder and then move into that folder

    sudo git clone https://github.com/bitcoin/bitcoin.git /apps/btc
    cd /apps/btc

  4. Next we need to create a Docker config file as Bitcoin 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 pkgconf python3 libevent-dev libboost-dev libsqlite3-dev libzmq3-dev systemtap-sdt-dev libcapnp-dev capnproto -y
    WORKDIR /app
    COPY . .
    RUN cmake -B build
    RUN cmake --build build -j $(( $(nproc) - 1 ))
    RUN mv /app/build/bin/bitcoind /app/bitcoind
    RUN mv /app/build/bin/bitcoin-cli /app/bitcoin-cli
    CMD /app/bitcoind -printtoconsole


  5. 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 btc .

  6. 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)

    sudo nano /data/.btc/bitcoin.conf
    Paste the following text and then do ctrl+x followed by Y and then press the Enter key. This will save and exit.
    server=1
    port=8335
    rpcport=9002
    rpcuser=pooluser
    rpcpassword=poolpassword
    prune=550
    wallet=default
    zmqpubhashblock=tcp://127.0.0.1:6002

    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 port 8335. We set this to a custom port so it doesn't conflict with other direct Bitcoin forks like BCH
    • 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.
    • wallet - This tells the node what wallet to auto use when it launches/restarts. We will be creating this wallet in a few steps.
    • 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.

  7. 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 btc --restart always --log-opt max-size=10m -v /data/.btc:/root/.bitcoin btc
    The container should now be running and start syncing the blockchain. You can check the logs with the following command
    sudo docker logs btc
    This node, by default, doesn't automatically create a wallet, so we need to create one. We can do this with one simple command
    sudo docker exec btc /app/bitcoin-cli createwallet default
    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 btc /app/bitcoin-cli getnewaddress "" "legacy"
    After running the above getnewaddress command, make note of the address. You will need it if you are going to configure Miningcore for Bitcoin.

  8. 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": "btc",
      "enabled": true,
      "coin": "bitcoin",
      "address": "1ABxxxxxxxxxxxxxxxxxxxxE",
      "rewardRecipients": [
        {
          "address": "1ABxxxxxxxxxxxxxxxxxxxxE",
          "percentage": 0.001
        }
      ],
      "enableAsicBoost": true,
      "blockRefreshInterval": 0,
      "jobRebroadcastTimeout": 10,
      "clientConnectionTimeout": 600,
      "banning": {
        "enabled": true,
        "time": 600,
        "invalidPercent": 50,
        "checkThreshold": 50
      },
      "ports": {
        "5002": {
          "name": "General ASIC",
          "listenAddress": "0.0.0.0",
          "difficulty": 1024,
          "varDiff": {
            "minDiff": 1,
            "targetTime": 15,
            "retargetTime": 90,
            "variancePercent": 30
          }
        },
        "5902": {
          "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": 9002,
          "user": "pooluser",
          "password": "poolpassword",
          "zmqBlockNotifySocket": "tcp://127.0.0.1:6002"
        }
      ],
      "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


  9. If you added the coin to Miningcore, make sure you restart the miningcore service

    sudo docker restart miningcore

  10. 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 (5002 and 5902), Miningcore API port (4000), and Miningcore Web UI port (80)


  11. Congrats, you now have your Bitcoin Node setup and optionally your own mining pool with Miningcore. If you find youself wanting to update to the latest version of Bitcoin at some point in the future, you can run these commands:

    cd /apps/btc
    sudo git pull
    sudo docker build -t btc .
    sudo docker run --rm -v /var/run/docker.sock:/var/run/docker.sock containrrr/watchtower --run-once btc


If you found this guide valueable, please consider donating to help me continue to create similar guides

Cryptocurrency & Bitcoin donation button by NOWPayments