Skip to content

Commit 9d079a4

Browse files
committed
format
1 parent beaebde commit 9d079a4

8 files changed

+170
-174
lines changed

miner_signet.yml

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
version: "3.8"
2-
31
services:
42
btc_sig_miner:
53
container_name: btc_sig_miner

miner_signet/Dockerfile

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ FROM ${OS}:${OS_VER} as bitcoind-install
44

55
# Install dependencies
66
RUN DEBIAN_FRONTEND=noninteractive \
7-
apt-get update -qq && apt-get install -y nano \
8-
net-tools nmap bc gpg curl unzip jq bash-completion git \
9-
python3 python3-pip python3-setuptools && \
10-
pip install argparse requests cryptography pipreqs
7+
apt-get update -qq && apt-get install -y nano \
8+
net-tools nmap bc gpg curl unzip jq bash-completion git \
9+
python3 python3-pip python3-setuptools && \
10+
pip install argparse requests cryptography pipreqs
1111

1212
RUN DEBIAN_FRONTEND=noninteractive \
13-
apt-get -y install python3.9
13+
apt-get -y install python3.9
1414

1515
# Install bitcoind
1616
ENV BITCOIND_VER="24.0.1"

miner_signet/bashrc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Use bash-completion, if available
22
alias bitcoin-cli="bitcoin-cli -datadir=/bitcoind"
33

4-
[[ $PS1 && -f /usr/share/bash-completion/bash_completion ]] && \
5-
. /usr/share/bash-completion/bash_completion
4+
[[ $PS1 && -f /usr/share/bash-completion/bash_completion ]] &&
5+
. /usr/share/bash-completion/bash_completion

miner_signet/bitcoind-download.sh

+19-19
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,31 @@ architecture=$(uname -m)
55

66
# Check the architecture and print the corresponding message
77
case $architecture in
8-
x86_64)
9-
BITCOIN_FILE="bitcoin-${BITCOIND_VER}-x86_64-linux-gnu.tar.gz"
10-
echo "Installing Bitcoin Core ${BITCOIND_VER} for x86_64"
11-
;;
12-
aarch64)
13-
BITCOIN_FILE="bitcoin-${BITCOIND_VER}-aarch64-linux-gnu.tar.gz"
14-
echo "Installing Bitcoin Core ${BITCOIND_VER} for aarch64"
15-
;;
8+
x86_64)
9+
BITCOIN_FILE="bitcoin-${BITCOIND_VER}-x86_64-linux-gnu.tar.gz"
10+
echo "Installing Bitcoin Core ${BITCOIND_VER} for x86_64"
11+
;;
12+
aarch64)
13+
BITCOIN_FILE="bitcoin-${BITCOIND_VER}-aarch64-linux-gnu.tar.gz"
14+
echo "Installing Bitcoin Core ${BITCOIND_VER} for aarch64"
15+
;;
1616
esac
1717

1818
# Install Bitcoin Core binaries and libraries
19-
cd /tmp && \
20-
curl -# -sLO https://bitcoincore.org/bin/bitcoin-core-${BITCOIND_VER}/${BITCOIN_FILE} && \
21-
curl -# -sLO https://bitcoincore.org/bin/bitcoin-core-${BITCOIND_VER}/SHA256SUMS
19+
cd /tmp &&
20+
curl -# -sLO https://bitcoincore.org/bin/bitcoin-core-${BITCOIND_VER}/${BITCOIN_FILE} &&
21+
curl -# -sLO https://bitcoincore.org/bin/bitcoin-core-${BITCOIND_VER}/SHA256SUMS
2222

2323
# Verify the integrity of the binaries
2424
# TODO: add gpg verification on SHA256SUMS
2525

2626
cd /tmp && grep "${BITCOIN_FILE}" SHA256SUMS | sha256sum -c -
2727

