A shell-runnable BIP325 miner for the winnow dev signet. Core 31.1's
generatetoaddress builds blocks but won't sign them for a custom signet, so
confirming anything on the fixture chain means running the whole cycle
yourself: getblocktemplate → coinbase with witness + signet commitments →
BIP325 block signature → PoW grind via bitcoin-util → submitblock. The
script does that, one block at a time. It is a port of
Tests/DifferentialTests/SignetMiner.swift, which only runs inside the test
harness.
-
Bitcoin Core 31.x (
bitcoind,bitcoin-cli,bitcoin-util— the grind step shells out tobitcoin-util) -
Python 3 with the
ecdsapackage (pure Python; one signature per block, so speed doesn't matter):python3 -m venv .venv ./.venv/bin/pip install ecdsa
-
The dev fixture running:
scripts/signet-fixture up
ADDR=$(bitcoin-cli -datadir=~/.bitcoin-mysignet -rpcport=38400 \
-rpcwallet=<wallet> getnewaddress)
./.venv/bin/python scripts/signet-miner "$ADDR" <nblocks> [wallet]<payout-address>receives the subsidy + fees for every block mined.[wallet]is only used for thegetaddressinfolookup of the payout address; defaults tofederation. Pass it whenever more than one wallet is loaded.- Prints one
mined i/n: <blockhash>line per block.
Environment overrides, same as signet-fixture:
WINNOW_DATADIR(default~/.bitcoin-mysignet)WINNOW_RPC_PORT(default38400)
# Fresh wallet, mine 201 blocks to it (~2 min on a laptop).
bitcoin-cli -datadir=~/.bitcoin-mysignet -rpcport=38400 \
-named createwallet wallet_name=demo
ADDR=$(bitcoin-cli -datadir=~/.bitcoin-mysignet -rpcport=38400 \
-rpcwallet=demo getnewaddress)
./.venv/bin/python scripts/signet-miner "$ADDR" 201 demo
# Coinbase needs 100 confirmations, so 101 of those coinbases are now
# spendable (~5,050 tBTC).
bitcoin-cli -datadir=~/.bitcoin-mysignet -rpcport=38400 \
-rpcwallet=demo getbalance
# Send with an OP_RETURN attached, then confirm it with one more block.
bitcoin-cli -datadir=~/.bitcoin-mysignet -rpcport=38400 -rpcwallet=demo \
-named send outputs='[{"<dest-address>": 4000}, {"data": "57652061726520776869746568617473"}]'
./.venv/bin/python scripts/signet-miner "$ADDR" 1 demo(57652061726520776869746568617473 is "We are whitehats" — replace with
your own message, python3 -c "print('...'.encode().hex())".)
- The challenge key is a published dev constant from
scripts/signet-fixture; the chain is isolated (dnsseed=0, no peers) and holds nothing of value. Never reuse the key anywhere else. - Block timestamps are pinned to
max(curtime, prevtime + 1), so mining hundreds of blocks back-to-back stays inside consensus rules. submitblockansweringinconclusivemeans your block was valid but lost a race to become tip — just mine again.