From 28fe6cbcdec2c09d21745f8e95cc25c8eb17cc3e Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Wed, 25 Aug 2021 21:16:20 +0200 Subject: [PATCH] bitcoind: Use loadwallet when restarting When restarting a docker-compose set of containers we might already have created the wallet, so load it instead. --- code/docker/bitcoind/bitcoind-entrypoint.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/code/docker/bitcoind/bitcoind-entrypoint.sh b/code/docker/bitcoind/bitcoind-entrypoint.sh index c9a17f8..51b65d7 100644 --- a/code/docker/bitcoind/bitcoind-entrypoint.sh +++ b/code/docker/bitcoind/bitcoind-entrypoint.sh @@ -15,8 +15,10 @@ echo "Importing demo private key" echo "Bitcoin address: " ${address} echo "Private key: " ${privkey} echo "================================================" -bitcoin-cli -datadir=/bitcoind createwallet regtest -bitcoin-cli -datadir=/bitcoind importprivkey $privkey +# If restarting the wallet already exists, so don't fail if it does, +# just load the existing wallet: +bitcoin-cli -datadir=/bitcoind createwallet regtest || bitcoin-cli -datadir=/bitcoind loadwallet regtest +bitcoin-cli -datadir=/bitcoind importprivkey $privkey || true # Executing CMD echo "$@"