Become Sovran

Yet another full-node guide


I've now automated this whole process you can download a script to install core with TOR and I2P Via this link

So I know I’m not the first person to put out a how to guide on running a Bitcoin full node. There are lots out here but I’m going to throw in my lot because I've been wanting to do technical Bitcoin guides for a few reasons. First, writing actually helps me get a firmer grasp on what I'm writing about. It's kind of a learning tool for me so bare with me. Secondly i'm not sure if there is a guide that includes I2P yet.


This guide assumes a few things. That you know what a Bitcoin node is. That your sick of trying to run one via Umbrel or some other node package for whatever reason and you want a bit more control over how it operates. I’m going to be using Bitcoin core. Specifically this will focus on bitcoind and should be valid on most newer Debian based distributions (Ubuntu, Raspbian, etc).


Hardware


I want to touch on hardware quickly. It's still pretty common to see people running nodes via Umbrel,Start9, MyNode or Rasblitz. All on raspberry Pi’s, which for some applications is fine. I run a few things on my home network that use a Raspberry Pi, they have great up-time and cost little to run 24/7. But, at the end of the day, they are low powered computers.


A Raspberry Pi 4 Model B has a quad core ARM v8 that clocks in at 1.8GHz and up to 8 gigs of RAM and we are at a point in Bitcoins history where the chain is starting to get big (~475GB at the time of writing) and if you want to do more than just run core then you'll need at least a 1tb to 2tb SSD. In my experience they tend to bog down when you get to many things running on them at once. The CPU ends up being a bit of a bottle neck and it slows down your IBD significantly. You might or might not care about this. Low time preference right? Anyways.


Cost wise, in the current environment, assuming you can find a Pi with 4 to 8 gigs of RAM. If your starting from scratch it's going to be more expensive to buy the Pi plus the required hard drive than an old tower from some business trying to liquidate old equipment. The old tower will be a much more robust node in the long run. So if you're building from scratch, save some Sats and consider getting an older or refurbished computer. Plus doing the IBD in ~15 hours (over clearnet) is a lot better than the week or so that it takes the Pi to sync.


Just my two Stats. End of the day it's your choice.


System


You are gonna do some prep before the actual install. First things first update your box.


Run :


sudo apt update && sudo apt upgrade -y 

to grab updates and upgrade things.


Users


Depending on how you installed your OS you're probably in a non-root account. For security and organization, separating projects into different users is a decent idea; these users are not admins and therefore can not edit configuration files. If you are not in a root account you can use your current account or make a new user. Just keep in mind the username you make because you will use that going forward when setting things up.


Run :


sudo adduser “your user”

It will ask you a few questions, they can be left blank. Add a password with :


sudo passwd “your user”

make a group :


sudo groupadd "your group"

add the user to the group :


sudo usermod -aG “your group” ”your user”

Network


Bitcoin has several options when it comes to how you wish to relay data. You can choose to relay Bitcoin data with any combo if these networks. Just be aware of the trade-offs. If you want something more private use Tor / I2P only but it will slow down your IBD.


Tor install


First lets add the Tor repository you might not have to do this try running “apt install tor” if it asks to install you can skip to the next bit if not go ahead and run :


lsb_release -c

This will give you the code name of the OS you're running. In my case it was “bullseye”. Remeber to replace “bullseye” in the next command if you got something different.


Run :


echo "deb https://deb.torproject.org/torproject.org bullseye main" | sudo tee /etc/apt/sources.list.d/tor.list

Add the GPG key next with :


gpg --keyserver keys.gnupg.net --recv 886DDD89
gpg --export A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89 | sudo apt-key add -

now you can run “apt update” and “apt install tor”. After the install is done you'll need to edit a configuration file called “torrc” by default it should be in etc/tor/torrc.


Run :


sudo nano /etc/tor/torrc

scroll to the bottom and copy and paste this :


ControlPort 9051
CookieAuthentication 1
CookieAuthFileGroupReadable 1
Log notice stdout
SOCKSPort 9050

save and exit with CTL+S, CTL+X. To make sure Tor is enabled at boot run “sudo systemctl enable tor”. Also make sure your user can run Tor with :


sudo usermod -aG debian-tor your-user

If you get an error saying that the group does not exist you can find Tor’s default group name with : 


grep User /usr/share/tor/tor-service-defaults-torrc 

and replace “debian-tor” with the group name. Tor should now be good to go. On to I2P.


I2P install


I2P support was added in Version 0.7.0. I won’t go into detail about it here but if you don’t know what it is and want a general overview I wrote an overview of it. You can read that here. Suffice to say it's another privacy network and the second most used to date. We will be using the I2Pd implementation of I2p. It is more suitable for servers.


Make sure you have the “apt-transport-https” package installed with


sudo apt install apt-transport-https

Then add the repository. I2P makes it easy with :


wget -q -O - https://repo.i2pd.xyz/.help/add_repo | sudo bash -s -

Then install it like you would any other package with :


sudo apt update
sudo apt install i2pd

enable it on boot with :


sudo systemctl enable i2pd

This is all the configuration you need to do to I2P. Before moving on you can check if Tor and I2P are up and running and listening on the right ports with :


sudo netstat -tulpn | egrep 'i2pd|tor' | grep LISTEN

You should see the Tor ports 9050, 9051 and I2P ports 4444, 7070, 4447, 6668, 7656 open as well as the random port that I2P chooses. Open ports depend on your configuration but these are the default. Now is also a good time to reboot your box to make sure some of the changes we have made so far take hold.


