Deploy Bitcoin RPC Node

Generate JSON-RPC password secret

Bitcoin nodes that enable JSON-RPC server are required to use basic authentication while calling JSON-RPC methods.

# WARNING: DON'T use the following secret in production
apiVersion: v1
kind: Secret
  name: kotal-rpc-user-password
  password: s3cr3t

Apply rpc-user-password.yaml to create the password secret:

kubectl apply -f rpc-user-password.yaml

Deploy Bitcoin RPC Node

The following manifest describes a Bitcoin node that syncs Bitcoin mainnet network: mainnet, enables HTTP JSON-RPC server rpc: true, defines JSON-RPC user credentials rpcUsers: ... and uses Bitcoin Core client:

kind: Node
  name: bitcoin-node
  network: mainnet
  rpc: true
    - username: kotal
      passwordSecretName: kotal-rpc-user-password

Apply bitcoin.yaml manifest:

kubectl apply -f bitcoin.yaml

Kotal operator will notice your bitcoin-node and will create all the necessary pods, persistent volumes, services, configmaps, and secrets neccessary.

You can fetch the deployed Bitcoin Node using:

kubectl get nodes.bitcoin

It will return an output similar to the following:

bitcoin-node    mainnet    bitcoincore

Fetch Node Logs

Get the pods that has been created by Kotal for the node:

kubectl get pods

It will return an output similar to the following:

bitcoin-node-0    1/1     Running   0          1m

Get the logs of the running node:

kubectl logs -f bitcoin-node-0

It will return node logs similar to the following:

2022-04-09T18:26:45Z Bitcoin Core version v22.0.0 (release build)
2022-04-09T18:26:45Z InitParameterInteraction: parameter interaction: -bind set -> setting -listen=1
2022-04-09T18:26:45Z Assuming ancestors of block 00000000000000000008a89e854d57e5667df88f1cdef6fde2fbca1de5b639ad have valid signatures.
2022-04-09T18:26:45Z Setting nMinimumChainWork=00000000000000000000000000000000000000001fa4663bbbe19f82de910280
2022-04-09T18:26:45Z Using the 'sse4(1way),sse41(4way),avx2(8way)' SHA256 implementation
2022-04-09T18:26:45Z Using RdRand as an additional entropy source
2022-04-09T18:26:45Z Wallet disabled!
2022-04-09T18:27:02Z Synchronizing blockheaders, height: 9999 (~1.44%)
2022-04-09T18:27:02Z Synchronizing blockheaders, height: 11999 (~1.73%)
2022-04-09T18:27:02Z Synchronizing blockheaders, height: 13999 (~2.02%)
2022-04-09T18:27:02Z Synchronizing blockheaders, height: 15999 (~2.31%)
2022-04-09T18:27:02Z Synchronizing blockheaders, height: 17999 (~2.61%)
2022-04-09T18:27:03Z Synchronizing blockheaders, height: 19999 (~2.90%)
2022-04-09T18:27:03Z Synchronizing blockheaders, height: 21999 (~3.21%)
2022-04-09T18:27:03Z Synchronizing blockheaders, height: 23999 (~3.51%)
2022-04-09T18:27:04Z Synchronizing blockheaders, height: 25999 (~3.82%)
2022-04-09T18:27:04Z Synchronizing blockheaders, height: 27999 (~4.13%)
2022-04-09T18:27:04Z Synchronizing blockheaders, height: 29999 (~4.43%)

Call JSON-RPC Method

By default, Bitcoin node JSON-RPC server port is 8332, which can be changed using rpcPort.

Forward localhost:8332 calls to the node pod:

kubectl port-forward bitcoin-node-0 8332

In another terminal window call getblockhash JSON-RPC method to get the genesis block hash:

curl --user "kotal:s3cr3t" --data-binary '{"jsonrpc": "1.0", "id": 1, "method": "getblockhash", "params": [0]}' -H 'content-type: text/plain;'

You will get JSON result similar to the following:


Finally you can delete the node by:

kubectl delete -f bitcoin.yaml

Kubernetes garbage collector will delete all the resources that has been created by Bitcoin Node controller.

Last updated