I’ve recently become interested in Blockchain technologies and thought I’d get involved with Bitcoin and go from there.
The experience has been really enjoyable and I’ve learned quite a bit. So figured I’d pass that on to others who were interested and wanted to start by showing you how to set up your own Bitcoin Core Node.
Bitcoin Core implements all parts of Bitcoin. The first implementation was made by Satoshi Nakamoto before the completion of the WhitePaper and was known as “Bitcoin” or “Satoshi Client”. Since its release, it has been heavily modded and improved and is now known as Bitcoin Core and is the reference implementation for the bitcoin system. Essentially this means we should refer to Bitcoin Core on how parts of the tech should be implemented.
For the purposes of this post, I just want to show you how to set up your own Bitcoin Core node by pulling down the source code, building it, and running your own Node.
First, we want to set up our development environment, I’ll be running on a Ubuntu 18.04 virtual machine. Ensure your box is up-to-date and has git installed (throughout this post I’m assuming you know the basics of version control).
Next, we want to get hold of the source code. There are a few ways to do this but I find the easiest is simply to clone the repo from GitHub. You’ll want to get a copy of the latest version.
Open a terminal, navigate to a preferred directory and run the following:
git clone https://github.com/bitcoin/bitcoin.git
Now we have the latest version of the bitcoin source code we’ll want to select the release (the latest) and provision our machines to build.
We can use the git tag command to get a list of available releases.
In your terminal, run the following:
Choose the latest release shown and run the following:
git checkout <release>
You can confirm you have the correct version checkout by running:
The result will contain the following:
HEAD detached at <release> nothing to commit, working directory clean
Great stuff. We’ve got the correct release of the Bitcoin source code we want to build, now we just need to make sure our machine is provisioned to do so.
From the root of the repo navigate to the doc directory in here you will find instructions on how to provision your machine to build your node. As I’m on a Ubuntu machine I will use build-unix.md but there are instructions for macOS and Windows.
Open your instructions:
Ensure you read the instructions carefully to avoid any potential issues. As I’m on a Ubuntu machine I will follow those steps:
First, install the build requirements:
sudo apt-get install build-essential libtool autotools-dev automake pkg-config bsdmainutils python3
Then, install the dependencies:
sudo apt-get install libssl-dev libevent-dev libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-test-dev libboost-thread-devsudo libminiupnpc-dev
Now our machines are provisioned we can start getting the build process moving.
First, we need to generate a collection of config scripts, these scripts will review your machine and discover the correct settings and that you have the correct dependencies for building. We can do this by running the autogen script found in the root of the repo.
Navigate to the repo root and run:
As part of the autogen step, we get a file called configure generated at the root. This file is used to automatically identify the required libraries and create a build script for your machine.
Let’s run that script then:
If you get the following error:
configure: error: libdb_cxx headers missing, Bitcoin Core requires this library for wallet functionality (--disable-wallet to disable wallet functionality)
Now, hopefully, that went smoothly!
Let’s compile, this will take some time, run:
If your machine can manage it would be worth adding parallel compilation using -j, e.g. make -j 2 will use two cores.
It is advised that you run the suite of unit tests available once compilation has completed. You can do this by running:
Finally, we need to install the executables on our system by running the following command:
sudo make install
That’s it for building Bitcoin Core, we can now run it.
To run our node we use the following command:
Though for now at least I recommend running:
The addition of -printtoconsole will feed output to the console soo you start to get an idea of what is happening.
Congratulations, you now have your own bitcoin core node up and running, it will take quite a while to get up to date with the current ecosystem.
To make sure you are aware of the full implications of running a bitcoin node I recommend you check out this link.
This post is for educational purposes only and I do not make any recommendations on whether you should or should not run a bitcoin node. The risks and costs associated must be weighted by yourself.