2020-06-11 02:46:55 +00:00
|
|
|
#!/bin/bash
|
2020-06-15 14:40:11 +00:00
|
|
|
set -Eeuo pipefail
|
2020-06-11 02:46:55 +00:00
|
|
|
|
2021-09-12 14:12:43 +00:00
|
|
|
|
|
|
|
# Start bitcoind
|
|
|
|
echo "Starting bitcoind..."
|
2020-06-11 02:46:55 +00:00
|
|
|
bitcoind -datadir=/bitcoind -daemon
|
2021-09-12 14:12:43 +00:00
|
|
|
|
|
|
|
# Wait for bitcoind startup
|
|
|
|
echo -n "Waiting for bitcoind to start"
|
2021-08-25 19:15:48 +00:00
|
|
|
until bitcoin-cli -datadir=/bitcoind -rpcwait getblockchaininfo > /dev/null 2>&1
|
2020-06-15 14:40:11 +00:00
|
|
|
do
|
2021-09-12 14:12:43 +00:00
|
|
|
echo -n "."
|
2020-06-15 14:40:11 +00:00
|
|
|
sleep 1
|
|
|
|
done
|
2021-09-12 14:12:43 +00:00
|
|
|
echo
|
|
|
|
echo "bitcoind started"
|
|
|
|
|
|
|
|
|
|
|
|
# Load private key into wallet
|
2020-06-11 02:46:55 +00:00
|
|
|
export address=`cat /bitcoind/keys/demo_address.txt`
|
|
|
|
export privkey=`cat /bitcoind/keys/demo_privkey.txt`
|
2021-09-12 14:12:43 +00:00
|
|
|
|
|
|
|
# If restarting the wallet already exists, so don't fail if it does,
|
|
|
|
# just load the existing wallet:
|
|
|
|
bitcoin-cli -datadir=/bitcoind createwallet regtest > /dev/null || bitcoin-cli -datadir=/bitcoind loadwallet regtest > /dev/null
|
|
|
|
bitcoin-cli -datadir=/bitcoind importprivkey $privkey > /dev/null || true
|
|
|
|
|
2020-06-11 02:46:55 +00:00
|
|
|
echo "================================================"
|
2021-09-12 14:12:43 +00:00
|
|
|
echo "Imported demo private key"
|
2020-06-11 02:46:55 +00:00
|
|
|
echo "Bitcoin address: " ${address}
|
|
|
|
echo "Private key: " ${privkey}
|
|
|
|
echo "================================================"
|
2020-06-15 14:40:11 +00:00
|
|
|
|
|
|
|
# Executing CMD
|
|
|
|
exec "$@"
|