Skip to main content

Bitcoin Testing

Starting a Local Bitcoin Development Environment

We have a docker-compose.yml setup script in the BOB repository.

The docker file will:

  • Run the Bitcoin daemon
  • Fund the "Alice" wallet
  • Mine a block every ten seconds
  • Start the Esplora backend to index the local chain and provide a REST API
  • Start the ord ordinals indexer, block explorer, and wallet

Using Bitcoin Core

The recommended approach to start a local Bitcoin node for testing is to use "regtest" mode. If you have downloaded Bitcoin Core from bitcoin.org use the following to start a regtest node.

bitcoind -regtest -daemon

To stop the node, use the following command:

bitcoin-cli -regtest stop

Using Nigiri Bitcoin

For an alterantive development environment check out Nigiri Bitcoin which also packages a Liquid daemon and an Electrum server.

Funding a Wallet

info

This step is only required if you are not using the docker-compose.yml script.

To create and fund the "Alice" wallet, use the following bitcoin-cli commands:

bitcoin-cli -regtest createwallet Alice
ALICE_ADDRESS=$(bitcoin-cli -regtest -rpcwallet=Alice getnewaddress)
bitcoin-cli -regtest generatetoaddress 101 ${ALICE_ADDRESS}
info

Funds from the coinbase transaction need 100 confirmations to be spendable, so make sure to mine a sufficient number of blocks. The command above mines 101 blocks, which is the minimum required for the funds to be spendable.

Transferring Funds

To create and send funds to the "Bob" wallet, use the following commands:

bitcoin-cli -regtest createwallet Bob
BOB_ADDRESS=$(bitcoin-cli -regtest -rpcwallet=Bob getnewaddress)
bitcoin-cli -regtest -rpcwallet=Alice -named sendtoaddress address=${BOB_ADDRESS} amount=$(bitcoin-cli -regtest -rpcwallet=Alice getbalance) subtractfeefromamount=true

To use a supported Graphical User Interface (GUI) instead, terminate the bitcoind process and run bitcoin-qt instead:

Bitcoin Core Wallet GUI