bitcoind: generate blocks on healthcheck in regtest

Signed-off-by: Lakshya Singh <lakshay.singh1108@gmail.com>
This commit is contained in:
Lakshya Singh 2023-12-13 19:27:34 +05:30
parent eb4926b203
commit e3161eea59
No known key found for this signature in database
GPG Key ID: D3239BA6109A2CE7

View File

@ -1 +1,15 @@
bitcoin-cli -chain=$BITCOIN_CHAIN getblockchaininfo #!/bin/sh
if [[ "$BITCOIN_CHAIN" = "regtest" ]]; then
# Check if the wallet already exists
if ! bitcoin-cli listwallets | grep -q "default"; then
# If the wallet does not exist, create it
bitcoin-cli createwallet default
fi
block_count=$(bitcoin-cli -chain=$BITCOIN_CHAIN getblockcount)
if [[ "$block_count" = "0" ]]; then
bitcoin-cli generatetoaddress 101 $(bitcoin-cli -chain=$BITCOIN_CHAIN getnewaddress)
fi
fi
bitcoin-cli -chain=$BITCOIN_CHAIN getblockchaininfo