diff --git a/docker/knots/entrypoint.sh b/docker/knots/entrypoint.sh index f422d79..839a34d 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,24 @@ set -e BITCOIN_DATA_DIR=${BITCOIN_DATA_DIR:-/data/.bitcoin} CONFIG_FILE="${BITCOIN_DATA_DIR}/bitcoin.conf" +# Network configuration - validate network setting +NETWORK=${NETWORK:-mainnet} +case "${NETWORK}" in + mainnet) + echo "Starting bitcoind on mainnet" + ;; + testnet) + echo "Starting bitcoind on testnet" + ;; + 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} @@ -70,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}