28-
cd /tmp && \
29-
tar -zxf ${BITCOIN_FILE} && \
30-
cd bitcoin-${BITCOIND_VER} && \
31-
install -vD bin/* /usr/bin && \
32-
install -vD lib/* /usr/lib && \
33-
cd /tmp && \
34-
rm ${BITCOIN_FILE} && \
35-
rm -rf bitcoin-${BITCOIND_VER}
28+
cd /tmp &&
29+
tar -zxf ${BITCOIN_FILE} &&
30+
cd bitcoin-${BITCOIND_VER} &&
31+
install -vD bin/* /usr/bin &&
32+
install -vD lib/* /usr/lib &&
33+
cd /tmp &&
34+
rm ${BITCOIN_FILE} &&
35+
rm -rf bitcoin-${BITCOIND_VER}

miner_signet/bitcoind-entrypoint.sh

+90-97
Original file line numberDiff line numberDiff line change
@@ -3,100 +3,95 @@ set -Eeuo pipefail
33

44
# Move bitcoin.conf to /bitcoind
55
if [ -f "/data/bitcoin.conf" ]; then
6-
mv /data/bitcoin.conf /bitcoind/bitcoin.conf
7-
ln -s /bitcoind /root/.
8-
# If not is assumed that the bitcoin.conf is already in /bitcoind
6+
mv /data/bitcoin.conf /bitcoind/bitcoin.conf
7+
ln -s /bitcoind /root/.
8+
# If not is assumed that the bitcoin.conf is already in /bitcoind
99
fi
1010

1111
# Check if there is already the 'signetchallenge' option in 'bitcoin.conf' different from the default
1212
# 'signetchallenge=00000000' added to not download any chain.
1313
echo "===================================="
1414
echo "Signetchallenge creation process"
15-
while read -r line
16-
do
17-
# Check line by line
18-
if [[ "$line" == *"signetchallenge=00000000"* ]]; then
19-
SIGNETCHALLENGE=false
20-
elif [[ "$line" == *"signetchallenge="* ]]; then
21-
echo "'signetchallenge' param already present in bitcoin.conf"
22-
echo "$line"
23-
SIGNETCHALLENGE=true
24-
fi
25-
done < "/bitcoind/bitcoin.conf"
15+
while read -r line; do
16+
# Check line by line
17+
if [[ "$line" == *"signetchallenge=00000000"* ]]; then
18+
SIGNETCHALLENGE=false
19+
elif [[ "$line" == *"signetchallenge="* ]]; then
20+
echo "'signetchallenge' param already present in bitcoin.conf"
21+
echo "$line"
22+
SIGNETCHALLENGE=true
23+
fi
24+
done <"/bitcoind/bitcoin.conf"
2625

2726
if [ $SIGNETCHALLENGE = false ]; then
28-
# Create a new signetchallenge
29-
# Start bitcoind
30-
echo "Starting bitcoind..."
31-
bitcoind -datadir=/bitcoind -daemon 2>&1 > /dev/null
32-
33-
# Wait for bitcoind startup
34-
until bitcoin-cli -datadir=/bitcoind -rpcwait getblockchaininfo > /dev/null 2>&1
35-
do
36-
echo -n "."
37-
sleep 1
38-
done
39-
echo "bitcoind started."
40-
echo "===================================="
41-
42-
# Create a new wallet
43-
# Uncomment the following line if a custom wallet name is require and comment the `WALLET="wallet"` line.
44-
# read -p "Enter the name of the wallet: " WALLET
45-
WALLET="wallet"
46-
bitcoin-cli -datadir=/bitcoind -named createwallet wallet_name="$WALLET" descriptors=true 2>&1 > /dev/null
47-
48-
# Get the signet script from the 86 descriptor
49-
ADDR=$(bitcoin-cli -datadir=/bitcoind getnewaddress)
50-
SCRIPT=$(bitcoin-cli -datadir=/bitcoind getaddressinfo $ADDR | jq -r ".scriptPubKey")
51-
sed -i "s/signetchallenge=00000000/signetchallenge=$SCRIPT/" /bitcoind/bitcoin.conf
52-
53-
54-
# Dumping descriptor wallet privatekey
55-
WALLETFILE="${WALLET}_privkey.txt"
56-
bitcoin-cli -datadir=/bitcoind listdescriptors true | jq -r ".descriptors | .[].desc" >> "/bitcoind/${WALLETFILE}"
57-
58-
# Wait for bitcoind shutdown
59-
echo "Waiting for bitcoind to stop."
60-
bitcoin-cli -datadir=/bitcoind stop &
61-
wait
62-
echo "bitcoind stopped."
63-
# Removing any downloaded timechain
64-
rm -rf /bitcoind/signet/ &
65-
wait
27+
# Create a new signetchallenge
28+
# Start bitcoind
29+
echo "Starting bitcoind..."
30+
bitcoind -datadir=/bitcoind -daemon 2>&1 >/dev/null
31+
32+
# Wait for bitcoind startup
33+
until bitcoin-cli -datadir=/bitcoind -rpcwait getblockchaininfo >/dev/null 2>&1; do
34+
echo -n "."
35+
sleep 1
36+
done
37+
echo "bitcoind started."
38+
echo "===================================="
39+
40+
# Create a new wallet
41+
# Uncomment the following line if a custom wallet name is require and comment the `WALLET="wallet"` line.
42+
# read -p "Enter the name of the wallet: " WALLET
43+
WALLET="wallet"
44+
bitcoin-cli -datadir=/bitcoind -named createwallet wallet_name="$WALLET" descriptors=true 2>&1 >/dev/null
45+
46+
# Get the signet script from the 86 descriptor
47+
ADDR=$(bitcoin-cli -datadir=/bitcoind getnewaddress)
48+
SCRIPT=$(bitcoin-cli -datadir=/bitcoind getaddressinfo $ADDR | jq -r ".scriptPubKey")
49+
sed -i "s/signetchallenge=00000000/signetchallenge=$SCRIPT/" /bitcoind/bitcoin.conf
50+
51+
# Dumping descriptor wallet privatekey
52+
WALLETFILE="${WALLET}_privkey.txt"
53+
bitcoin-cli -datadir=/bitcoind listdescriptors true | jq -r ".descriptors | .[].desc" >>"/bitcoind/${WALLETFILE}"
54+
55+
# Wait for bitcoind shutdown
56+
echo "Waiting for bitcoind to stop."
57+
bitcoin-cli -datadir=/bitcoind stop &
58+
wait
59+
echo "bitcoind stopped."
60+
# Removing any downloaded timechain
61+
rm -rf /bitcoind/signet/ &
62+
wait
6663
fi
6764

6865
# Start bitcoind
6966
echo "Restarting bitcoind..."
7067
bitcoind -datadir=/bitcoind -daemon
7168

7269
# Wait for bitcoind startup
73-
until bitcoin-cli -datadir=/bitcoind -rpcwait getblockchaininfo > /dev/null 2>&1
74-
do
75-
echo -n "."
76-
sleep 1
70+
until bitcoin-cli -datadir=/bitcoind -rpcwait getblockchaininfo >/dev/null 2>&1; do
71+
echo -n "."
72+
sleep 1
7773
done
7874
echo
7975
echo "bitcoind started"
8076

8177
if [ $SIGNETCHALLENGE = false ]; then
82-
# If there is any wallet, create a descriptor wallet
83-
bitcoin-cli -datadir=/bitcoind -named createwallet wallet_name="$WALLET" blank=true descriptors=true 2>&1 > /dev/null
84-
echo "================================================"
85-
echo "Importing descriptors for the private key:"
86-
line_count=0
87-
while read line; do
88-
# Increment the line counter
89-
line_count=$((line_count+1))
90-
91-
# Check if the line count is even or odd
92-
if [ $((line_count % 2)) -eq 0 ]; then
93-
is_even="true"
94-
else
95-
is_even="false"
96-
fi
97-
98-
99-
DESCRIPTORS="
78+
# If there is any wallet, create a descriptor wallet
79+
bitcoin-cli -datadir=/bitcoind -named createwallet wallet_name="$WALLET" blank=true descriptors=true 2>&1 >/dev/null
80+
echo "================================================"
81+
echo "Importing descriptors for the private key:"
82+
line_count=0
83+
while read line; do
84+
# Increment the line counter
85+
line_count=$((line_count + 1))
86+
87+
# Check if the line count is even or odd
88+
if [ $((line_count % 2)) -eq 0 ]; then
89+
is_even="true"
90+
else
91+
is_even="false"
92+
fi
93+
94+
DESCRIPTORS="
10095
{
10196
\"desc\": \"${line}\",
10297
\"timestamp\": 0,
@@ -107,37 +102,35 @@ if [ $SIGNETCHALLENGE = false ]; then
107102
999
108103
]
109104
}"
110-
111-
DESCRIPTORS="[${DESCRIPTORS//[$'\t\r\n ']}]"
112-
113-
bitcoin-cli -datadir=/bitcoind importdescriptors "$DESCRIPTORS" 2>&1 > /dev/null
114-
115-
done < "/bitcoind/${WALLETFILE}"
116-
echo "$(bitcoin-cli -datadir=/bitcoind listdescriptors)"
117-
echo "================================================"
105+
106+
DESCRIPTORS="[${DESCRIPTORS//[$'\t\r\n ']/}]"
107+
108+
bitcoin-cli -datadir=/bitcoind importdescriptors "$DESCRIPTORS" 2>&1 >/dev/null
109+
110+
done <"/bitcoind/${WALLETFILE}"
111+
echo "$(bitcoin-cli -datadir=/bitcoind listdescriptors)"
112+
echo "================================================"
118113
else
119-
# If restarting, load the wallet that already exists, so don't fail if it does,
120-
# just load the existing wallet:
121-
echo "================================================"
122-
echo "Loading the main wallet:"
123-
WALLET=$(ls /bitcoind/signet/wallets -1 | head -1 | tail -1)
124-
bitcoin-cli -datadir=/bitcoind loadwallet "$WALLET" 2>&1 >/dev/null
125-
echo "Bitcoin core wallet \"$WALLET\" loaded."
126-
echo "================================================"
114+
# If restarting, load the wallet that already exists, so don't fail if it does,
115+
# just load the existing wallet:
116+
echo "================================================"
117+
echo "Loading the main wallet:"
118+
WALLET=$(ls /bitcoind/signet/wallets -1 | head -1 | tail -1)
119+
bitcoin-cli -datadir=/bitcoind loadwallet "$WALLET" 2>&1 >/dev/null
120+
echo "Bitcoin core wallet \"$WALLET\" loaded."
121+
echo "================================================"
127122
fi
128123

129124
# Get the signet magic string from bitcoind debug logs
130125

131-
132126
if [ -f "/bitcoind/sig_magic.txt" ]; then
133-
# If the file exists, check if the magic string is the same
134-
echo "Signet magic: $(cat /bitcoind/sig_magic.txt)"
127+
# If the file exists, check if the magic string is the same
128+
echo "Signet magic: $(cat /bitcoind/sig_magic.txt)"
135129
else
136-
# If the file doesn't exist, create it
137-
SIG_MAGIC=`cat /bitcoind/signet/debug.log | grep -oP 'Signet derived magic \(message start\): \K[a-f0-9]+'`
138-
echo $SIG_MAGIC > /bitcoind/sig_magic.txt
130+
# If the file doesn't exist, create it
131+
SIG_MAGIC=$(cat /bitcoind/signet/debug.log | grep -oP 'Signet derived magic \(message start\): \K[a-f0-9]+')
132+
echo $SIG_MAGIC >/bitcoind/sig_magic.txt
139133
fi
140134

141135
# Executing CMD
142136
exec "$@"
143-

miner_signet/bitcoind/bitcoin.conf

+3
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,6 @@ zmqpubrawblock=tcp://0.0.0.0:28332
3434
zmqpubhashblock=tcp://0.0.0.0:28334
3535

3636
signetchallenge=00000000
37+
# signetchallenge=5121022047cf340e32a1e2d3012d299d8426201dd3b8c1547fefcedef2db6da184e7bdc21021033d2e7b6c05dbab54b0d43b9e18e1d53af709282eb3eea324fbf404e76b8dc63752ae
38+
# addnode=178.62.246.6
39+
# addnode=68.183.118.49

0 commit comments

Comments
 (0)