Bitcoin-core build and run
Ubuntu 20.04 LTS
Methods
You can run bitcoin-core in different ways.
- Build from source and run
- Use docker. I prefer to use docker because it is easy to constrain system resources.
Build from source
Selecting a Bitcoin Core Release
$git clone https://github.com/bitcoin/bitcoin.git
$cd bitcoin
$git tag
...
v0.10.0
v0.10.0rc1
v0.10.0rc2
...
v21.99-guixtest1
v22.0
v22.0rc1
v22.0rc2
v22.0rc3
# By convention, release candidates, which are intended for testing, have the suffix “rc.”
# Stable releases that can be run on production systems have no suffix.
$git checkout v22.0
Configuring the Bitcoin Core Build
See README.md, doc/build-unix.md (or doc/build-osx.md, doc/build-windows.md) Carefully review the build prerequisites, which are in the first part of the build documentation. These are libraries that must be present on your system before you can begin to compile bitcoin.
# For Ubnuntu & Debian
$sudo apt-get install build-essential libtool autotools-dev automake pkg-config bsdmainutils python3
$sudo apt-get install libevent-dev libboost-dev libboost-system-dev libboost-filesystem-dev libboost-test-dev libboost-all-dev libssl-dev
$./autogen.sh
$./configure CXXFLAGS="-O0" --prefix=$HOME --disable-wallet --with-gui=no
$make
# This command will install bitcoin at "~/bin/". The location must be added to the PATH environment variable.
$sudo make install
Edit bitcoin.conf
Make this file at $HOME/.bitcoin/
Don’t forget to change your_user_name and password. You use this when using rpc request.
# Go to the project directory.
# $./share/rpcauth/rpcauth.py your_user_name password
# rpcauth=your_user_name:5273a7ccb3047e9c67d7841bde270efd$7e822bcacde29469334cba00ab0bcb9e9c396d5cf78e230d212a12951c0d4d0f
# Your password:
# password
rpcauth=your_user_name:5273a7ccb3047e9c67d7841bde270efd$7e822bcacde29469334cba00ab0bcb9e9c396d5cf78e230d212a12951c0d4d0f
# Optional. Configuration of a resource-constrained system.
maxconnections=15
prune=5000
minrelaytxfee=0.0001
maxmempool=200
maxreceivebuffer=2500
maxsendbuffer=500
Run
$bitcoind
Use Docker
Dockerfile
FROM ubuntu:20.04
RUN apt-get update -y && DEBIAN_FRONTEND=noninteractive apt-get install -y\
git\
wget\
build-essential\
libtool\
autotools-dev\
automake\
pkg-config\
bsdmainutils\
python3\
libevent-dev\
libboost-dev\
libboost-system-dev\
libboost-filesystem-dev\
libboost-test-dev\
libboost-all-dev\
libssl-dev
RUN git clone https://github.com/bitcoin/bitcoin.git
WORKDIR /bitcoin
RUN git checkout v22.0
RUN ./autogen.sh
RUN ./contrib/install_db4.sh `pwd`
RUN ./configure CXXFLAGS="-O0" BDB_LIBS="-L/bitcoin/db4/lib -ldb_cxx-4.8" BDB_CFLAGS="-I/bitcoin/db4/include" --with-gui=no
RUN make && make install
WORKDIR /
bitcoin.conf
Make this file at /your/bitcoin/data/dir/
Don’t forget to change your_user_name and password. You use this when using rpc request.
# Go to the project directory.
# $./share/rpcauth/rpcauth.py your_user_name password
# rpcauth=your_user_name:5273a7ccb3047e9c67d7841bde270efd$7e822bcacde29469334cba00ab0bcb9e9c396d5cf78e230d212a12951c0d4d0f
# Your password:
# password
rpcauth=your_user_name:5273a7ccb3047e9c67d7841bde270efd$7e822bcacde29469334cba00ab0bcb9e9c396d5cf78e230d212a12951c0d4d0f
# Optional. Configuration of a resource-constrained system.
maxconnections=15
prune=5000
minrelaytxfee=0.0001
maxmempool=200
maxreceivebuffer=2500
maxsendbuffer=500
Run
I used –cpus”0.1” option to constrain the use of cpu. This can limit the usage of cpu to 10%.
$docker build -t full_node:v22.0 .
$docker run -it -v /your/bitcoin/data/dir:/root/.bitcoin --cpus=".1" --net host --name full_node full_node:v22.0 /bin/bash
$bitcoind
Leave a comment