How To Setup a Bitcoin Node Using Source Code [Linux]?

Bitcoin node helps for bitcoin development or backend services.

Arnish Gupta
Coinmonks
Published in
4 min readDec 2, 2020

--

Bitcoin is the most popular cryptocurrency and its price is continuously grown up in 2020. Many developers are looking for a guide to set up a bitcoin node. I heard the word bitcoin first time in 2016 and I have worked on blockchain development for more than the last two years. Bitcoin code is written in C++. We need to compile a code (if you want to do some changes to the code you can do it) then setup the node. So let’s look at the steps with a fresh operating system. I am dividing this article into two parts. The first part is to compile the source code and the second part is for setup the node.

Photo by André François McKenzie on Unsplash

If you want to set up only a node then you can skip the source code compilation process and download the bitcoin executable files directly from here. Extract the file and check bin folder.

Part 1: Source Code Compilation Guide

Step 1.

Update all the repositories apt-get update -y and download the latest bitcoin code. you can get all the releases from here.

wget https://github.com/bitcoin/bitcoin/archive/v0.20.1.tar.gz (If wget command not found then apt-get install wget -y)

Step 2.

Extract the file tar -xvzf v0.20.1.tar.gz

Install some helper libraries

  1. AutoConf apt-get install autoconf -y
  2. Libtool apt-get install -y libtool
  3. G++ apt-get install g++ -y
  4. Package Config apt-get install pkg-config -y
  5. All Dev apt-get install libboost-all-dev -y
  6. LibDB Package apt-get install libdb++-dev -y
  7. Utils apt-get install bsdmainutils -y
  8. Essential for make apt-get install build-essential -y

Step 3.

We are ready to compile the code. Go into the extracted directory (bitcoin-0.20.1) and execute the command ./autogen.sh

If everything goes good then you will see the output like this.

root@05664050921e:~/bitcoin-0.20.1# ./autogen.shLlibtoolize: 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'etc...

Step 4.

Configure the project with incompatible DB version because it required only 4.8 version and we don’t need to track the dependency.

./configure --with-incompatible-bdb --disable-dependency-tracking

Step 5.

Now we are ready to make the executable files using the make command. It will take time about an hour so don’t worry about that.

[Optional] You can run this command in the background using the article.

After successfully execute the make command then you can check in the src folder there are some executable files created.

## These files are1. bitcoind
2. bitcoin-cli
3. bitcoin-tx
4. bitcoin-wallet

Congratulations !! You have compiled the bitcoin code, now a new journey started to setup the bitcoin node.

Part 2: Setup a Bitcoin Node

We need a bitcoin executable file that we can get by using compile the code on the above steps or directly download it from the bitcoin site.

Step 1.

Make a .bitcoin directory in the root path (mkdir ~/.bitcoin) then go into the directory. Now we have to write the configuration of our bitcoin node so that we have to create bitcoin.conf file in the .bitcoin directory.

Step 2.

For starting the bitcoin node execute the below command:

./bitcoind -daemon If we want to use the deprecated RPC command then we have to write -deprecatedrpc=<rpc_package_name> (i.e. accounts)

If we want to change the bitcoin directory then we can give the directory path with the -datadir=<Folder_Path> command. We can check the logs in the debug.log file.

For stop the bitcoin node: ./bitcoin-cli stop

Step 3.

Bitcoin CLI Commands

## RPC Command Verifycurl -XGET 'http://localhost:8332'Output: JSONRPC server handles only POST requests## It means our bitcoin node working successfully and RPC is ready ## to use.#### ------ Some bitcoin CLI commands -------
## To check bitcoin wallet balance
./bitcoin-cli getbalance
## Check bitcoin fee for ECONOMICAL (regular) confirmation
./bitcoin-cli estimatesmartfee 1
## Check bitcoin fee for CONSERVATIVE (fastest) confirmation
./bitcoin-cli estimatesmartfee 6
## Check complete wallet information
./bitcoin-cli getwalletinfo

You can find all the CLI commands from here.

It’s Waaw. Finally, we achieved success. If you have any concerns or query then you can write in the comment box, I will try to solve your query with happiness and looking forward to your feedback.

If you liked this article, give me a second and clap.

Thank you for reading. Have a Bitcoin Day.

Also, Read

Get Best Software Deals Directly In Your Inbox

--

--