forked from bitcoinerlab/tester
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_bitcoind_service.sh
26 lines (22 loc) · 1.19 KB
/
run_bitcoind_service.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env bash
# Define a path to the flag file
FLAG_FILE="$TAPE_VOLUME_DIR/.bitcoind_setup_done"
# Set default values if not provided
: ${PREMINED:=432} # Set PREMINED to 432 if not already set
/usr/bin/bitcoind -datadir="$BITCOIN_DIR" -server -regtest -txindex -zmqpubhashtx=tcp://127.0.0.1:30001 -zmqpubhashblock=tcp://127.0.0.1:30001 -rpcworkqueue=32 -fallbackfee=0.0002 $([ "$REINDEX" = "1" ] && echo "-reindex") &
disown
sleep 2
# Check if the initial setup has been done (wallet creation and mining)
if [ ! -f "$FLAG_FILE" ]; then
echo "First-time setup: Creating wallet and mining blocks..."
/usr/bin/bitcoin-cli -datadir="$BITCOIN_DIR" -regtest createwallet default
/usr/bin/bitcoin-cli -datadir="$BITCOIN_DIR" -regtest loadwallet default
ADDRESS=$(/usr/bin/bitcoin-cli -datadir="$BITCOIN_DIR" -regtest getnewaddress "" bech32)
#Mine 1 million btc and be rich!
/usr/bin/bitcoin-cli -datadir="$BITCOIN_DIR" -regtest generatetoaddress $PREMINED $ADDRESS
# Create a flag file to indicate that the setup has been completed
touch "$FLAG_FILE"
else
echo "Skipping setup. Wallet and blocks already created."
/usr/bin/bitcoin-cli -datadir="$BITCOIN_DIR" -regtest loadwallet default
fi