Left-facing arrow
back to blog
CRYPTO

Self Sovereign Bitcoin Stack, Part 1 — The Node

“Using Bitcoin” can mean different things to different people. It’s a spectrum.

Some would say that simply having any exposure to Bitcoin is “using Bitcoin”. That could be with a Coinbase account, or “holding” GBTC in the Greyscale Bitcoin Trust.

But neither of these options provide the individual with “the point” of Bitcoin.

I don’t want to speak for everyone, but in my view, “the point” of bitcoin is “self sovereign money”. Holding, spending, and receiving money with as little trust as possible placed into other people, governments, and institutions.

This blog series will show you how to set up your own usable Bitcoin Stack, so that you can hold, spend, and receive bitcoin, trusting only in the software that you’re running on your own hardware.

The Stack

Bitcoin Core Full Node <- we are here
ElectrumX Server
Block Explorer
Lightning Network Daemon Node

After the above stack is installed and running on a computer in your network, you will be able to:

  • use a wallet with your own keys to hold, spend, and receive bitcoin (we’ll use Electrum, which uses ElectrumX and the Full Node)
  • view and navigate the Bitcoin blockchain on a beautiful, friendly, easy-to-use website (we’ll set up a block explorer on your network, which connects to your own block explorer which grabs data from your ElectrumX server and your Full Node — my own copy is running at https://btc.gall.pro)
  • use the Lightning Network, by opening, closing, funding, and using your own channels (we’ll use the Zap suite of LN wallet software, which can connect directly to your own Lightning Network Node)

Prerequisites

For this tutorial, you need to have a computer on your network that’s running a Linux system based off of Debian. I’m no Linux expert, and Ubuntu seemed pretty user-friendly, so that’s what I went with on my own server.

If you have an old laptop or desktop computer, this is a great option to put it back to work. I had a tower full of hardware that I built a decade ago that is currently running my bitcoin stack. There’s no monitor hooked up to it, it just sits in the corner, serving all of my bitcoin needs for me.

Get a fresh Ubuntu. I choose Ubuntu Server, and only interact with it via SSH from my laptop. Ubuntu Server has no window system, you only interact with it via Terminal prompts. This guide is going to be 100% text-based, no visual elements.

You can also install Ubuntu Desktop. I suggest you do, if you’re installing this on a laptop, cause it’ll be nice to look at something other than your Terminal when you open it up.

Download Bitcoin Core

Log into your Ubuntu machine, and let’s make a new folder for downloading the Bitcoin Core binary.

-- CODE language-shell -- ~$ mkdir btc-bin ~$ cd btc-bin

<short-break> <short-break>
Next let’s download the latest linux version of Bitcoin Core. We can see which version that is if we use a browser to navigate to https://bitcoincore.org/en/download/. At the time of writing, this is Bitcoin Core version 0.19.1.

-- CODE language-shell -- ~/btc-bin$ wget https://bitcoincore.org/bin/bitcoin-core-0.19.1/bitcoin-0.19.1-x86_64-linux-gnu.tar.gz

Let’s verify that this downloaded file hasn’t been corrupted. Download the list of cryptographic checksums, and use them to check the file.

-- CODE language-shell -- ~/btc-bin$ wget https://bitcoincore.org/bin/bitcoin-core-0.19.1/SHA256SUMS.asc ~/btc-bin$ sha256sum --ignore-missing --check SHA256SUMS.asc

You should see an output with at least one line saying:

-- CODE language-shell -- bitcoin-0.19.1-x86_64-linux-gnu.tar.gz: OK

As long as you see that, all good. You can safely ignore any warnings.

Finally, let’s make sure these checksums were actually signed by the Bitcoin Core release team (to verify that every bit of this file was signed-off)

-- CODE language-shell -- ~/btc-bin$ gpg --keyserver hkp://keyserver.ubuntu.com --recv-keys 01EA5486DE18A882D4C2684590C8019E36C2E964 ~/btc-bin$ gpg --verify SHA256SUMS.asc

You should see a line that says:

-- CODE language-shell -- gpg: Good signature from ...

and another line that says:

-- CODE language-shell -- Primary key fingerprint: 01EA 5486 DE18 A882 D4C2 6845 90C8 019E 36C2 E964

If you’d like, you can read more about this verification process here: https://bitcoincore.org/en/download/#verify-your-download

Phew! All that, and the only thing we’ve done so far was download a compressed file.

Let’s unpack that tarball

-- CODE language-shell -- ~/btc-bin$ tar -xzf bitcoin-0.19.1-x86_64-linux-gnu.tar.gz

This will result in a new folder in <code>btc-bin<code> called <code>bitcoin-0.19.1<code>. If you navigate in there, there’s a folder called <code>bin<code>, and inside there is an executable file called <code>bitcoind<code>! That’s what we’re after. Let’s go in there.

-- CODE language-shell -- ~/btc-bin$ cd bitcoin-0.19.1/bin

In order to be able to execute <code>bitcoind<code>, we need to add it to our <code>PATH<code>. Let’s do that by creating a symlink in <code>/usr/local/bin<code>.

-- CODE language-shell -- ~/btc-bin/bitcoin-0.19.1/bin$ ln -s bitcoind /usr/local/bin/bitcoind

Excellent! Now, anywhere on your system, you have access to run the <code>bitcoind<code> Bitcoin Core Daemon Full Node. Let’s test that by heading back to your home folder and checking the version of <code>bitcoind<code>.

-- CODE language-shell -- ~/btc-bin/bitcoin-0.19.1/bin$ cd ~ ~$ bitcoind --version

You should see output that starts with this line:

-- CODE language-shell -- Bitcoin Core version v0.19.1

Congratulations! 🎉 You now have a copy of the Bitcoin Core program on your machine, ready to sync with the network.

Configure Bitcoin Core

As alluded to at the start of this guide, there are many ways to use Bitcoin. Due to the way that we are setting up our Bitcoin stack here, we need to configure our version of Bitcoin Core a bit, so that the other pieces of software in our stack can interact with it properly.

Here’s how to do that.

We’ll tell Bitcoin Core to look for a configuration file at <code>~/.bitcoin/bitcoin.conf<code>, so we just need to make that (folder and) file

-- CODE language-shell -- ~$ mkdir .bitcoin ~$ touch .bitcoin/bitcoin.conf

and then fill it with the following content (using your favorite text editor, like <code>vim<code> or <code>nano<code>, or a graphical one if you’re using Ubuntu Desktop)

-- CODE language-shell -- server=1 txindex=1 rpcuser= rpcpassword= rpcworkqueue=256 disablewallet=1 zmqpubrawblock=tcp://127.0.0.1:28332 zmqpubrawtx=tcp://127.0.0.1:28333

Be sure to change the values of <code>rpcuser<code> and <code>rpcpassword<code>.

On your router, open up port 8333 and forward it to your computer where Bitcoin Core will be running.

Set up the service

We want this stack to be as foolproof as possible.

If your computer restarts, you shouldn’t have to do anything. Bitcoin Core needs to start up on it’s own and get re-synced with the network.

Thankfully we can use <code>systemd<code> for that. We can basically tell Ubuntu, that whenever the system turns on, it needs to run a script, and we can have that script simply be “start the <code>bitcoind<code> executable”.

Make a file with the following content:

-- CODE language-shell -- [Unit] Description=Bitcoin daemon After=network.target [Service] User= Group= Type=forking PIDFile=/home//.bitcoin/bitcoind.pid ExecStart=/usr/local/bin/bitcoind -daemon \ -conf=/home//.bitcoin/bitcoin.conf \ -pid=/home//.bitcoin/bitcoind.pid Restart=on-failure [Install] WantedBy=multi-user.target

And save it at <code>/etc/systemd/system/<code> with a filename of <code>bitcoind.service<code>

You’ll need to provide <code>sudo<code> access to save this file into the <code>/etc/systemd/system/ directory<code>.

Be sure to update that file with your actual Ubuntu username wherever you see <code><user><code>.

The last thing you need to do is create a file called <code>bitcoind.pid<code> in <code>~/.bitcoin/<code>, right next to your <code>bitcoin.conf<code> file.

Once this file is created at <code>/etc/systemd/system/bitcoind.service<code>, we need to reload the <code>systemd<code> daemon, then enable the service (so that it starts automatically after the system is rebooted), then start the service (so that it starts right now).

-- CODE language-shell -- ~$ sudo systemctl daemon-reload ~$ sudo systemctl enable bitcoind.service ~$ sudo systemctl start bitcoind.service

Bitcoin Core is now running on your computer!

In a new terminal window, we can follow the logs to make sure it’s syncing properly.

-- CODE language-shell -- ~$ tail -f .bitcoin/debug.log

Hopefully you see all kinds of logs indicating that Bitcoin Core is starting up, connecting to peers, and syncing the blockchain.

Now we play the waiting game. In a day or two or three you’ll see the <code>progress<code> indicator value in the logs creep closer and closer to <code>1.000000<code>, and when that happens, you’re fully synced!

Fin

That’s all for now.

If you’ve followed this guide all the way here, you’ve got Bitcoin Core installed and syncing on a computer that you control. This lays the groundwork for all kinds of other fun services and softwares that we’ll install next, which GREATLY increase the actual usability of your full node.

This is my blockchain. There are many like it, but this one is mine.

I’ll include a link to Part 2: ElectrumX Server here, when that’s ready.

Follow me on Twitter: https://twitter.com/trainface

Adam Gall

Build with Us

We are always interested in connecting with people who want to fund, innovate
or work in the open financial system.

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.