Skip to content

Commit

Permalink
Remove error from startup_regtest when loading wallet
Browse files Browse the repository at this point in the history
startup_regtest now checks if wallet directory exists before creating
the default wallet, then it will check if wallet is loaded before
attempting to load it. This prevents unnecessary errors during the
execution of this bash script.

[ Squashed fixup: `regtest: restore double quotes on PATH_TO_BITCOIN` -- RR ]
  • Loading branch information
Lagrang3 authored Oct 31, 2023
1 parent 33a0af8 commit 12d8ab6
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions contrib/startup_regtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -142,18 +142,25 @@ start_ln() {
# Wait for it to start.
while ! bitcoin-cli -datadir="$PATH_TO_BITCOIN" -regtest ping 2> /tmp/null; do echo "awaiting bitcoind..." && sleep 1; done

# Kick it out of initialblockdownload if necessary
if bitcoin-cli -datadir="$PATH_TO_BITCOIN" -regtest getblockchaininfo | grep -q 'initialblockdownload.*true'; then
# Modern bitcoind needs createwallet
# Check if default wallet exists
if ! bitcoin-cli -datadir="$PATH_TO_BITCOIN" -regtest listwalletdir | jq -r '.wallets[] | .name' | grep -wqe 'default' ; then
# wallet dir does not exist, create one
echo "Making \"default\" bitcoind wallet."
bitcoin-cli -datadir="$PATH_TO_BITCOIN" -regtest createwallet default >/dev/null 2>&1
# But it might already exist, load it
bitcoin-cli -datadir="$PATH_TO_BITCOIN" -regtest loadwallet default
fi

# Check if default wallet is loaded
if ! bitcoin-cli -datadir="$PATH_TO_BITCOIN" -regtest listwallets | jq -r '.[]' | grep -wqe 'default' ; then
echo "Loading \"default\" bitcoind wallet."
bitcoin-cli -datadir="$PATH_TO_BITCOIN" -regtest loadwallet default >/dev/null 2>&1
fi

# Kick it out of initialblockdownload if necessary
if bitcoin-cli -datadir="$PATH_TO_BITCOIN" -regtest getblockchaininfo | grep -q 'initialblockdownload.*true'; then
bitcoin-cli -datadir="$PATH_TO_BITCOIN" -regtest generatetoaddress 1 "$(bitcoin-cli -datadir="$PATH_TO_BITCOIN" -regtest getnewaddress)" > /dev/null
else
bitcoin-cli -datadir="$PATH_TO_BITCOIN" -regtest loadwallet default
fi
alias bt-cli='bitcoin-cli -datadir=$PATH_TO_BITCOIN -regtest'

alias bt-cli='bitcoin-cli -datadir="$PATH_TO_BITCOIN" -regtest'

if [ -z "$1" ]; then
nodes=2
Expand Down

0 comments on commit 12d8ab6

Please sign in to comment.