A Bitcoin Cash Node (BCHN) docker image
6.6K
A Bitcoin Cash Node (BCHN) docker image.
23.0.0-alpine, 23-alpine, alpine (23/alpine/Dockerfile)
23.0.0, 23, latest (23/Dockerfile)
Bitcoin Cash Node is the name of open-source software which enables the use of Bitcoin Cash. It is a descendant of the Bitcoin Core and Bitcoin ABC software projects.
This image contains the main binaries from the Bitcoin Cash Node project - bitcoind, bitcoin-cli and bitcoin-tx. It behaves like a binary, so you can pass any arguments to the image and they will be forwarded to the bitcoind binary:
❯ docker run --rm -it uphold/bitcoin-cash-node \
-printtoconsole \
-regtest=1 \
-rpcallowip=172.17.0.0/16 \
-rpcpassword=bar \
-rpcuser=foo
By default, bitcoind will run as user bitcoin for security reasons and with its default data dir (~/.bitcoin/). If you'd like to customize where bitcoin-cash-node stores its data, you must use the BITCOIN_CASH_NODE_DATA environment variable. The directory will be automatically created with the correct permissions for the bitcoin user and bitcoin-cash-node automatically configured to use it.
❯ docker run --env BITCOIN_CASH_NODE_DATA=/var/lib/data --rm -it uphold/bitcoin-cash-node \
-printtoconsole \
-regtest=1
You can also mount a directory it in a volume under /home/bitcoin/.bitcoin in case you want to access it on the host:
❯ docker run -v ${PWD}/data:/home/bitcoin/.bitcoin -it --rm uphold/bitcoin-cash-node \
-printtoconsole \
-regtest=1
You can optionally create a service using docker-compose:
bitcoin-cash-node:
image: uphold/bitcoin-cash-node
command:
-printtoconsole
-regtest=1
There are two communications methods to interact with a running Bitcoin Cash Node daemon.
The first one is using a cookie-based local authentication. It doesn't require any special authentication information as running a process locally under the same user that was used to launch the Bitcoin Cash Node daemon allows it to read the cookie file previously generated by the daemon for clients. The downside of this method is that it requires local machine access.
The second option is making a remote procedure call using a username and password combination. This has the advantage of not requiring local machine access, but in order to keep your credentials safe you should use the newer rpcauth authentication mechanism.
Start by launching the Bitcoin Cash Node daemon:
❯ docker run --rm --name bitcoin-cash-node-server -it uphold/bitcoin-cash-node \
-printtoconsole \
-regtest=1
Then, inside the running bitcoin-cash-node-server container, locally execute the query to the daemon using bitcoin-cli:
❯ docker exec --user bitcoin bitcoin-cash-node-server bitcoin-cli -regtest getmininginfo
{
"blocks": 0,
"currentblocksize": 0,
"currentblocktx": 0,
"difficulty": 4.656542373906925e-10,
"networkhashps": 0,
"pooledtx": 0,
"chain": "regtest",
"warnings": ""
}
In the background, bitcoin-cli read the information automatically from /home/bitcoin/.bitcoin/regtest/.cookie. In production, the path would not contain the regtest part.
Before setting up remote authentication, you will need to generate the rpcauth line that will hold the credentials for the Bitcoind Core daemon. You can either do this yourself by constructing the line with the format <user>:<salt>$<hash> or use the official rpcuser.py script to generate this line for you, including a random password that is printed to the console.
Example:
❯ curl -sSL https://raw.githubusercontent.com/bitcoin/bitcoin/master/share/rpcuser/rpcuser.py | python - <username>
String to be appended to bitcoin.conf:
rpcauth=foo:7d9ba5ae63c3d4dc30583ff4fe65a67e$9e3634e81c11659e3de036d0bf88f89cd169c1039e6e09607562d54765c649cc
Your password:
qDDZdeQ5vw9XXFeVnXT4PZ--tGN2xNjjR4nrtyszZx0=
Note that for each run, even if the username remains the same, the output will be always different as a new salt and password are generated.
Now that you have your credentials, you need to start the Bitcoin Cash Node daemon with the -rpcauth option. Alternatively, you could append the line to a bitcoin.conf file and mount it on the container.
Let's opt for the Docker way:
❯ docker run --rm --name bitcoin-cash-node-server -it uphold/bitcoin-cash-node \
-printtoconsole \
-regtest=1 \
-rpcallowip=172.17.0.0/16 \
-rpcauth='foo:e1fcea9fb59df8b0388f251984fe85$26431097d48c5b6047df8dee64f387f63835c01a2a463728ad75087d0133b8e6'
Two important notes:
-rpcpassword, the content is hashed so even if the arguments would be exposed, they would not allow the attacker to get the actual password.You can now connect via bitcoin-cli or any other compatible client. You will still have to define a username and password when connecting to the Bitcoin Cash Node RPC server.
To avoid any confusion about whether or not a remote call is being made, let's spin up another container to execute bitcoin-cli and connect it via the Docker network using the password generated above:
❯ docker run --link bitcoin-cash-node-server --rm uphold/bitcoin-cash-node bitcoin-cli -rpcconnect=bitcoin-cash-node-server -regtest -rpcuser=foo -rpcpassword='j1DuzF7QRUp-iSXjgewO9T_WT1Qgrtz_XWOHCMn_O-Y=' getmininginfo
{
"blocks": 0,
"currentblocksize": 0,
"currentblocktx": 0,
"difficulty": 4.656542373906925e-10,
"networkhashps": 0,
"pooledtx": 0,
"chain": "regtest",
"warnings": ""
}
Done!
The uphold/bitcoin-cash-node image comes in multiple flavors:
uphold/bitcoin-cash-node:latestPoints to the latest release available of Bitcoin Cash Node. Occasionally pre-release versions will be included.
uphold/bitcoin-cash-node:<version>Based on a slim Debian image, targets a specific version branch or release of Bitcoin Cash Node.
uphold/bitcoin-cash-node:<version>-alpineBased on Alpine Linux with Berkeley DB 4.8 (cross-compatible build), targets a specific version branch or release of Bitcoin Cash Node.
This image is officially supported on Docker version 20.10.5, with support for older versions provided on a best-effort basis.
License information for the software contained in this image.
License information for the uphold/docker-bitcoin-cash-node docker project.
Content type
Image
Digest
sha256:b390ac413…
Size
70.2 MB
Last updated
5 months ago
docker pull uphold/bitcoin-cash-node