From e4159120f98faf470a6c671b1c3ca9233b5307dc Mon Sep 17 00:00:00 2001 From: Lakshya Singh Date: Thu, 15 Feb 2024 09:00:42 +0530 Subject: [PATCH] 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 --- bitcoind/healthcheck.sh | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/bitcoind/healthcheck.sh b/bitcoind/healthcheck.sh index 9131b63..dc71e54 100755 --- a/bitcoind/healthcheck.sh +++ b/bitcoind/healthcheck.sh @@ -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)