Feat:create a new script to generate signet challenge
This commit is contained in:
parent
18333d9140
commit
8fda01b586
46
Dockerfile
46
Dockerfile
@ -1,43 +1,53 @@
|
||||
FROM ubuntu:20.04
|
||||
# Build stage for Bitcoin Core
|
||||
FROM ubuntu as builder
|
||||
|
||||
# Install dependencies
|
||||
# Install build dependencies
|
||||
RUN apt-get update && apt-get install -y \
|
||||
build-essential libtool autotools-dev automake \
|
||||
pkg-config bsdmainutils python3 libssl-dev \
|
||||
libevent-dev libboost-system-dev libboost-filesystem-dev \
|
||||
libboost-chrono-dev libboost-test-dev libboost-thread-dev \
|
||||
libdb-dev libdb++-dev python3-pip jq
|
||||
libdb-dev libdb++-dev python3-pip jq git
|
||||
|
||||
# Clone Bitcoin Core
|
||||
RUN apt-get install -y git
|
||||
RUN git clone https://github.com/bitcoin/bitcoin.git
|
||||
# Clone and build Bitcoin Core
|
||||
RUN git clone --depth 1 https://github.com/bitcoin/bitcoin.git
|
||||
|
||||
# Build Bitcoin Core
|
||||
# Build Bitcoin core
|
||||
WORKDIR /bitcoin
|
||||
RUN ./autogen.sh
|
||||
RUN ./configure
|
||||
RUN make
|
||||
|
||||
# Copy, Prepare Signet configuration and run signet script
|
||||
COPY generate_signet.sh .
|
||||
RUN chmod +x generate_signet.sh
|
||||
# Application stage
|
||||
FROM ubuntu
|
||||
|
||||
# Install runtime dependencies
|
||||
RUN apt-get update && apt-get install -y \
|
||||
python3 libssl-dev libevent-dev libboost-system-dev libboost-filesystem-dev \
|
||||
libboost-chrono-dev libboost-test-dev libboost-thread-dev libdb-dev libdb++-dev python3-pip jq
|
||||
|
||||
# Copy Binaries and scripts from the builder stage
|
||||
COPY --from=builder /bitcoin/src/bitcoind /usr/local/bin/
|
||||
COPY --from=builder /bitcoin/src/bitcoin-cli /usr/local/bin/
|
||||
COPY --from=builder /bitcoin/contrib/signet/miner /usr/local/bin/
|
||||
RUN chmod +x /usr/local/bin/miner
|
||||
|
||||
# Copy and prepare sript for signet configurations
|
||||
COPY generate_signet.sh /usr/local/bin
|
||||
RUN chmod +x /usr/local/bin/generate_signet.sh
|
||||
|
||||
# Copy Bitcoin.conf file
|
||||
COPY bitcoin.conf /root/.bitcoin/bitcoin.conf
|
||||
|
||||
# Copy the generate.py script from the Bitcoin core source
|
||||
COPY --from=0 /bitcoin/contrib/signet/miner.py /usr/local/bin/
|
||||
RUN chmod +x /usr/local/bin/miner.py
|
||||
# Copy the logtail.sh script
|
||||
COPY logtail.sh /usr/local/bin/
|
||||
RUN chmod +x usr/local/bin/logtail.sh
|
||||
|
||||
# Copy the .bashrc file to the container's root directory
|
||||
COPY .bashrc /root/.bashrc
|
||||
|
||||
# Copy the logtail.sh script
|
||||
COPY logtail.sh .
|
||||
RUN chmod +x logtail.sh
|
||||
|
||||
# Expose necessary ports
|
||||
EXPOSE 38333 38332
|
||||
|
||||
# Start Bitcoin Core
|
||||
CMD ["./generate_signet.sh"]
|
||||
CMD ["usr/local/bin/generate_signet.sh"]
|
||||
|
||||
@ -3,8 +3,8 @@ signet=1
|
||||
daemon=1
|
||||
|
||||
# Custom Signet challenge
|
||||
# we would add our custom signet parameters here(currently generic parameters are used)
|
||||
signetchallenge=5121<PUBKEY>51ae
|
||||
# This was generated by running the signet challenge script.
|
||||
signetchallenge= 512102a353dc1b52018dce23d364bb007608a2849caef3f11fe655c9c5d439656d669851ae
|
||||
|
||||
|
||||
#rpcauth=would be provided when needed
|
||||
|
||||
28
generate_signet.sh
Normal file → Executable file
28
generate_signet.sh
Normal file → Executable file
@ -1,18 +1,18 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Start Bitcoind in regtest mode
|
||||
./src/bitcoind -regtest -daemon -wallet="test" #change wallet name
|
||||
echo "wating for regtest bitcoind to start..."
|
||||
while ! ./src/bitcoin-cli -regtest getconnectioncount 2>/dev/null 1>&2; do
|
||||
# Start Bitcoind in Signet mode
|
||||
/usr/local/bin/bitcoind -signet -daemon -wallet="test" #change wallet name
|
||||
echo "wating for signet bitcoind to start..."
|
||||
while ! /usr/local/bin/bitcoin-cli -signet getconnectioncount 2>/dev/null 1>&2; do
|
||||
echo -n ".";
|
||||
sleep 1;
|
||||
done
|
||||
echo "started"
|
||||
|
||||
# Generate mew address and keys
|
||||
ADDR=$(./src/bitcoin-cli -regtest getnewaddress '' bech32)
|
||||
PRIVKEY=$(./src/bitcoin-cli -regtest dumpprivkey $ADDR)
|
||||
PUBKEY=$(./src/bitcoin-cli -regtest getaddressinfo $ADDR | jq -r .scriptPubKey)
|
||||
ADDR=$(/usr/local/bin/bitcoin-cli -signet getnewaddress '' bech32)
|
||||
PRIVKEY=$(/usr/local/bin/bitcoin-cli -signet dumpprivkey $ADDR)
|
||||
PUBKEY=$(/usr/local/bin/bitcoin-cli -signet getaddressinfo $ADDR | jq -r .pubKey)
|
||||
|
||||
# Calculate script length and keys
|
||||
LENX2=$(printf $PUBKEY | wc -c)
|
||||
@ -28,9 +28,6 @@ PUBKEY=$PUBKEY
|
||||
SCRIPT=$SCRIPT
|
||||
EOF
|
||||
|
||||
# Stop the regtest node
|
||||
./src/bitcoin-cli -regtest stop
|
||||
|
||||
# Create a new directory for the custom signet
|
||||
datadir=/root/signet-custom
|
||||
mkdir $datadir
|
||||
@ -44,29 +41,26 @@ signetchallenge=$SCRIPT
|
||||
EOF
|
||||
|
||||
# Start bitcoind with the custom signet configuration
|
||||
./src/bitcoind -datadir=$datadir -wallet="test"
|
||||
/usr/local/bin/bitcoind -datadir=$datadir -signet -wallet="test"
|
||||
|
||||
# Wait for the custom signet to start
|
||||
echo "Waiting for custom Signet bitcoind to start"
|
||||
while ! ./src/bitcoin-cli -datadir=$datadir getconnectioncount 2>/dev/null 1>&2; do
|
||||
while ! /usr/local/bin/bitcoin-cli -datadir=$datadir getconnectioncount 2>/dev/null 1>&2; do
|
||||
echo -n ".";
|
||||
sleep 1;
|
||||
done
|
||||
echo "Started"
|
||||
|
||||
# Import the private key to the custom signet node
|
||||
./src/bitcoin-cli -datadir=$datadir importprivkey "$PRIVKEY"
|
||||
/usr/local/bin/bitcoin-cli -datadir=$datadir importprivkey "$PRIVKEY"
|
||||
|
||||
# Generate a new address for mining
|
||||
NADDR=$(./src/bitcoin-cli -datadir=$datadir getnewaddress)
|
||||
NADDR=$(/usr/local/bin/bitcoin-cli -datadir=$datadir getnewaddress)
|
||||
|
||||
# Examples from
|
||||
# https://github.com/bitcoin/bitcoin/pull/19937#issuecomment-696419619
|
||||
|
||||
|
||||
# Navigate to the src directory(this assume that Docker workdir is set to the root)
|
||||
cd src/
|
||||
|
||||
# Define neccessary commands and paths
|
||||
MINER="../contrib/signet/miner"
|
||||
GRIND="./bitcoin-util grind"
|
||||
|
||||
15
signet_challenge.sh
Executable file
15
signet_challenge.sh
Executable file
@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Create a new wallet
|
||||
WALLET_NAME="custom_signet_wallet"
|
||||
bitcoin-cli -signet createwallet "$WALLET_NAME"
|
||||
|
||||
# Generate a new address and retrieve the public key
|
||||
ADDRESS=$(bitcoin-cli -signet -rpcwallet="$WALLET_NAME" getnewaddress)
|
||||
PUBKEY=$(bitcoin-cli -signet -rpcwallet="$WALLET_NAME" getaddressinfo "$ADDRESS" | jq -r .pubkey)
|
||||
|
||||
# Construct the signetchallenge script
|
||||
SIGNETCHALLENGE="5121${PUBKEY}51ae"
|
||||
|
||||
# Output the signetchallenge
|
||||
echo "signetchallenge: $SIGNETCHALLENGE"
|
||||
Loading…
x
Reference in New Issue
Block a user