Note:


Port 7070 is a web dashboard for I2PD if you want to make it visible on your local network you can edit the configuration file with : 


sudo nano /etc/i2pd/i2pd.conf

look for the [http] section and change the IP address to your machine's IP. Its a good idea to uncomment the auth options as well. Fill those in and save and exit with ctl+s and ctl+x.


Restart I2P with :


systemctl restart i2pd

you should be able to browse to “yourIP:7070” and log into the web GUI.


Install Bitcoin Core


Finally on to installing Bitcoin Core. Make sure that all the necessary dependencies are installed. These are included in most modern Linux distributions but just to make sure run :

sudo apt install git build-essential libtool autotools-dev automake pkg-config bsdmainutils python3 libssl-dev libevent-dev 
libboost-system-dev libboost-filesystem-dev libboost-test-dev libboost-thread-dev libboost-all-dev libzmq3-dev

If there are no errors then you are good to move on. Navigate into a directory that you want to pull your copy of Core into. You can make a folder with :


mkdir “your folder”
cd “your folder”
wget https://bitcoincore.org/bin/bitcoin-core-24.0.1/bitcoin-24.0.1.tar.gz

Grab a signers pgp key with :


gpg --keyserver keyserver.ubuntu.com –recv-keys E777299FC265DD04793070EB944D35F9AC3DB76A
gpg --export E777299FC265DD04793070EB944D35F9AC3DB76A | sudo apt-key add -

then run :


wget https://bitcoincore.org/bin/bitcoin-core-24.0.1/SHA256SUMS
sha256sum --ignore-missing --check SHA256SUMS

you should see :


“bitcoin-24.0.1.tar.gz: OK”


extract core with :


tar -xzvf bitcoin-24.0.1.tar.gz
cd bitcoin-24.0.1

Build with :


./autogen.sh
./configure
make

This will take some time, run :


sudo make install

Make sure you user and group can run bitcoind with


sudo chown YourUser:YourGroup /home/your user/bitcoin-24.0.1

Configure Core


Almost there! Bitcoin by default makes its data directory in a folder called .bitcoin in the home folder of the user that runs it. It will make these folders once you start running core but if you're trying to be private we need to configure Core first so it will start up with our Tor and I2P proxies we set up above. Keep in mind you can set anywhere you want to be your data directory but I'm ok with the default.


In your “/home /YourUser” folder run :


mkdir .bitcoin
cd .bitcoin
nano bitcoin.conf

There are a lot of settings you can flip here but below will be a bare minimum configuration file. This file assumes you are installing with the plan to use Lightning Network at some point and want to connect other apps like an electrum server to your node.


# [core]


# Maintain coinstats index used by the gettxoutsetinfo RPC.

coinstatsindex=1


# Run in the background as a daemon and accept commands.

daemon=1


# Wait for initialization to be finished before exiting. This implies -daemon.

daemonwait=1


# Set database cache size in megabytes; machines sync faster with a larger cache. Recommend setting as high as possible based upon machine's available RAM.

dbcache=600


# Keep the transaction memory pool below what you set in megabytes.

maxmempool=800


# Maintain a full transaction index, used by the getrawtransaction rpc call.

txindex=1


# Turn off serving SPV nodes

nopeerbloomfilters=1

peerbloomfilters=0


# Don't accept deprecated multi-sig style

permitbaremultisig=0


# Reduce the log file size on restarts

shrinkdebuglog=1


#Add visibility into mempool and RPC calls for potential LND debugging

debug=mempool

debug=rpc

debug=tor

debug=i2p


#[NETWORK]


# This allows only Tor and I2P connections remove to allow IPv4

onlynet=onion,i2p

# Connect to Tor proxy

proxy=127.0.0.1:9050

# I2PD Proxy

i2psam=127.0.0.1:7656


A few notes on the config file. Lopp has a great config maker on github. It's a good way to explore the options available to you. You can see that here

Also if you are having a hard time finding peers you can use this list to add more Tor and I2P peers. That list is here, really the configuration file is up to you.


Configure Systemctl


This is a last optional step but it makes managing bitcoin core really easy. To plug Core into systemd you run :


nano /etc/systemd/system/bitcoind.service

Then copy and paste :



[Unit]


Description=Bitcoin daemon

After=network-online.target

Wants=network-online.target


[Service]


User=your user

Group=your user

Type=forking

ExecStart=/path/to/bitcoind/file/bin/bitcoind \

-conf=/path/to/conf/file/.bitcoin/bitcoin.conf\

-pid=/run/bitcoind.pid

Restart=always

PrivateTmp=true

TimeoutStopSec=480s

TimeoutStartSec=480s

StartLimitInterval=480s

StartLimitBurst=5


[Install]

WantedBy=multi-user.target


This will let bitcoind start on boot as well with the “restart=always” flag. Save and exit with CTL+S and CTL+X. Enable with :


Systemctl enable bitcoind

And at last run :


Systemctl start bitcoind

There you have it if everything is in order you should be able to run systemctl status bitcoind and see that it's up and running. If you want to see core syncing you can navigate to your “/home/your user/bitcoin-24.0.1/bin” folder and run ./bitcoin-cli -getinfo to see your progress.


I hope this helps and congrats getting your Bitcoin full node up and running! This lays the base for any additions that you want to make to your local bitcoin infrastructure.