Chapter 2: Installing, Configuring & Updating Bitcoin Core

Prerequisite

1- Installing Bitcoin Core

This section will be done remotely from another computer by connecting to your Node using SSH. Please follow previous Chapter to make sure your hardware is adequate, and that you have followed Ubuntu Server installation.
First of all, we will validate that the installation was done properly and that the Ubuntu installation was NOT setup as a virtual machine (step 13 of section 3 of the previous chapter).
df -h
Looking for updates
sudo apt update
Updating
sudo apt upgrade
Let's start by creating a “downloads” folder
mkdir downloads
Go in the downloads folder
cd downloads
It is now important to understand what you are about to do. There are different ways to install Bitcoin Core. My preferred way is to download the release from Bitcoin Core here and do the GPG Key verification with the key list here on Github.
Download the files from the Bitcoin Core website
Validate that the release file is listed in the checksums file
sha256sum --ignore-missing --check SHA256SUMS
Use GPG to load keys locally from individuals found on the Github site Ignore any warning and failures, but you must be sure that the lists “OK” after the name of the release file downloaded
Use GPG to load keys locally from individuals found on the Github site
gpg --keyserver hkps://keys.openpgp.org --recv-keys E777299FC265DD04793070EB944D35F9AC3DB76A
gpg --keyserver hkps://keys.openpgp.org --recv-keys D1DBF2C4B96F2DEBF4C16654410108112E7EA81F
Validate that the checksum file is verified
gpg --verify SHA256SUMS.asc
You should receive a “Good signature” beside the name associated to the key
Extract the tar file. It will create a folder called bitcoin-24.0.1 so it is important that you call it in the next command line.
tar xzf bitcoin-24.0.1-x86_64-linux-gnu.tar.gz
Install the content in the following directory. It is IMPORTANT that you write the correct folder name based on your release number. If you have installed the release 25.0, the folder name has to be bitcoin-25.0
sudo install -m 0755 -o root -g root -t /usr/local/bin bitcoin-24.0.1/bin/*
Cross your fingers and launch Bitcoin Core
bitcoind -daemon
Get blockchain info to see which block your node is at
bitcoin-cli getblockchaininfo
Validate to how many peers your node is connected to
bitcoin-cli getconnectioncount
If you want to follow the log of your node synchronization, you should open a secondary Terminal window and write the following command
tail -f .bitcoin/debug.log

2. Configuring Bitcoin Core (bitcoin.conf)

While the blockchain is synchronizing, you can start the configuration. In order to be fully synchronized, it will take approximately 18 hours. I found a great tutorial on youtube here
Open a new therminal window and go to the /.bitcoin folder
cd /.bitcoin
We need to create a new configuration file
nano bitcoin.conf
Paste de following text in the bitcoin.conf file
server=1 txindex=1 daemon=1 rpcport=8332 rpcbind=0.0.0.0 rpcallowip=127.0.0.1 rpcallowip=10.0.0.0/8 rpcallowip=172.0.0.0/8 rpcallowip=192.0.0.0/8 zmqpubrawblock=tcp://0.0.0.0:28332 zmqpubrawtx=tcp://0.0.0.0:28333 zmqpubhashblock=tcp://0.0.0.0:28334 whitelist=127.0.0.1 rpcauth=<username>:[output of rpcauth.py]
Keep this terminal window open and go back to the main window
We will create a username and password for the RPC Authentification of the bitcoin.conf file we have created in the other terminal window and modify it
In the original terminal window, be sure you are in your “downloads” folder
cd downloads
In order to add a <username> and <password> to access to your node, go to Github.com/bitcoin/bitcoin and search for rpcauth.py. Go to the raw file and copy the link
Make the file executable
chmod +x rpcauth.py
Execute the file with a <username> & <password> at the end of the command line
./rpcauth.py <username> <password>
Copy the string and paste it in the configuration file of the auxiliary termina window
Modify the <username> and <password> in the bitcon.conf file
rpcauth=<username>:[output of rpcauth.py]
CTRL+X and save Yes
Restart bitcoind
Bitcoin-cli stop Bitcoind
###3.Creating the service file for automatic boot on start-up (bitcoind.service)
Important note: The new service file does not work properly. The link above is for the service file from 2021
Download the .service file in your systemd folder
Change the file
In the [service] section, make the following changes:
• Make sure that the “ExecStart” has the right path for the folder “bitcoind” on the same line as “daemonwait” (you can verify the path in another terminal with the command “whereis bitcoind”) • you need to remove the “wait” in -daemonwait to have only -daemon • Make sure that the bitcoin.conf file has the right path. • Change also the path for the datadir. • Put a # in front of ExecStartPre= • Change “user” and “group” for the actual user of the server instead of Bitcoin and Bitcoin • Put a # in front of ProtectHome
Press CTRL + X to save it, Y, enter
Shutdown Bitcoin
bitcoin-cli stop
Activate the new service file
sudo systemctl enable bitcoind sudo systemctl start bitcoind
Validate the status
sudo systemctl status bitcoind

4. Enable TOR

Go back to home directory
sudo apt install tor
Validate that TOR has been activated
sudo systemctl status tor
Edit TOR rc file
sudo nano /etc/tor/torrc
Go all the way to bottom and enter 3 lines
ControlPort 9051 CookieAuthentication 1 CookieAuthFileGroupReadable 1
CTRL-X, Save
Restart Tor
sudo systemctl restart tor
sudo usermod -a -G debian-tor <username>
Modify bitcoin.conf to add TOR lines
nano .bitcoin/bitcoin.conf
Add the following lines at the end of the file:
proxy=127.0.0.1:9050 listen=1 b bind=127.0.0.1 onlynet=onion addnode=ty5nq4ua4v47jmebyib7wtk6b25exd735twap6g3rckbfhvlzvrkdhid.onion:8333
CTRL+X, Y
Reboot your node
sudo reboot
##How to upgrade bitcoin-core
Go go downloads folder
cd downloads
Remove the previous sha256sums and sha256sums.asc files
rm sha256sums rm sha256sums.asc
Go to bitcoincore.org to download the latest release with its signature files
Validate that the release file is listed in the checksums file
sha256sum --ignore-missing --check SHA256SUMS
Verify that the checksum file is verified
gpg --verify SHA256SUMS.asc
You should receive a “Good signature” beside the name associated to the key
Extract the tar file. It will create a folder called bitcoin-25.0 in order to reflect the upgrade to the latest release
tar xzf bitcoin-25.0-x86_64-linux-gnu.tar.gz
Stop your node
bitcoin-cli stop
Install the content in the following directory. It is IMPORTANT that you write the correct folder name based on your release number.
sudo install -m 0755 -o root -g root -t /usr/local/bin bitcoin-25.0/bin/*
Restart bitcoind
sudo systemctl start bitcoind
Validate the version
bitcoin-cli –version
Et voila!
Stay tuned, I will be explaining how to install your Personal Electrum Server on your node in the next chapter!
Will let you know how that goes. late 2011 seems to run very nicely so far :-)
reply
I am really curious to have your feedback afterwards!
reply
Hey, your last write up was helpful for setting up the RAM and SSD. Those things are wedged in the mini in a somewhat confusing way.
Installed 22.04.2 (that part was easy!) Now fully synced with systemd service for bitcoin and tor. My next step will be LND. Going with that because most comfortable with it.
Have not got to setting up lightning as a service. Was previously using parts of this tutorial by alex b.
cron/nohup # Start LND on boot @reboot nohup /home/ubuntu/go/bin/lnd > /dev/null 2> /home/ubuntu/.lnd/err.log &
systemd gist
Not sure whether to use cron or systemd. Any thoughts?
reply
Hey mate, thanks for the feedback.
I am honestly debating if I will go ahead and install LND on my node yet. I will need to install Electrum Server before and see if I have enough space on the SSD. If i decide to go that route, it will be Chapter 4. I would definately install it using official release binaries.
I am glad that my little write up were useful. I want to make sure that my months of research can be sum up in a short concise matter and help other plebs.
reply
Nice writeup! It would be cool to see a post on configuring your node to abide by different policy settings than the default (like an enlarged mempool for example)
reply
Very detailed, useful writeup. Thanks.
reply