Skip to content

Commit

Permalink
feat: mine 101 blocks right away (#17)
Browse files Browse the repository at this point in the history
Co-authored-by: Fanis Michalakis <fanis.michalakis@ito.am>
  • Loading branch information
fanismichalakis and Fanis Michalakis authored Nov 9, 2023
1 parent bca7da3 commit 4da5740
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 4 additions & 3 deletions docker/bitcoin-regtest/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
# Bitcoin Regtest

This app is a simple bitcoin regtest node with auto-mining enabled.
The node will mine 1 block every 30 seconds

You can disable the auto-mining by setting the `CRON_MINE_BTC` env variable to `false`
The node will mine the 101 first blocks instantly right after initialization, so that at least one coinbase is [mature](https://bitcoin.stackexchange.com/questions/1991/what-is-the-block-maturation-time) from the get go. Then, it will automatically mine 1 new block every 30 seconds.

You can disable the auto-mining by setting the `CRON_MINE_BTC` env variable to `false`. Note that it also disables the mining of the first 101 blocks.

The bitcoin node rpc is listening on port `18443`, to connect to the rpc use `satoshi` as username and `satoshi` as password
The zmq port are `28334` for raw blocks and `28335` for raw transactions

You can use the `mine` command to mine a specific amount of blocks

```bash
docker exec -it bitcoin-regtest mine 10
docker exec -it bitcoin-regtest mine -b 10
```
3 changes: 2 additions & 1 deletion docker/bitcoin-regtest/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ create_and_load_wallet() {
bitcoin-cli -regtest loadwallet satoshi 2>/dev/null | true
}

# Mine blocks every 30 seconds
# Mine 1 block every 30 seconds
mine_btc() {
sleep 5 && mine -b 101
while true; do
sleep $MININING_INTERVAL && mine
done
Expand Down

0 comments on commit 4da5740

Please sign in to comment.