Cyberithub

How to Install and Setup Bitcoin Core on Ubuntu 20.04 LTS

Advertisements

In this article, I will take you through the steps to Install and Setup Bitcoin Core on Ubuntu 20.04 LTS. According to Official website, Bitcoin Core is programmed to decide which block chain contains valid transactions. The users of Bitcoin Core only accept transactions for that block chain, making it the Bitcoin block chain that everyone else wants to use.

What is Bitcoin

Bitcoin is a decentralized digital currency created in 2009 that uses peer to peer technology to facilitate instant payments.

How to Install and Setup Bitcoin Core on Ubuntu 20.04 LTS

How to Install and Setup Bitcoin Core on Ubuntu 20.04 LTS

Also Read: How to Install and Use Docker on Ubuntu 20.04 LTS [Step by Step]

Step 1: Prerequisites

a) You should have a running Ubuntu 20.04 LTS Server.

b) You should have sudo or root access to run privileged commands.

c) You should have autoconf and boost package installed in your System.

d) You should also have git and snap utility available in your System.

Advertisements

 

Step 2: Update Your Server

First you need to update your Server using apt update or apt-get update command as shown below. If needed, you can also run apt upgrade or apt-get upgrade to install the latest security patches and upgrade all the installed packages to the latest version.

root@cyberithub:~# apt update
Hit:1 http://in.archive.ubuntu.com/ubuntu focal InRelease
Hit:2 http://in.archive.ubuntu.com/ubuntu focal-updates InRelease
Hit:3 http://in.archive.ubuntu.com/ubuntu focal-backports InRelease
Hit:5 https://download.docker.com/linux/ubuntu focal InRelease
Hit:6 http://security.ubuntu.com/ubuntu focal-security InRelease
Ign:7 https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 InRelease
Hit:8 http://ppa.launchpad.net/hluk/copyq/ubuntu focal InRelease
Hit:9 https://repos.influxdata.com/ubuntu focal InRelease
Hit:10 https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 Release
Hit:11 https://artifacts.elastic.co/packages/oss-7.x/apt stable InRelease

 

Step 3: Install Bitcoin Core

There are multiple ways to install bitcoin-core package on Ubuntu/Debian based System but here we are going to use the most simplest one. We will install it as snap by using snap install bitcoin-core command as shown below. You can also install it by directly downloading from Bitcoin Official website.

root@cyberithub:~# snap install bitcoin-core
bitcoin-core 22.0 from Bitcoin Core installed

 

Step 4: Clone Source Code

If you also wish to participate in the bitcoin code then you can download the bitcoin source code from GitHub repository using below git clone https://github.com/bitcoin/bitcoin.git command. This will create a local bitcoin directory and copy all the contents inside it.

root@cyberithub:~# git clone https://github.com/bitcoin/bitcoin.git
Cloning into 'bitcoin'...
remote: Enumerating objects: 215497, done.
remote: Counting objects: 100% (2/2), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 215497 (delta 0), reused 1 (delta 0), pack-reused 215495
Receiving objects: 100% (215497/215497), 188.30 MiB | 1.20 MiB/s, done.
Resolving deltas: 100% (153745/153745), done.

 

Step 5: Compile and Install

Then change the directory using cd bitcoin/ command.

root@cyberithub:~# cd bitcoin/

Here you need to run autogen.sh script to generate the configure script.

root@cyberithub:~/bitcoin# ./autogen.sh
libtoolize: putting auxiliary files in AC_CONFIG_AUX_DIR, 'build-aux'.
libtoolize: copying file 'build-aux/ltmain.sh'
libtoolize: putting macros in AC_CONFIG_MACRO_DIRS, 'build-aux/m4'.
libtoolize: copying file 'build-aux/m4/libtool.m4'
libtoolize: copying file 'build-aux/m4/ltoptions.m4'
libtoolize: copying file 'build-aux/m4/ltsugar.m4'
libtoolize: copying file 'build-aux/m4/ltversion.m4'
libtoolize: copying file 'build-aux/m4/lt~obsolete.m4'
configure.ac:11: installing 'build-aux/compile'

Once configure script is generated, you can run this script to configure all the settings best suited to your local System.

root@cyberithub:~/bitcoin# ./configure
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether to enable maintainer-specific portions of Makefiles... yes
checking whether make supports nested variables... (cached) yes

Once all the configuration is ok then compile the code by using make command.

root@cyberithub:~/bitcoin# make
Making all in src
make[1]: Entering directory '/root/bitcoin/src'
make[2]: Entering directory '/root/bitcoin/src'
CXX bitcoind-bitcoind.o
CXX init/bitcoind-bitcoind.o
CXX libbitcoin_server_a-addrdb.o
CXX libbitcoin_server_a-addrman.o
...............................................
make[2]: Leaving directory '/root/bitcoin/src'
make[1]: Leaving directory '/root/bitcoin/src'
Making all in doc/man
make[1]: Entering directory '/root/bitcoin/doc/man'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/root/bitcoin/doc/man'
make[1]: Entering directory '/root/bitcoin'
make[1]: Nothing to be done for 'all-am'.
make[1]: Leaving directory '/root/bitcoin'

