#!/bin/bash NBITS=${NBITS:-"1e0377ae"} #minimum difficulty in signet WALLET=${WALLET:-"custom_signet"} # Wallet name for descriptor wallet while true; do ADDR=${MINETO:-$(bitcoin-cli -rpcwallet=$WALLET getnewaddress)} if [[ -f "${BITCOIN_DIR}/BLOCKPRODUCTIONDELAY.txt" ]]; then BLOCKPRODUCTIONDELAY_OVERRIDE=$(cat ~/.bitcoin/BLOCKPRODUCTIONDELAY.txt) echo "Delay OVERRIDE before next block" $BLOCKPRODUCTIONDELAY_OVERRIDE "seconds." sleep $BLOCKPRODUCTIONDELAY_OVERRIDE else BLOCKPRODUCTIONDELAY=${BLOCKPRODUCTIONDELAY:="0"} if [[ BLOCKPRODUCTIONDELAY -gt 0 ]]; then echo "Delay before next block" $BLOCKPRODUCTIONDELAY "seconds." sleep $BLOCKPRODUCTIONDELAY fi fi echo "Mine To:" $ADDR # PRIVKEY should be available from .env via run.sh environment # The miner will automatically use PRIVKEY from environment for descriptorprocesspsbt # Export PRIVKEY to ensure it's available to the miner process export PRIVKEY=${PRIVKEY:-$(cat ~/.bitcoin/PRIVKEY.txt 2>/dev/null || echo "")} # Get block template and pipe it to miner # Use bitcoin-cli with -datadir from BITCOIN_DIR (container env) but without -rpcwallet for miner (descriptorprocesspsbt is node RPC, not wallet RPC) bitcoin-cli -rpcwallet=$WALLET getblocktemplate '{"rules": ["segwit", "signet"]}' | \ miner --cli="bitcoin-cli -datadir=${BITCOIN_DIR:-/root/.bitcoin}" generate --grind-cmd="bitcoin-util grind" --address=$ADDR --nbits=$NBITS --set-block-time=$(date +%s) done