From 7b0cc597b4fed3c46a838381eae3604ad9f1bd56 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 31 Jul 2025 18:39:46 +0000 Subject: [PATCH 1/3] Initial plan From 2e10643bdd102193bf4d159784eccc07aeb68c64 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 31 Jul 2025 18:44:32 +0000 Subject: [PATCH 2/3] Add Bitcoin network configuration support via NETWORK environment variable Co-authored-by: esomore <7858567+esomore@users.noreply.github.com> --- docker/knots/entrypoint.sh | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/docker/knots/entrypoint.sh b/docker/knots/entrypoint.sh index f422d79..8202a9b 100644 --- a/docker/knots/entrypoint.sh +++ b/docker/knots/entrypoint.sh @@ -2,6 +2,10 @@ # This script acts as an entrypoint for the bitcoind container. # It retrieves RPC credentials and other configurations from environment # variables, generates a bitcoin.conf file, and then starts bitcoind. +# +# Network Configuration: +# - Set NETWORK environment variable to: mainnet (default), testnet, or regtest +# - Invalid network values will cause the script to exit with an error set -e @@ -9,6 +13,27 @@ set -e BITCOIN_DATA_DIR=${BITCOIN_DATA_DIR:-/data/.bitcoin} CONFIG_FILE="${BITCOIN_DATA_DIR}/bitcoin.conf" +# Network configuration - validate and set network flag +NETWORK=${NETWORK:-mainnet} +case "${NETWORK}" in + mainnet) + NETWORK_FLAG="" + echo "Starting bitcoind on mainnet" + ;; + testnet) + NETWORK_FLAG="-testnet" + echo "Starting bitcoind on testnet" + ;; + regtest) + NETWORK_FLAG="-regtest" + echo "Starting bitcoind on regtest" + ;; + *) + echo "Error: Invalid NETWORK value '${NETWORK}'. Must be one of: mainnet, testnet, regtest" + exit 1 + ;; +esac + # Use provided RPC user/password or fallback to defaults RPC_USER=${RPC_USER:-rpcuser} RPC_PASSWORD=${RPC_PASSWORD:-rpcpassword} @@ -142,5 +167,5 @@ chmod +x "${BITCOIN_DATA_DIR}/blocknotify.sh" echo "blocknotify=${BITCOIN_DATA_DIR}/blocknotify.sh" >> "${CONFIG_FILE}" echo "Starting bitcoind..." -# Pass any additional command-line arguments ("$@") -exec /usr/local/bin/bitcoind -conf="${CONFIG_FILE}" "$@" \ No newline at end of file +# Pass any additional command-line arguments ("$@") and network flag +exec /usr/local/bin/bitcoind -conf="${CONFIG_FILE}" ${NETWORK_FLAG} "$@" \ No newline at end of file From 65e0b4d41d3d0a109fda0b1b89d1493be6f80668 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 31 Jul 2025 18:54:19 +0000 Subject: [PATCH 3/3] Move network configuration from command line flags to bitcoin.conf file Co-authored-by: esomore <7858567+esomore@users.noreply.github.com> --- docker/knots/entrypoint.sh | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/docker/knots/entrypoint.sh b/docker/knots/entrypoint.sh index 8202a9b..839a34d 100644 --- a/docker/knots/entrypoint.sh +++ b/docker/knots/entrypoint.sh @@ -13,19 +13,16 @@ set -e BITCOIN_DATA_DIR=${BITCOIN_DATA_DIR:-/data/.bitcoin} CONFIG_FILE="${BITCOIN_DATA_DIR}/bitcoin.conf" -# Network configuration - validate and set network flag +# Network configuration - validate network setting NETWORK=${NETWORK:-mainnet} case "${NETWORK}" in mainnet) - NETWORK_FLAG="" echo "Starting bitcoind on mainnet" ;; testnet) - NETWORK_FLAG="-testnet" echo "Starting bitcoind on testnet" ;; regtest) - NETWORK_FLAG="-regtest" echo "Starting bitcoind on regtest" ;; *) @@ -95,6 +92,24 @@ cat << EOF > "$CONFIG_FILE" # Bitcoin Core Configuration File # Generated by entrypoint.sh +# ======== Network Configuration ======== +EOF + +# Add network-specific configuration +case "${NETWORK}" in + testnet) + echo "testnet=1" >> "$CONFIG_FILE" + ;; + regtest) + echo "regtest=1" >> "$CONFIG_FILE" + ;; + mainnet) + # No additional configuration needed for mainnet (default) + ;; +esac + +cat << EOF >> "$CONFIG_FILE" + # ======== Core Settings ======== server=${SERVER_ENABLED} txindex=${TXINDEX_ENABLED} @@ -167,5 +182,5 @@ chmod +x "${BITCOIN_DATA_DIR}/blocknotify.sh" echo "blocknotify=${BITCOIN_DATA_DIR}/blocknotify.sh" >> "${CONFIG_FILE}" echo "Starting bitcoind..." -# Pass any additional command-line arguments ("$@") and network flag -exec /usr/local/bin/bitcoind -conf="${CONFIG_FILE}" ${NETWORK_FLAG} "$@" \ No newline at end of file +# Pass any additional command-line arguments ("$@") +exec /usr/local/bin/bitcoind -conf="${CONFIG_FILE}" "$@" \ No newline at end of file