It has become so entrenched that many of the mainstream ASIC miners no longer support the native GBT protocol
built into the Bitcoin Core client. In order to use a modern Bitcoin miners, a stratum pool/proxy must be setup/run
on the same machine as the node. Miners are then directed to the stratum server port rather than directly to the
Bitcoin Core node port.
Note: Stratum proxy servers are connected to stratum pool servers. In many ways, a proxy acts like a sub pool;
many miners can be connected to it, but it will look like just one miner on the main pool. The proxy can, but does
not need to be, run on the same machine as the main pool.
Compile/Install CKPool/CKProxy
- sudo apt-get -y update
- sudo apt-get -y upgrade
- sudo apt-get -y install build-essential yasm autoconf automake libtool libzmq3-dev git
- git clone https://github.com/satoshiware/ckpool
- cd ckpool
- ./autogen.sh
- ./configure -prefix /usr
- make clean
- make
- sudo make install
- sudo useradd --system --shell=/sbin/nologin ckpool
- sudo mkdir -p /var/log/stratum
- sudo chown root:ckpool -R /var/log/stratum
- sudo chmod 670 -R /var/log/stratum
- sudo apt-get -y install python
- sudo wget https://github.com/satoshiware/bitcoin/ ... rpcauth.py -P /usr/share/python
- sha256sum /usr/share/python/rpcauth.py # Verify Checksum b0920f6d96f8c72cee49df90ee4d0bf826bbe845596ecc056c6bc0873c146d1f
- sudo chmod +x /usr/share/python/rpcauth.py
- echo "#"\!"/bin/sh" | sudo tee /usr/share/python/rpcauth.sh
- echo "python3 /usr/share/python/rpcauth.py \$1 \$2" | sudo tee -a /usr/share/python/rpcauth.sh
- sudo ln -s /usr/share/python/rpcauth.sh /usr/bin/rpcauth
- sudo chmod 755 /usr/bin/rpcauth
- BTCRPCPASSWD=$(openssl rand -base64 16)
- BTCRPCPASSWD=${BTCRPCPASSWD//\//0} # Replace '/' characters with '0'
- BTCRPCPASSWD=${BTCRPCPASSWD//+/1} # Replace '+' characters with '1'
- BTCRPCPASSWD=${BTCRPCPASSWD//=/} # Replace '=' characters with ''
- echo $BTCRPCPASSWD | sudo tee /root/rpcpasswd
- BTCRPCPASSWD="" # Erase from memory
- sudo chmod 400 /root/rpcpasswd
- btc stop
- sudo sed -i 's/.*server.*/server=1/g' /etc/bitcoin.conf
- sudo sed -i '/.*rpcuser.*/d' /etc/bitcoin.conf
- sudo sed -i '/.*rpcpassword.*/d' /etc/bitcoin.conf
- sudo sed -i "s/.*rpcauth.*/$(rpcauth satoshi $(sudo cat /root/rpcpasswd) | grep 'rpcauth')/g" /etc/bitcoin.conf
- cat << EOF | sudo tee /etc/systemd/system/ckpool.service
[Unit]
Description=Stratum Pool Server
After=network-online.target
Wants=bitcoind.service
[Service]
ExecStart=/usr/bin/ckpool --log-shares --killold --config /etc/ckpool.conf
Type=simple
PIDFile=/tmp/ckpool/main.pid
Restart=always
RestartSec=30
TimeoutStopSec=30
### Run as ckpool:ckpool ###
User=ckpool
Group=ckpool
### Hardening measures ###
ProtectSystem=full
ProtectHome=true
NoNewPrivileges=true
PrivateDevices=true
[Install]
WantedBy=multi-user.target
EOF
- cat << EOF | sudo tee /etc/systemd/system/ckproxy.service
[Unit]
Description=Stratum Proxy Server
After=network-online.target
Wants=bitcoind.service
[Service]
ExecStart=/usr/bin/ckproxy --log-shares --killold --config /etc/ckproxy.conf
Type=simple
PIDFile=/tmp/ckproxy/main.pid
Restart=always
RestartSec=30
TimeoutStopSec=30
### Run as ckpool:ckpool ###
User=ckpool
Group=ckpool
### Hardening measures ###
ProtectSystem=full
ProtectHome=true
NoNewPrivileges=true
PrivateDevices=true
[Install]
WantedBy=multi-user.target
EOF
- # Note: Reusing the p2pssh environment file and p2pkey authentication.
- cat << EOF | sudo tee /etc/systemd/system/stratssh@.service
[Unit]
Description=Stratum AutoSSH %I Tunnel Service
Before=ckproxy.service
After=network-online.target
[Service]
Environment="AUTOSSH_GATETIME=0"
EnvironmentFile=/etc/default/p2pssh@%i
ExecStart=/usr/bin/autossh -M 0 -NT -o ServerAliveInterval=30 -o ExitOnForwardFailure=yes -o "ServerAliveCountMax 3" -i /root/.ssh/p2pkey -L 3334:localhost:3333 -p \${TARGET_PORT} p2p@\${TARGET}
RestartSec=5
Restart=always
[Install]
WantedBy=multi-user.target
EOF
- sudo systemctl daemon-reload
- MININGADDRESS=$(btc -rpcwallet=mining getnewaddress "ckpool")
- cat << EOF | sudo tee /etc/ckpool.conf
{
"btcd" : [
$(printf '\t'){
$(printf '\t')"url" : "localhost:19332",
$(printf '\t')"auth" : "satoshi",
$(printf '\t')"pass" : "$(sudo cat /root/rpcpasswd)",
$(printf '\t')"notify" : true
$(printf '\t')}
],
"btcaddress" : "$MININGADDRESS",
"btcsig" : "",
"serverurl" : [
$(printf '\t')"0.0.0.0:3333"
],
"mindiff" : 1,
"startdiff" : 42,
"maxdiff" : 0,
"zmqblock" : "tcp://127.0.0.1:28332",
"logdir" : "/var/log/stratum"
}
Comments from here on are ignored.
EOF
- sudo chown root:ckpool /etc/ckpool.conf
- sudo chmod 440 /etc/ckpool.conf
- MININGADDRESS=$(btc -rpcwallet=mining getnewaddress "ckproxy")
- echo "Please enter your email to receive notifications from the pool"; read MININGEMAIL
- cat << EOF | sudo tee /etc/ckproxy.conf
{
"btcd" : [
$(printf '\t'){
$(printf '\t')"url" : "localhost:19332",
$(printf '\t')"auth" : "satoshi",
$(printf '\t')"pass" : "$(sudo cat /root/rpcpasswd)",
$(printf '\t')"notify" : true
$(printf '\t')}
],
"proxy" : [
$(printf '\t'){
$(printf '\t')"url" : "localhost:3334",
$(printf '\t')"auth" : "${MININGADDRESS}.${MININGEMAIL}",
$(printf '\t')"pass" : "x"
$(printf '\t')}
],
"btcaddress" : "",
"serverurl" : [
$(printf '\t')"0.0.0.0:3333"
],
"mindiff" : 1,
"startdiff" : 42,
"maxdiff" : 0,
"zmqblock" : "tcp://127.0.0.1:28332",
"logdir" : "/var/log/stratum"
}
Comments from here on are ignored.
EOF
- sudo chown root:ckpool /etc/ckproxy.conf
- sudo chmod 440 /etc/ckproxy.conf