Skip to content

Commit 32ba9f7

Browse files
committed
network.sh
1 parent 03dbba6 commit 32ba9f7

File tree

16 files changed

+484
-7
lines changed

16 files changed

+484
-7
lines changed

miner.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
rsync -r ./signet_data/* ./signet_data-0/
2+
cat ./signet_data-0/bitcoin.conf
3+
./bin/bitcoin-cli --signet -netinfo -rpcpassword=signetpassword -rpcuser=signetuser --datadir=./signet_data-0
4+
./bin/bitcoind --datadir=./signet_data-0 -port=8080 -server & sleep 3;
5+
./bin/bitcoin-cli --signet -netinfo -rpcpassword=signetpassword -rpcuser=signetuser --datadir=./signet_data-0
6+
cat ./signet_data/bitcoin.conf
7+
./bin/bitcoin-cli --signet -netinfo -rpcpassword=signetpassword -rpcuser=signetuser --datadir=./signet_data
8+
count=0
9+
while ((count < 101));do
10+
../contrib/signet/miner --cli './bin/bitcoin-cli -datadir=./signet_data' generate --address tb1quj2f4cdeczgsuqcuse0aehc8alp2zyqknfs8zg --grind-cmd './bin/bitcoin-util grind' --min-nbits #--ongoing
11+
./bin/bitcoin-cli --signet -netinfo -rpcpassword=signetpassword -rpcuser=signetuser --datadir=./signet_data
12+
./bin/bitcoin-cli --signet -netinfo -rpcpassword=signetpassword -rpcuser=signetuser --datadir=./signet_data-0
13+
done
14+
exit;

pr896/miner3.sh renamed to network.sh

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ grinder="./bin/bitcoin-util grind"
2323
TIMESTAMP=0
2424
# Note: Renaming files ensures you don't lose previous configurations.
2525
mkdir -p "$SIGNET_DATADIR-$TIMESTAMP"
26-
rsync -r "$SIGNET_DATADIR/bitcoin.conf" "$SIGNET_DATADIR-$TIMESTAMP/" 2>/dev/null
27-
rsync -r "$SIGNET_DATADIR/*" "$SIGNET_DATADIR-$TIMESTAMP/" 2>/dev/null
28-
rsync -r "$SIGNET_DATADIR/signet" "$SIGNET_DATADIR-$TIMESTAMP/signet" 2>/dev/null
26+
rsync -r "$SIGNET_DATADIR-0/bitcoin.conf" "$SIGNET_DATADIR-$TIMESTAMP/" 2>/dev/null
27+
rsync -r "$SIGNET_DATADIR-0/*" "$SIGNET_DATADIR-$TIMESTAMP/" 2>/dev/null
28+
rsync -r "$SIGNET_DATADIR-0/signet" "$SIGNET_DATADIR-$TIMESTAMP/signet" 2>/dev/null
2929
cat "$SIGNET_DATADIR-$TIMESTAMP/bitcoin.conf"
3030

3131
# Cleanup old configuration/data files for a fresh start (Crucial for debugging)
@@ -60,14 +60,30 @@ export weeble
6060

6161
echo "--- Phase 2: Starting Custom Signet and Miner Setup ---"
6262

63+
pids=$(lsof -t -i :$((weeble+1)) )
64+
if [ -n "$pids" ]; then
65+
echo "Found processes on port $((weeble+10)). Killing them now: $pids"
66+
kill -9 $pids
67+
fi
6368

6469
for datadir in $(ls -d signet_data-*);do
65-
pids=$(lsof -t -i :$((weeble+10)) )
70+
pids=$(lsof -t -i :$((weeble+2)) )
6671
if [ -n "$pids" ]; then
6772
echo "Found processes on port $((weeble+10)). Killing them now: $pids"
68-
#kill -9 $pids
73+
kill -9 $pids
6974
fi
70-
./bin/bitcoin-qt -listen=$((weeble -1)) -addnode=127.0.0.1:$weeble -addnode=127.0.0.1:$((weeble + 1)) -addnode=127.0.0.1:38333 -addnode=127.0.0.1:38332 -addnode=127.0.0.1:38334 -port=$((weeble +1 )) -signet -daemon -datadir=$datadir || { echo "Error: Failed to start bitcoind in Signet mode."; exit 1; } & sleep 5
75+
./bin/bitcoin-qt \
76+
-listen=$((weeble -1)) \
77+
-addnode=127.0.0.1:8080 \
78+
-addnode=127.0.0.1:$((weeble-1)) \
79+
-addnode=127.0.0.1:$((weeble-2)) \
80+
-addnode=127.0.0.1:$((weeble)) \
81+
-addnode=127.0.0.1:38332 \
82+
-addnode=127.0.0.1:38333 \
83+
-port=$((weeble +1 )) \
84+
-signet \
85+
-daemon \
86+
-datadir=$datadir || { echo "Error: Failed to start bitcoind in Signet mode."; exit 1; } & sleep 5
7187

7288
weeble=$(( weeble + 1 ))
7389

pr896/miner.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
rsync -r ./signet_data/* ./signet_data-0/
2+
cat ./signet_data-0/bitcoin.conf
3+
./bin/bitcoin-cli --signet -netinfo -rpcpassword=signetpassword -rpcuser=signetuser --datadir=./signet_data-0
4+
./bin/bitcoind --datadir=./signet_data-0 -port=8080 -server & sleep 3;
5+
./bin/bitcoin-cli --signet -netinfo -rpcpassword=signetpassword -rpcuser=signetuser --datadir=./signet_data-0
16
cat ./signet_data/bitcoin.conf
2-
../contrib/signet/miner --cli './bin/bitcoin-cli -datadir=./signet_data' generate --address tb1quj2f4cdeczgsuqcuse0aehc8alp2zyqknfs8zg --grind-cmd './bin/bitcoin-util grind' --min-nbits --ongoing
7+
./bin/bitcoin-cli --signet -netinfo -rpcpassword=signetpassword -rpcuser=signetuser --datadir=./signet_data
8+
count=0
9+
while ((count < 101));do
10+
../contrib/signet/miner --cli './bin/bitcoin-cli -datadir=./signet_data' generate --address tb1quj2f4cdeczgsuqcuse0aehc8alp2zyqknfs8zg --grind-cmd './bin/bitcoin-util grind' --min-nbits #--ongoing
11+
./bin/bitcoin-cli --signet -netinfo -rpcpassword=signetpassword -rpcuser=signetuser --datadir=./signet_data
12+
./bin/bitcoin-cli --signet -netinfo -rpcpassword=signetpassword -rpcuser=signetuser --datadir=./signet_data-0
13+
done
314
exit;

pr896/network.sh

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#!/bin/bash
2+
set -x
3+
#
4+
# Script to set up a custom Signet network, generate a challenge,
5+
# start the daemon, create a wallet, and start a local miner.
6+
#
7+
8+
# --- 1. Setup and Cleanup ---
9+
10+
# Define the data directory path
11+
SIGNET_DATADIR="./signet_data"
12+
export SIGNET_DATADIR
13+
14+
# Ensure the data directory exists
15+
mkdir -p "$SIGNET_DATADIR"
16+
17+
# Define executable paths relative to the current working directory
18+
btcd="./bin/bitcoind -datadir=$SIGNET_DATADIR"
19+
bcli="./bin/bitcoin-cli -datadir=$SIGNET_DATADIR"
20+
miner="../contrib/signet/miner"
21+
grinder="./bin/bitcoin-util grind"
22+
23+
TIMESTAMP=0
24+
# Note: Renaming files ensures you don't lose previous configurations.
25+
mkdir -p "$SIGNET_DATADIR-$TIMESTAMP"
26+
rsync -r "$SIGNET_DATADIR-0/bitcoin.conf" "$SIGNET_DATADIR-$TIMESTAMP/" 2>/dev/null
27+
rsync -r "$SIGNET_DATADIR-0/*" "$SIGNET_DATADIR-$TIMESTAMP/" 2>/dev/null
28+
rsync -r "$SIGNET_DATADIR-0/signet" "$SIGNET_DATADIR-$TIMESTAMP/signet" 2>/dev/null
29+
cat "$SIGNET_DATADIR-$TIMESTAMP/bitcoin.conf"
30+
31+
# Cleanup old configuration/data files for a fresh start (Crucial for debugging)
32+
echo "Archiving old configuration and data files..."
33+
TIMESTAMP=$(date +%s)
34+
# Note: Renaming files ensures you don't lose previous configurations.
35+
mkdir -p "$SIGNET_DATADIR-$TIMESTAMP"
36+
rsync -r "$SIGNET_DATADIR/bitcoin.conf" "$SIGNET_DATADIR-$TIMESTAMP/" 2>/dev/null
37+
rsync -r "$SIGNET_DATADIR/*" "$SIGNET_DATADIR-$TIMESTAMP/" 2>/dev/null
38+
rsync -r "$SIGNET_DATADIR/signet" "$SIGNET_DATADIR-$TIMESTAMP/signet" 2>/dev/null
39+
cat "$SIGNET_DATADIR-$TIMESTAMP/bitcoin.conf"
40+
41+
# --- 4. Phase 2: Signet Execution and Mining Setup ---
42+
43+
44+
# 1. Execute the external tool and capture its output
45+
weeble_raw=$(gnostr-weeble)
46+
47+
# 2. Declare 'weeble' as an integer variable.
48+
# This forces the value to be treated as an integer for math operations.
49+
# It's safer than using 'eval'.
50+
declare -i weeble
51+
52+
# 3. Assign the raw output to the integer variable.
53+
# Bash will attempt to convert the string to an integer during this assignment.
54+
weeble=$weeble_raw
55+
56+
# Optional: Export the variable if needed by subprocesses
57+
export weeble
58+
59+
60+
61+
echo "--- Phase 2: Starting Custom Signet and Miner Setup ---"
62+
63+
pids=$(lsof -t -i :$((weeble+1)) )
64+
if [ -n "$pids" ]; then
65+
echo "Found processes on port $((weeble+10)). Killing them now: $pids"
66+
kill -9 $pids
67+
fi
68+
69+
for datadir in $(ls -d signet_data-*);do
70+
pids=$(lsof -t -i :$((weeble+2)) )
71+
if [ -n "$pids" ]; then
72+
echo "Found processes on port $((weeble+10)). Killing them now: $pids"
73+
kill -9 $pids
74+
fi
75+
./bin/bitcoin-qt \
76+
-listen=$((weeble -1)) \
77+
-addnode=127.0.0.1:8080 \
78+
-addnode=127.0.0.1:$((weeble-1)) \
79+
-addnode=127.0.0.1:$((weeble-2)) \
80+
-addnode=127.0.0.1:$((weeble)) \
81+
-addnode=127.0.0.1:38332 \
82+
-addnode=127.0.0.1:38333 \
83+
-port=$((weeble +1 )) \
84+
-signet \
85+
-daemon \
86+
-datadir=$datadir || { echo "Error: Failed to start bitcoind in Signet mode."; exit 1; } & sleep 5
87+
88+
weeble=$(( weeble + 1 ))
89+
90+
done

pr896/run.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
ln -sf /Users/git/Library/Application\ Support /Users/git/Library/Application_Support
2+
#ls /Users/git/Library/Application_Support/Bitcoin/
3+
ls /Users/git/Library/Application_Support/Signet/
4+
#ls /Users/git/Library/Application_Support/Bitcoin/signet/
5+
#cat /Users/git/Library/Application_Support/Bitcoin/bitcoin.conf
6+
cat /Users/git/Library/Application_Support/Signet/bitcoin.conf
7+
# Bitcoin client
8+
SIGNET_DATADIR="/Users/git/Library/Application_Support/Signet/"
9+
export SIGNET_DATADIR
10+
mkdir -p $SIGNET_DATADIR
11+
btcd="./bin/bitcoind -datadir=$SIGNET_DATADIR"
12+
13+
ls /Users/git/Library/Application_Support/Signet
14+
15+
# Bitcoin CLI
16+
bcli="./bin/bitcoin-cli -datadir=$SIGNET_DATADIR"
17+
18+
# Mining script
19+
miner="../contrib/signet/miner"
20+
21+
# Bitcoin-util, a tool that computes proof of work
22+
grinder="./bin/bitcoin-util grind"
23+
24+
# datadir cleanup, in case we need to start the network from scratch
25+
miner_datadir_cleanup="rm $SIGNET_DATADIR; mkdir $SIGNET_DATADIR"
26+
27+
cat /Users/git/Library/Application_Support/Signet/bitcoin.conf
28+
29+
(\
30+
./bin/bitcoin-qt --datadir="/Users/git/Library/Application_Support/Signet/";
31+
)
32+
33+
MINER_ADDR=$($bcli -named getnewaddress address_type="bech32")
34+
$miner --cli "bcli" generate --address $MINER_ADDR --grind-cmd "grinder" --min-nbits --set-block-time $(date +%s)
35+
$miner --cli "bcli" generate --address $MINER_ADDR --grind-cmd "grinder" --min-nbits --ongoing

pr896/miner2.sh renamed to pr896/setup.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ cat <<EOF > "$SIGNET_DATADIR/bitcoin.conf"
122122
rpcuser=signetuser
123123
rpcpassword=signetpassword
124124
signet=1
125+
server=1
125126
[signet]
126127
rpcport=38332
127128
add-node=8080
0 Bytes
Binary file not shown.

pr896/signet_data/signet/blocks/index/000003.log

Whitespace-only changes.
50 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)