Switching to Knots on Raspiblitz

How to switch from Core to Knots on Raspiblitz (1.11.4)

#SSH into your pi as admin:

ssh admin@raspberrypi.local

#Download the official knots bonus script from the raspiblitz repo, and make it executable:

cd /home/admin/config.scripts
wget -O bonus.knots.sh "https://github.com/raspiblitz/raspiblitz/raw/eb2d2dc43e057281adde3e7b909b65bb3573226d/home.admin/config.scripts/bonus.knots.sh"
chmod +x bonus.knots.sh

#If you are running Core Lightning, stop it:

sudo systemctl stop lightningd

#Otherwise, stop LND if you are running it:

sudo systemctl stop lnd

#Stop bitcoind, and after it is fully shutdown, replace it witth Knots:

sudo systemctl stop bitcoind && sleep 30
sudo -u admin bash -x ./bonus.knots.sh on

#Confirm that you are now running Knots!

bitcoin-cli -version

Important Note:

Core 26.x ignores some corrupt blockchain data, but Knots 28.x does not. You may need to re-index!

How to re-index the blockchain (if necessary)

#Check if a re-index is needed:

bitcoin-cli -rpcwait getblockchaininfo | jq '.blocks, .verificationprogress'

If the above command hangs forever, then you will need to re-index!

#(Optional) Confirm that corrupt blockchain data is actually the problem:

sudo grep -i -A2 -B2 "error" /mnt/hdd/bitcoin/debug.log | tail -n 40

#(if the blockchain data is corrupt, it should print log output that includes: “Corrupted block database detected. Please restart with -reindex or -reindex-chainstate to recover.”)

#Stop bitcoind, and after it fully shuts down, restart it with the -reindex directive:

sudo systemctl stop bitcoind && sleep 30
sudo -u bitcoin /usr/local/bin/bitcoind -conf=/mnt/hdd/bitcoin/bitcoin.conf -datadir=/mnt/hdd/bitcoin -reindex -daemon

#Watch the paint dry (i.e. follow the re-indexing logs). Press Ctrl+C when it finally finishes:

sudo journalctl -u bitcoind -f

#Confirm that it is actually finished (should output two identical numbers and the word “false”):

bitcoin-cli getblockchaininfo | jq '.blocks, .headers, .initialblockdownload'

#Stop bitcoind, and once it has fully shut down, reboot the pi:

bitcoin-cli stop && sleep 30
sudo reboot

If Electrs index is also corrupt

(Manifests in Raspiblitz as Mempool future blocks and fee estimates never loading)

#Stop electrs and bitcoind, and when fully shut down, delete the index and reboot:

sudo systemctl stop electrs
sudo systemctl stop bitcoind && sleep 30
sudo rm -rf /mnt/hdd/app-storage/electrs/db/bitcoin
sudo reboot

If you need to revert back to Core 26.x

#Run the bonus script’s “off” command, and reboot:

cd /home/admin/config.scripts
sudo systemctl stop bitcoind && sleep 30
sudo -u admin bash -x ./bonus.knots.sh off && sleep 30
sudo systemctl stop bitcoind && sleep 30
sudo reboot

#Note: You will need to re-index the blockchain after switching back to Core 26.x, as the 28.x database format is not backwards compatible

How to get your node’s public Tor address

(to check if you are reachable on BitNodes.io)

#While SSH’d in as admin, lookup the address via “getnetworkinfo”:

bitcoin-cli getnetworkinfo | jq -r '.localaddresses[] | "\(.address)"'