reworked docker to use lncm images
This commit is contained in:
parent
c20a8643b3
commit
2d5f75e6a0
40
Dockerfile
40
Dockerfile
@ -1,24 +1,4 @@
|
|||||||
# Build stage for Bitcoin Core
|
# Use a base image with the necessary runtime dependencies
|
||||||
FROM ubuntu as builder
|
|
||||||
|
|
||||||
# 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 git
|
|
||||||
|
|
||||||
# Clone and build Bitcoin Core
|
|
||||||
RUN git clone https://github.com/bitcoin/bitcoin.git
|
|
||||||
|
|
||||||
# Build Bitcoin core
|
|
||||||
WORKDIR /bitcoin
|
|
||||||
RUN ./autogen.sh
|
|
||||||
RUN ./configure
|
|
||||||
RUN make
|
|
||||||
|
|
||||||
# Application stage
|
|
||||||
FROM ubuntu
|
FROM ubuntu
|
||||||
|
|
||||||
# Install runtime dependencies
|
# Install runtime dependencies
|
||||||
@ -26,13 +6,7 @@ RUN apt-get update && apt-get install -y \
|
|||||||
python3 libssl-dev libevent-dev libboost-system-dev libboost-filesystem-dev \
|
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
|
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 and prepare script for signet configurations
|
||||||
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
|
COPY generate_signet.sh /usr/local/bin
|
||||||
RUN chmod +x /usr/local/bin/generate_signet.sh
|
RUN chmod +x /usr/local/bin/generate_signet.sh
|
||||||
|
|
||||||
@ -41,13 +15,15 @@ COPY bitcoin.conf /root/.bitcoin/bitcoin.conf
|
|||||||
|
|
||||||
# Copy the logtail.sh script
|
# Copy the logtail.sh script
|
||||||
COPY logtail.sh /usr/local/bin/
|
COPY logtail.sh /usr/local/bin/
|
||||||
RUN chmod +x usr/local/bin/logtail.sh
|
RUN chmod +x /usr/local/bin/logtail.sh
|
||||||
|
|
||||||
# Copy the .bashrc file to the container's root directory
|
# Copy the .bashrc file to the container's root directory
|
||||||
COPY .bashrc /root/.bashrc
|
COPY .bashrc /root/.bashrc
|
||||||
|
|
||||||
# Expose necessary ports
|
# Expose necessary ports (update these if needed)
|
||||||
EXPOSE 38333 38332
|
EXPOSE 18443
|
||||||
|
# EXPOSE 38333
|
||||||
|
|
||||||
# Start Bitcoin Core
|
# Start Bitcoin Core
|
||||||
CMD ["usr/local/bin/generate_signet.sh"]
|
CMD ["/usr/local/bin/generate_signet.sh"]
|
||||||
|
|
||||||
|
|||||||
@ -4,7 +4,7 @@ daemon=1
|
|||||||
|
|
||||||
# Custom Signet challenge
|
# Custom Signet challenge
|
||||||
# This is generated by running the signet challenge script.
|
# This is generated by running the signet challenge script.
|
||||||
signetchallenge=512102a353dc1b52018dce23d364bb007608a2849caef3f11fe655c9c5d439656d669851ae
|
#signetchallenge=512102a353dc1b52018dce23d364bb007608a2849caef3f11fe655c9c5d439656d669851ae
|
||||||
|
|
||||||
|
|
||||||
#rpcauth=would be provided when needed
|
#rpcauth=would be provided when needed
|
||||||
@ -17,13 +17,13 @@ maxtxfee=1.0
|
|||||||
mintxfee=0.00000001
|
mintxfee=0.00000001
|
||||||
minrelaytxfee=0.00000001
|
minrelaytxfee=0.00000001
|
||||||
|
|
||||||
rpcbind=0.0.0.0:38332
|
rpcbind=0.0.0.0:18443
|
||||||
rpcallowip=0.0.0.0/0
|
rpcallowip=0.0.0.0/0
|
||||||
whitelist=0.0.0.0/0
|
whitelist=0.0.0.0/0
|
||||||
|
|
||||||
# Basic Network
|
# Basic Network
|
||||||
listen=1
|
listen=1
|
||||||
bind=127.0.0.1
|
bind=0.0.0.0
|
||||||
|
|
||||||
# ZeroMQ notification settings
|
# ZeroMQ notification settings
|
||||||
zmqpubrawblock=tcp://0.0.0.0:28332
|
zmqpubrawblock=tcp://0.0.0.0:28332
|
||||||
|
|||||||
29
docker-compose.yml
Normal file
29
docker-compose.yml
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
version: '3'
|
||||||
|
|
||||||
|
services:
|
||||||
|
bitcoind:
|
||||||
|
image: lncm/bitcoind:v26.0
|
||||||
|
container_name: easepay-bitcoind
|
||||||
|
command: -conf=/bitcoin/.bitcoin/bitcoin.conf
|
||||||
|
volumes:
|
||||||
|
- ./bitcoin.conf:/bitcoin/.bitcoin/bitcoin.conf
|
||||||
|
- bitcoind-data:/bitcoin/.bitcoin
|
||||||
|
ports:
|
||||||
|
- "18443:18443" # RPC port
|
||||||
|
- "48333:38333" # P2P port for Signet
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
|
fulcrum:
|
||||||
|
image: cculianu/fulcrum:latest # Replace with the desired Fulcrum version
|
||||||
|
container_name: easepay-fulcrum
|
||||||
|
volumes:
|
||||||
|
- fulcrum-data:/data
|
||||||
|
ports:
|
||||||
|
- "50002:50002" # Electrum server port
|
||||||
|
restart: unless-stopped
|
||||||
|
depends_on:
|
||||||
|
- bitcoind
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
bitcoind-data:
|
||||||
|
fulcrum-data:
|
||||||
@ -1,105 +1,25 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# Start Bitcoind in Signet mode
|
# Define container name = should match name in docker-compose
|
||||||
/usr/local/bin/bitcoind -signet -daemon
|
BICOIND_CONTAINER_NAME="easepay-bitcoind"
|
||||||
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"
|
|
||||||
|
|
||||||
# check if custom_signet_wallet exist, create it if not
|
# Start Bitcoind in Regtest mode
|
||||||
if ! /usr/local/bin/bitcoin-cli -signet listwallets | grep -q "custom_signet_wallet"; then
|
docker exec -it $BITCOIND_CONTAINER_NAME bitcoind -regtest -daemon
|
||||||
echo "Creating wallet: custom_signet_wallet"
|
|
||||||
/usr/local/bin/bitcoin-cli -signet createwallet "custom_signet_wallet"
|
|
||||||
else
|
|
||||||
echo "Wallet custom_signet-wallet already exists"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Generate mew address and keys
|
# Wait for Bitcoind to start running
|
||||||
ADDR=$(/usr/local/bin/bitcoin-cli -signet -rpcwallet="custom_signet_wallet" getnewaddress '' bech32)
|
sleep 5
|
||||||
if [ -z "$ADDR" ]; then
|
|
||||||
echo "Failed to get new address"
|
|
||||||
fi
|
|
||||||
|
|
||||||
PRIVKEY=$(/usr/local/bin/bitcoin-cli -signet -rpcwallet="custom_signet_wallet" dumpprivkey $ADDR)
|
# Generate a new address and get the private key and public key
|
||||||
PUBKEY=$(/usr/local/bin/bitcoin-cli -signet -rpcwallet="custom_signet_wallet" getaddressinfo $ADDR | jq -r .pubkey)
|
ADDR=$(docker exec $BITCOIND_CONTAINER bitcoin-cli -regtest getnewaddress)
|
||||||
|
PRIVKEY=$(docker exec $BITCOIND_CONTAINER bitcoin-cli -regtest dumpprivkey $ADDR)
|
||||||
|
PUBKEY=$(docker exec $BITCOIND_CONTAINER bitcoin-cli -regtest getaddressinfo $ADDR | jq -r '.pubkey')
|
||||||
|
|
||||||
# Calculate script length and keys
|
# Echo the generated values
|
||||||
LENX2=$(printf $PUBKEY | wc -c)
|
echo "Address: $ADDR"
|
||||||
LEN=$((LENX2/2))
|
echo "Private Key: $PRIVKEY"
|
||||||
LENHEX=$(printf '%x\n' $LEN)
|
echo "Public Key: $PUBKEY"
|
||||||
SCRIPT="51${LENHEX}${PUBKEY}51ae"
|
|
||||||
|
|
||||||
# Output the generated values
|
# Optionally, stop the regtest node
|
||||||
cat <<EOF
|
# docker exec $BITCOIND_CONTAINER bitcoin-cli -regtest stop
|
||||||
ADDR=$ADDR
|
|
||||||
PRIVKEY=$PRIVKEY
|
|
||||||
PUBKEY=$PUBKEY
|
|
||||||
SCRIPT=$SCRIPT
|
|
||||||
EOF
|
|
||||||
|
|
||||||
# Create a new directory for the custom signet
|
|
||||||
datadir=/root/signet-custom
|
|
||||||
mkdir $datadir
|
|
||||||
|
|
||||||
# Write the custom signet configuration
|
|
||||||
cat > $datadir/bitcoin.conf <<EOF
|
|
||||||
signet=1
|
|
||||||
[signet]
|
|
||||||
daemon=1
|
|
||||||
signetchallenge=$SCRIPT
|
|
||||||
EOF
|
|
||||||
|
|
||||||
# Start bitcoind with the custom signet configuration
|
|
||||||
/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 ! /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
|
|
||||||
/usr/local/bin/bitcoin-cli -datadir=$datadir importprivkey "$PRIVKEY"
|
|
||||||
|
|
||||||
# Generate a new address for mining
|
|
||||||
NADDR=$(/usr/local/bin/bitcoin-cli -datadir=$datadir getnewaddress)
|
|
||||||
|
|
||||||
# Examples from
|
|
||||||
# https://github.com/bitcoin/bitcoin/pull/19937#issuecomment-696419619
|
|
||||||
|
|
||||||
|
|
||||||
# Define neccessary commands and paths
|
|
||||||
MINER="../contrib/signet/miner"
|
|
||||||
GRIND="./bitcoin-util grind"
|
|
||||||
CLI="./bitcoin-cli -datadir=$datadir"
|
|
||||||
|
|
||||||
# Calibrate to find a suitable nbits value (Note: it is possible to adjust this as you see fit)
|
|
||||||
NBITS=$($MINER calibrate --grind-cmd="$GRIND" --seconds=160)
|
|
||||||
|
|
||||||
# Generate an address for receiving mining rewards
|
|
||||||
ADDR=$($CLI -signet getnewaddress)
|
|
||||||
|
|
||||||
# Advanced Block Generation Process
|
|
||||||
# Generate and create a block template. This generates a PSBT, processes it, and submits the block to the Signet network
|
|
||||||
$CLI -signet getblocktemplate '{"rules": ["signet","segwit"]}' \
|
|
||||||
| $MINER --cli="$CLI" genpsbt --address="$ADDR" \
|
|
||||||
| $CLI -signet -stdin walletprocesspsbt \
|
|
||||||
| jq -r .psbt \
|
|
||||||
| $MINER --cli="$CLI" solvepsbt --grind-cmd="$GRIND" \
|
|
||||||
| $CLI -signet -stdin submitblock
|
|
||||||
|
|
||||||
|
|
||||||
# Optional for continues mining
|
|
||||||
# $MINER --cli="$CLI" generate --grind-cmd="$GRIND" --address="$ADDR" --nbits=$NBITS --ongoing
|
|
||||||
|
|
||||||
# Stop the custom Signet node
|
|
||||||
./bitcoin-cli -datadir=$datadir stop
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# -wallet="custom_signet_wallet" #Wallet name must match the name we have in signet_challenge script
|
|
||||||
Loading…
x
Reference in New Issue
Block a user