Categories
Raspberry Pi

Compile Bitcoin-QT from source on Raspberry Pi

Difficulty: Low

A lot of posts on this blog will be about running your own Bitcoin infrastructure without the major node in a box implementations such Umbrel. This has the benefit of getting new features and critical updates sooner as you don’t have to wait for the node in a box implementation to push a new update. The official distribution site for the Bitcoin Core node software does include a binary for Raspberry Pi so there is no need to build from source yourself. I’m not sure that was always the case so at one time I went through the process of building Bitcoin-QT myself and have been doing so ever since.

The only prerequisite for completing this guide is to have an updated version of Raspberry Pi OS installed on your Raspberry Pi. For this guide I’ll be using a Raspberry Pi 4 with 4 GB of RAM. I’m using the 64-bit version of the OS that was released on April 4th of 2022. The software can be obtained from this website:

https://www.raspberrypi.com/software/operating-systems/

One thing to note is that while this guide is written for the Raspberry Pi you should be able to build Bitcoin-QT on any Debian based Linux Distribution with these instructions.

First I booted into the gui to enable SSH and VNC. This is not explicitly necessary. I prefer to run my Raspberry Pi headless and after enabling these options I’m able to SSH into the Pi to perform the upcoming steps.

The next step is to get the Bitcoin Software from the official site:

https://bitcoincore.org/en/download/

The binaries for the 32 bit and 64 bit versions of Bitcoin Core for the Raspberry Pi are are available by #1. If you just want to get Bitcoin-QT running on your Pi quickly that is the easiest option. For this guide however we are going to download the source code and build Bitcoin-QT ourselves. Select the link by #2.

With any Bitcoin related software I highly recommend that you verify that the download has not been tampered with. You can do this by using GPG to verify that the download was signed by the Bitcoin Core developers. I suspect that most people skip this step. However, when your life savings can be taken in an instant if you are using compromised software, the time invested in verifying your software is well worth it in my opinion!

Here is a detailed guide by Luke Dashjr on how to accomplish this task:

https://medium.com/@lukedashjr/how-to-securely-install-bitcoin-9bfeca7d3b2a

Now that you’ve verified the software we can get down to the business of building it. First we’ll install the required prerequisite software for building Bitcoin-QT.

$ sudo apt-get update
$ sudo apt-get install build-essential libtool autotools-dev automake pkg-config bsdmainutils python3 libminiupnpc-dev libzmq3-dev libqt5gui5 libqt5core5a libqt5dbus5 qttools5-dev qttools5-dev-tools libqrencode-dev bison

Now unpack the software with these command:

$ mv ~/Downloads/bitcoin-23.0.tar.gz ~/
$ tar -xvzf bitcoin-23.0.tar.gz
$ cd bitcoin-23.0/

We are going to now build some special dependencies for Bitcoin Core that are included with the source files. These dependencies allow you to run a legacy wallet.

You will have to build these dependencies for your architecture. This will be as follows for the Raspberry Pi:

32-Bit arm-linux-gnueabihf
64-Bit aarch64-linux-gnu

This will take a very long time, like 4-5 hours so be prepared. This is the kind of thing you want to start before you go to bed for the night:

$ cd depends
$ make HOST=aarch64-linux-gnu 

When this completes you should get a message like this:

$ copying packages: boost libevent qt expat libxcb xcb_proto libXau xproto freetype fontconfig libxkbcommon libxcb_util libxcb_util_render libxcb_util_keysyms libxcb_util_image libxcb_util_wm qrencode bdb sqlite miniupnpc libnatpmp systemtap zeromq
to: /home/bitcoin/bitcoin-23.0/depends/aarch64-linux-gnu

Now that the dependencies have been built it’s time to build the actual Bitcoin-QT program. Run the following commands:

$ cd ..
$ ./autogen.sh
$ ./configure --prefix=$PWD/depends/aarch64-linux-gnu
$ make

Note that in the ./configure line you will use the same architecture that you used for the dependencies. Again, the “make” command will take quite a while to complete although not quite as long as building the dependencies.

Once the make has completed without error you are ready to start Bitcoin-QT!

$ cd src/qt
$ ./bitcoin-qt

If “bitcoin-qt is not present in this directory then the build didn’t complete successfully or you are missing dependencies. If “bitcoin-qt” is present you’ve likely started it up and started syncing the blockchain! This will take a couple of days and require several hundred Gigabytes of storage space. I believe it’s better to store the block data on a separate USB SSD and not the SD Card you are booting from. I won’t go into depth here on configuring your node but you can change this setting by editing this file:

$ nano ~/.bitcoin/bitcoin.conf

When editing add an option to store the block data in a different directory such as this directory:

datadir=/mnt/bitcoin

Now your newly compiled node is on it’s way to syncing the blockchain. You are now running Bitcoin Core without the help of a node in a box implementation!

Leave a Reply

Your email address will not be published.