Skip to content

Instantly share code, notes, and snippets.

@posix4e
Created September 6, 2026 20:29
Show Gist options
  • Select an option

  • Save posix4e/08b802167a67a464e1a4fe90a49a23e2 to your computer and use it in GitHub Desktop.

Select an option

Save posix4e/08b802167a67a464e1a4fe90a49a23e2 to your computer and use it in GitHub Desktop.
How to use scripts/signet-miner (BIP325 miner for the winnow dev signet)

Using scripts/signet-miner

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.

Prerequisites

  • Bitcoin Core 31.x (bitcoind, bitcoin-cli, bitcoin-util — the grind step shells out to bitcoin-util)

  • Python 3 with the ecdsa package (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

Mine blocks

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 the getaddressinfo lookup of the payout address; defaults to federation. 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 (default 38400)

Worked example: fund a wallet and move coins

# 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())".)

Notes

  • 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.
  • submitblock answering inconclusive means your block was valid but lost a race to become tip — just mine again.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment