-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbootstrap_bitcoind.sh
executable file
·79 lines (65 loc) · 1.91 KB
/
bootstrap_bitcoind.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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
source env.sh
ARCH=$(uname -m)
case $ARCH in
x86_64)
BITCOIN_TARBALL="bitcoin-${BITCOIN_VERSION}-x86_64-linux-gnu.tar.gz"
;;
aarch64)
BITCOIN_TARBALL="bitcoin-${BITCOIN_VERSION}-aarch64-linux-gnu.tar.gz"
;;
riscv64)
BITCOIN_TARBALL="bitcoin-${BITCOIN_VERSION}-riscv64-linux-gnu.tar.gz"
;;
*)
echo "Unsupported architecture: $ARCH"
exit 1
;;
esac
BITCOIN_TARBALL_URL="https://bitcoincore.org/bin/bitcoin-core-${BITCOIN_VERSION}/${BITCOIN_TARBALL}"
# Check if the directory exists
if [ ! -d "$BITCOIN_UNPACKED" ]; then
echo "Directory $BITCOIN_UNPACKED does not exist. Downloading tarball..."
wget "$BITCOIN_TARBALL_URL" -O "$BITCOIN_TARBALL"
if [ $? -ne 0 ]; then
echo "Download failed. Exiting."
exit 1
fi
echo "Download successful. Unpacking tarball..."
tar -xzf "$BITCOIN_TARBALL"
if [ $? -ne 0 ]; then
echo "Extraction failed. Exiting."
exit 1
fi
echo "Removing tarball..."
rm "$BITCOIN_TARBALL"
echo "Bitcoin Core version $BITCOIN_VERSION has been downloaded and unpacked successfully."
else
echo "Directory $BITCOIN_UNPACKED already exists. Skipping download and extraction."
fi
if [ -d "$BITCOIN_DATADIR" ]; then
echo "We are about to erase the contents of $BITCOIN_DATADIR. Do you want to continue? (yes/no)"
read -r user_input
if [ "$user_input" != "yes" ]; then
echo "User did not consent. Exiting."
exit 1
fi
rm -rf $BITCOIN_DATADIR/*
fi
echo "Creating $BITCOIN_DATADIR"
mkdir -p $BITCOIN_DATADIR/signet
if [ -d "$PLEBNET_SNAPSHOT" ]; then
cp -r plebnet_snapshot/{blocks,chainstate} $BITCOIN_DATADIR/signet
fi
cat << EOF > $BITCOIN_DATADIR/bitcoin.conf
[signet]
server=1
rpcuser=user
rpcpassword=pass
# OP_TRUE
signetchallenge=51
addnode=$PLEBNET_GENESIS_NODE_IP # genesis node
# addnode=fixme
# addnode=fixme
# addnode=fixme
EOF