vls-container/bitcoind/healthcheck.sh
Lakshya Singh e4159120f9
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>
2024-02-21 20:17:09 +05:30

24 lines
690 B
Bash
Executable File

#!/bin/sh
set -ex
if [[ "$BITCOIN_CHAIN" = "regtest" ]]; then
# Check if default wallet isn't loaded
if ! bitcoin-cli listwallets | grep -q "default"; then
# 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)
fi
fi
bitcoin-cli -chain=$BITCOIN_CHAIN getblockchaininfo