Peter Tyonum
Posted on February 16, 2023
Bitcoin is made up of computing devices connected with each other on a peer-to-peer (P2P) network running the Bitcoin software. These computing devices participating in the network are called nodes. A Bitcoin node has a blockchain database, a routing mechanism to receive and propagate transactions and blocks, a mining function to validate and create new bitcoin, and a wallet to manage user keys. A node can have all (full node) of these features or selected features according to the needs of the user.
The first and most popular full-node client implementation is the Bitcoin core. It is the original client that was released by Satoshi Nakamoto. It is open-source and actively maintained by the Bitcoin community. Installable binaries exist on bitcoin.org for any platform of choice.
Another well-known client implementation is the BTCD by Conformal Systems. It is also an open-source project that has already been used in production as far back as 2014 and is actively maintained. Btcd implements most of the core functionalities of a node except wallet and chain functionality. The team has instead unbundled the wallet functionality into a separate wallet application called btcwallet.
btcd
client also has minor differences from bitcoind
such as enabling TLS for RPC connections by default and accepting both HTTP requests and Websockets. You can read their blog post here about why they were separated.
btcWallet
is a hierarchical deterministic (HD) bitcoin wallet client for a single user. It acts as both an RPC client to btcd
and an RPC server for wallet clients and legacy RPC applications. It uses an HD path for address derivation (BIP0044
) and encrypts both private keys and public data. You can read more about the wallet on their official repository here.
Having been using Bitcoin core for some time, I wanted to see how well I can work with btcd
client. So the first thing is to compile btcd
from the source. The following sections document how I was able to set up the btcd
node.
COMPILING BTCD
One prominent thing I have noticed while compiling BTCD is that a lot of details are abstracted. I was wondering where to place the configuration file, what is the command line tool, ports for RPC calls, etc. I will attempt to answer these questions in this article.
btcd
is said to provide a compatible RPC interface with Bitcoin core, I am assuming that most features provided in bitcoind
aside wallet and chain are found in btcd
.
Following the instructions on their official repo, first, install go
and check the version with go version
, root path, and path with go env GOROOT GOPATH
.
Next, cd $GOPATH
and create the subdirectories mkdir -p src/github.com/btcsuite/btcd
Clone the repo into the directory: git clone https://github.com/btcsuite/btcd $GOPATH/src/github.com/btcsuite/btcd
Then install: GO111MODULE=on go install -v . ./cmd/...
List installed btcd and its utilities: ls $GOPATH/bin/
We have addblock
, btcctl
, btcd
, findcheckpoint
, gencerts
, lncli
, lnd
btcctl
- is a command line utility used to query and control btcd
via RPC.
gencerts
- is another command line utility used to generate TLS certificates for a specified host
lncli
is a command line tool for querying lnd
via RPC.
lnd
Lightning Network Daemon is a lightning network node implementation by Lightning labs.
There are other Bitcoin-related Go packages released by the team, you can check them out here
BTCD NODE CONFIGURATION USING btcd.conf FILE
Next, we will create our configuration file. Now that btcd
has been successfully installed, run the command btcd —help
to see where we can place our configuration option.
For the macOS platform which I am using, the default /Users/{username}/Library/Application Support/Btcd/btcd.conf
.
Navigate to the Btcd directory and create a config file: cd /Users/{username}/Library/‘Application Support’/Btcd && touch btcd.conf && code btcd.conf
Set the following options in the config file:
Network settings: simnet=1
or testnet=1
depending on the test network you want to use.
RPC Server: rpcuser={username}
, rpcpass={password}
set a strong password
Indexes: txindex=1
Debug: debuglevel=info
Summary of config file:
rpcuser="username"
rpcpass="password"
simnet=1
txindex=1
debuglevel=info
Save the file and return to the terminal and start btcd by running btcd
.
SETTING UP BTCCTL COMMAND LINE TOOL
Next, we will configure btcctl
to interact with btcd
similar to bitcoin-cli
for bitcoind
.
Create a btcctl.conf
file inside the default directory for your platform. For macOS, it is at /Users/{username}/Library/Application Support/Btcctl/btcctl.conf
, check the default location for your platform by running btcctl -h
.
Set the credentials to be same as those used for btcd: rpcuser
="username", rpcpass
="password", and network: simnet=1
You should be able to query btcd now.
You can use btcctl -l
to list all available command options or visit this documentation page here for further information.
Thank you.
References:
- Btcd official repo: https://github.com/btcsuite/btcd
- Btcd documentation: https://btcd.readthedocs.io
- Conformal blog post: https://blog.conformal.com/btcd-not-your-moms-bitcoin-daemon
Posted on February 16, 2023
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.