Links

Bitcoind

The following instructions describe installing Bitcoin SV Node using tools available in most mainstream Linux distributions. The assumption has been made that you are using a Bourne-like shell such as bash.
To start the install of Bitcoin, make sure you use an account that can use su or sudo to install software into directories owned by the root user.
Download the zipped release of your choosing, for this example we are using 1.0.5 which is the latest release at the time of writing:
$ wget https://download.bitcoinsv.io/bitcoinsv/1.0.5/bitcoin-sv-1.0.5-x86_64-linux-gnu.tar.gz
Confirm downloaded file sha hash matches those provided at download.bitcoinsv.io for the version you have downloaded.
$ sha256sum bitcoin-sv-1.0.5-x86_64-linux-gnu.tar.gz
//Expected Output
96f7c56c7ebd4ecb2dcd664297fcf0511169ac33eaf216407ebc49dae2535578 bitcoin-sv-1.0.5-x86_64-linux-gnu.tar.gz
Locate the file you downloaded and extract it using the tar command followed by the argument xzf followed by the file name. The argument xzf means eXtract the gZipped tar archive file. For example, for a 64-bit tar archive in your current directory, the command is:
$ tar xvf bitcoin-sv-1.0.5-x86_64-linux-gnu.tar.gz
Create a symbolic link from a new directory called bitcoin to the bitcoin-sv-1.0.5 directory you just made by unzipping for easier use and updates:
$ ln -s bitcoin-sv-1.0.5 bitcoin
Create a bitcoin-data directory to put bitcoin data in (or else Bitcoin will put data in ~/.bitcoin by default):
$ mkdir bitcoin-data
Create a bitcoin.conf file in the directory to configure the settings to run your node using:
$ cd bitcoin-data/
$ vim bitcoin.conf
Below is an example bitcoin.conf file used by a node on the STN:
A full list of available options can be seen by running bitcoind --help
#start in background
daemon=1
#select network -- comment out both for mainnet
#testnet=1
stn=1
#Required Consensus Rules for Genesis
excessiveblocksize=10000000000 #10GB
maxstackmemoryusageconsensus=100000000 #100MB
#Mining
#biggest block size you want to mine
blockmaxsize=4000000000
blockassembler=journaling #journaling is default as of 1.0.5
#preload mempool
preload=1
#mempool usage allowance
maxmempool=8000 #8G
dbcache=8192 #8G
#Pruning -- Uncomment to trim the chain in an effort to keep disk usage below the figure set
#prune=100000 #100GB
#orphan transaction storage
#blockreconstructionextratxn=200000
#maxorphantxsize=10000
#transaction options
#maxsigcachesize=260
#maxscriptcachesize=260
#minrelaytxfee=0.00000001
#mintxfee=0.00000001
#dustrelayfee=0.00000001
#blockmintxfee=0.00000001
#relaypriority=0
#feefilter=0
#limitfreerelay=1000
#maxscriptsizepolicy=500000
#OP Return max size
#datacarriersize=100000 #Genesis default is UINT32_MAX
#Max number and size of related Child and Parent transactions per block template
limitancestorcount=100
limitdescendantcount=100
#limitancestorsize=25000000
#limitdescendantsize=25000000
#connection options
maxconnections=80
#ZMQ
#zmqpubhashtx=tcp://127.0.0.1:28332
#zmqpubhashblock=tcp://127.0.0.1:28332
#Ports - Leave commented for defaults
#port=9333
#rpcport=9332
#rpc settings
rpcworkqueue=600
rpcthreads=16
#rpcallowip=0.0.0.0/0
rpcuser=CHANGE_ME
rpcpassword=CHANGE_ME
#debug options
#can be: net, tor,
# mempool, http, bench, zmq, db, rpc, addrman, selectcoins,
# reindex, cmpctblock, rand, prune, proxy, mempoolrej, libevent,
# coindb, leveldb, txnprop, txnsrc, journal, txnval.
# 1 = all options enabled.
# 0 = off which is default
#debug=1
#debugexclude to ignore set log items, can be used to keep log file a bit cleaner
debugexclude=libevent
debugexclude=leveldb
debugexclude=zmq
debugexclude=txnsrc
debugexclude=net
#shrinkdebugfile=0 # Setting to 1 prevents bitcoind from clearning the log file on restart. 0/off is default
#multi-threaded options
#threadsperblock=32
#maxparallelblocks
#scriptvalidatormaxbatchsize
#maxparallelblocksperpeer
maxstdtxvalidationduration=15
maxcollectedoutpoints=1000000
maxstdtxnsperthreadratio=10000
#maxnonstdtxvalidationduration
To run Bitcoind, pass in the location of the configuration file as well as the location of where to store the bitcoin data:
(In our example the user test was used)
$ /home/test/bitcoin/bin/bitcoind -conf=/home/test/bitcoin-data/bitcoin.conf -datadir=/home/test/bitcoin-data -daemon
Create the bitcoind.service file:
$ sudo vim /etc/systemd/system/bitcoind.service
bitcoind.service:
[Unit]
Description=Bitcoin service
After=network.target
[Service]
Type=forking
ExecStart=/home/test/bitcoin/bin/bitcoind -conf=/home/test/bitcoin-data/bitcoin.conf -datadir=/home/test/bitcoin-data -daemon
ExecStop=/home/test/bitcoin/bin/bitcoin-cli -conf=/home/test/bitcoin-data/bitcoin.conf -datadir=/home/test/bitcoin-data stop
ExecReload=/bin/kill -s HUP $MAINPID
Restart=on-abnormal
TimeoutStopSec=120
KillMode=none
PrivateTmp=true
User=test
[Install]
WantedBy=multi-user.target
(be sure to replace test in the above with your logged user)
Then start:
$ sudo systemctl start bitcoind.service
Included in this repo are docker images for the Bitcoin SV Node implementation. Thanks to Josh Ellithorpe and his repository, which provided the base for this repo.
This Docker image provides bitcoind, bitcoin-cli and bitcoin-tx which can be used to run and interact with a Bitcoin server.
To see the available versions/tags, please visit the Docker Hub page.
To run the latest version of Bitcoin SV:
$ docker run bitcoinsv/bitcoin-sv
To run a container in the background, pass the -d option to docker run, and give your container a name for easy reference later:
$ docker run -d --rm --name bitcoind bitcoinsv/bitcoin-sv
Once you have the bitcoind service running in the background, you can show running containers:
$ docker ps
Or view the logs of a service:
$ docker logs -f bitcoind
To stop and restart a running container:
$ docker stop bitcoind
$ docker start bitcoind
The best method to configure the server is to pass arguments to the bitcoind command. For example, to run Bitcoin SV on the testnet:
$ docker run --name bitcoind-testnet bitcoinsv/bitcoin-sv bitcoind -testnet
Alternatively, you can edit the bitcoin.conf file which is generated in your data directory (see below).
By default, Docker will create ephemeral containers. That is, the blockchain data will not be persisted, and you will need to sync the blockchain from scratch each time you launch a container.
To keep your blockchain data between container restarts or upgrades, simply add the -v option to create a data volume:
$ docker run -d --rm --name bitcoind -v bitcoin-data:/data bitcoinsv/bitcoin-sv
$ docker ps
$ docker inspect bitcoin-data
Alternatively, you can map the data volume to a location on your host:
$ docker run -d --rm --name bitcoind -v "$PWD/data:/data" bitcoinsv/bitcoin-sv
$ ls -alh ./data
By default, Docker runs all containers on a private bridge network. This means that you are unable to access the RPC port (8332) necessary to run bitcoin-cli commands.
There are several methods to run bitcoin-cli against a running bitcoind container. The easiest is to simply let your bitcoin-cli container share networking with your bitcoind container:
$ docker run -d --rm --name bitcoind -v bitcoin-data:/data bitcoinsv/bitcoin-sv
$ docker run --rm --network container:bitcoind bitcoinsv/bitcoin-sv bitcoin-cli getinfo
If you plan on exposing the RPC port to multiple containers (for example, if you are developing an application which communicates with the RPC port directly), you probably want to consider creating a user-defined network. You can then use this network for both your bitcoind and bitclin-cli containers, passing -rpcconnect to specify the hostname of your bitcoind container:
$ docker network create bitcoin
$ docker run -d --rm --name bitcoind -v bitcoin-data:/data --network bitcoin bitcoinsv/bitcoin-sv
$ docker run --rm --network bitcoin bitcoinsv/bitcoin-sv bitcoin-cli -rpcconnect=bitcoind getinfo
The following directions will walk you through creating a Bitcoin SV node within GKE (Google Kubernetes Engine).
If you wish to run another version of bitcoind, just change the image reference in bitcoin-deployment.yml.
Steps:
1- Add a new blank disk on GCE called bitcoin-data that is 200GB. You can always expand it later.
2- Save the following code snippets and place them in a new directory kube.
3- Change the rpcuser and rpcpass values in bitcoin-secrets.yml. They are base64 encoded. To base64 a string, just run echo -n SOMESTRING | base64.
4- Run kubectl create -f /path/to/kube
5- Profit!
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
namespace: default
labels:
service: bitcoin
name: bitcoin
spec:
strategy:
type: Recreate
replicas: 1
template:
metadata:
labels:
service: bitcoin
spec:
containers:
- env:
- name: BITCOIN_RPC_USER
valueFrom:
secretKeyRef:
name: bitcoin
key: rpcuser
- name: BITCOIN_RPC_PASSWORD
valueFrom:
secretKeyRef:
name: bitcoin
key: rpcpass
image: bitcoinsv/bitcoin-sv
name: bitcoin
volumeMounts:
- mountPath: /data
name: bitcoin-data
resources:
requests:
memory: "2Gi"
restartPolicy: Always
volumes:
- name: bitcoin-data
gcePersistentDisk:
pdName: bitcoin-data
fsType: ext4
apiVersion: v1
kind: Secret
metadata:
name: bitcoin
type: Opaque
data:
rpcuser: YWRtaW4=
rpcpass: aXRvbGR5b3V0b2NoYW5nZXRoaXM=
apiVersion: v1
kind: Service
metadata:
name: bitcoin
namespace: default
spec:
ports:
- port: 8333
targetPort: 8333
selector:
service: bitcoin
type: LoadBalancer
externalTrafficPolicy: Local