Finally install all the compiled code by using make install command as shown below.

root@cyberithub:~/bitcoin# make install
Making install in src
make[1]: Entering directory '/root/bitcoin/src'
make[2]: Entering directory '/root/bitcoin/src'
make[3]: Entering directory '/root/bitcoin'
make[3]: Leaving directory '/root/bitcoin'
make[3]: Entering directory '/root/bitcoin/src'
make[4]: Entering directory '/root/bitcoin'
make[4]: Leaving directory '/root/bitcoin'
/usr/bin/mkdir -p '/usr/local/lib'
/bin/bash ../libtool --preserve-dup-deps --mode=install /usr/bin/install -c libbitcoinconsensus.la '/usr/local/lib'
libtool: install: /usr/bin/install -c .libs/libbitcoinconsensus.so.0.0.0 /usr/local/lib/libbitcoinconsensus.so.0.0.0
libtool: install: (cd /usr/local/lib && { ln -s -f libbitcoinconsensus.so.0.0.0 libbitcoinconsensus.so.0 || { rm -f libbitcoinconsensus.so.0 && ln -s libbitcoinconsensus.so.0.0.0 libbitcoinconsensus.so.0; }; })
libtool: install: (cd /usr/local/lib && { ln -s -f libbitcoinconsensus.so.0.0.0 libbitcoinconsensus.so || { rm -f libbitcoinconsensus.so && ln -s libbitcoinconsensus.so.0.0.0 libbitcoinconsensus.so; }; })
libtool: install: /usr/bin/install -c .libs/libbitcoinconsensus.lai /usr/local/lib/libbitcoinconsensus.la
libtool: install: /usr/bin/install -c .libs/libbitcoinconsensus.a /usr/local/lib/libbitcoinconsensus.a
libtool: install: chmod 644 /usr/local/lib/libbitcoinconsensus.a
libtool: install: /usr/bin/ranlib /usr/local/lib/libbitcoinconsensus.a

 

Step 6: Check Bitcoin version

After successful installation, you can check the currently installed version by using bitcoind --version command as shown below.

root@cyberithub:~# bitcoind --version
Bitcoin Core version v22.99.0-623745ca74cf

 

Step 7: Setup bitcoin.conf

In the next step, you need to configure Bitcoin to run in a test network. For that you need to go to .bitcoin directory which got created in the user's home directory during installation process. There you will find bitcoin.conf file which you need to open using your favorite text editor as shown below. After finishing up the configuration, save and close the file by pressing Ctrl+X.

root@cyberithub:~# cd ~/.bitcoin/
root@cyberithub:~/.bitcoin# nano bitcoin.conf
##
## bitcoin.conf configuration file. Lines beginning with # are comments.
##

# Network-related settings:

# Note that if you use testnet, signet or regtest, particularly with the options
# addnode, connect, port, bind, rpcport, rpcbind or wallet, you will also
# want to read "[Sections]" further down.

# Run on the testnet network
#testnet=0

# Run on a signet network
#signet=0

# Run a regression test network
#regtest=0

# Connect via a SOCKS5 proxy
#proxy=127.0.0.1:9050

# Bind to given address and always listen on it. Use [host]:port notation for IPv6
#bind=<addr>

# Bind to given address and add permission flags to peers connecting to it. Use [host]:port notation for IPv6
#whitebind=perm@<addr>

 

Step 8: Start Bitcoin Test Network

Once configuration is completed, you can start the Bitcoin test network by using bitcoind --testnet -daemon command as shown below.

root@cyberithub:~# bitcoind --testnet -daemon
Bitcoin Core starting

 

Step 9: Start a Node

Then start a node in Bitcoin test network by using bitcoind -regtest -daemon=1 command as shown below.

root@cyberithub:~# bitcoind -regtest -daemon=1
Bitcoin Core starting

 

Step 10: Stop Node

If you want you can also stop the node by using bitcoin-cli -regtest stop command as shown below.

root@cyberithub:~# bitcoin-cli -regtest stop
Bitcoin Core stopping

1 thought on “How to Install and Setup Bitcoin Core on Ubuntu 20.04 LTS”

  1. When I started root was in my ~. When I got to "Setup bitcoin.conf" , there was no bitcoin.conf in my ~/bitcoin direcory. But I ran bitcoind --testnet -daemon and everything seems to check out so I made the bitcoin.conf file in my ~/bitcoin directory.

    Reply

Leave a Comment