Testing with Bitcoin

Testing integration with fake Bitcoins

Given the nature of Bitcoin's scarcity. Testing your application can be challening specially if you want to test it in the closest scenario to the production as possible. This is why the Bitcoin core team have come up with the Testnet, which is a network with the same rules as the actual Bitcoin network but the coins have no value.

This guide will walk you through the process of testing bamotf with a testnet wallet. This includes setting up the Bitcoin core over the testnet, configuring bamotf, and setting up your testnet wallet.

Setting up the Bitcoin Core over the Testnet

To set up the Bitcoin Core over the testnet, you will need to download and install the Bitcoin Core on your server. You can find lots of guides on how to do this online. This approach can be time-consuming and resource-intensive so it can get expensive.

Optionally, you can use Docker to run the Bitcoin Core over the testnet on your own machine or server using the ruimarinho/bitcoin-core Docker image. This is a lightweight image that is easy to set up and use. You can find more information about this image on its Docker Hub page (opens in a new tab). Or you can use the following docker-compose.yml file to run the Bitcoin Core

version: '3.8'
  bamotf: ...
    image: ruimarinho/bitcoin-core:latest
    command: [
        '-rpcuser=myrpcuser', # Replace with your own RPC username
        '-rpcpassword=myrpcpassword', # Replace with your own RPC password
      - 18332:18332
      - ./docker-data/bitcoin:/home/bitcoin/.bitcoin

Be aware that this may take some time to download and sync the blockchain. You can check the status of the blockchain sync by running the following command:

docker logs -f bitcoin-core-testnet

If you prefer, you can download the snapshot of the blockchain (opens in a new tab) and unpack it on the ./bitcoin/testnet3 folder to speed up the process.

Configuring bamotf

To configure bamotf to use the Bitcoin Core over the testnet, you will need to set the TESTNET_BITCOIN_CORE_URL environment variable to your bamotf server. This URL should include the user and password for the RPC connection.

If you want to test it locally, you just need to set the TESTNET_BITCOIN_CORE_URL environment variable on your docker-compose file.

version: '3.8'
      - TESTNET_BITCOIN_CORE_URL=http://myrpcuser:myrpcpassword@bitcoin-core-testnet:18332

After that, you will need to create an API Key (opens in a new tab) and Webhook (opens in a new tab) to your test environment and add them to your application.

Setting up Your Testnet Wallet

Install the Blockstream's Green Wallet

Download and install the Blockstream's Green Wallet (opens in a new tab) on your phone.

Create a Testnet Wallet

In order to create a testnet wallet, you first need to create a mainet wallet. After creating the mainet wallet, head back to the list of wallets screen and click on the App Settings button and turn on Enable testnet then, click on Save.

After that just follow the normal "New Wallet" flow.

Get Some Testnet Coins

Now that you have a testnet wallet, you need to get some testnet coins. Go to one of the following testnet faucets and enter your testnet wallet address to get some testnet coins:

Remember, the testnet network is separate from the main Bitcoin network. Coins on the testnet have no real-world value and are useful for testing purposes only.

The bamotf/core-dev image

This is mainly used by the bamotf team to test the integration.

We also ship this bamotf/core-dev image which is a base image for building and testing the Bitcoin core under the regtest network. During the inicialization, it creates a test-wallet and mine 101 blocks to it so you can start testing your application right away.

You probably don't need it but in case you do, you can access this image with the following RPC access:

  • user: username
  • password: wc7eFmVwEeZCDYTMaOqxRnLWSR7aI76bGmHl6pRFtAU