bitcoind: healthcheck fix regtest

- if wallet file is present we can't create new wallet, we load it
- set -ex wasn't enabled which didn't fail the healthcheck
Signed-off-by: Lakshya Singh <lakshay.singh1108@gmail.com>
This commit is contained in:
Lakshya Singh 2024-02-15 09:00:42 +05:30
parent 22b2c1b63a
commit e4159120f9
No known key found for this signature in database
GPG Key ID: D3239BA6109A2CE7

View File

@ -1,11 +1,19 @@
#!/bin/sh
set -ex
if [[ "$BITCOIN_CHAIN" = "regtest" ]]; then
# Check if the wallet already exists
# Check if default wallet isn't loaded
if ! bitcoin-cli listwallets | grep -q "default"; then
# If the wallet does not exist, create it
bitcoin-cli createwallet default
# Check if default wallet is present and needs to be loaded
if bitcoin-cli listwalletdir | grep -q "default"; then
bitcoin-cli loadwallet default
else
# create default wallet since no file was found
bitcoin-cli createwallet default
fi
fi
block_count=$(bitcoin-cli -chain=$BITCOIN_CHAIN getblockcount)
if [[ "$block_count" = "0" ]]; then
bitcoin-cli generatetoaddress 101 $(bitcoin-cli -chain=$BITCOIN_CHAIN getnewaddress)