Repository navigation
Add tools/liquid.py, to spend a verifier on Liquid, Liquid testnet or regtest - #27
Merged
Merged
Conversation
… regtest A developer tool around deploy: address, faucet (Liquid testnet), utxos, sighash, spend, prove, keyspend and broadcast. It reads the chain through an Esplora server (Blockstream's by default) or a node (--node "elements-cli ..."), and needs only the Python standard library and the harness. The proof binds the fee, so the fee is fixed before proving: in two steps (sighash, then spend with the witness) for any prover, or with `prove`, which runs the prover itself and proves again if the measured size needs a higher fee. The output must pay the verifier, be explicit and hold L-BTC; every fee must meet the minimum relay fee; nothing is sent without --broadcast, and with a node testmempoolaccept checks the transaction first. tests/test_liquid.py checks it with the chain and deploy faked (in make test and CI). It was also run on an Elements regtest node through --node, and each toy verifier was spent on Liquid testnet with `prove` (docs/benchmarks.md links the transactions). The README gets a section on both networks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Until now a verifier's output could be spent only by hand with
deploy, or by the toy-circuit scripttools/regtest.shon a regtest node.tools/liquid.pyis a developer tool for spending any verifierdeploy compileproduced, on Liquid, Liquid testnet or a regtest node. It reads the chain through an Esplora server (Blockstream's by default) or your own node (--node "elements-cli ..."), builds every transaction withdeploy, and needs only the Python standard library.Commands
address PROGRAMfaucet ADDRESSutxos PROGRAMsighash PROGRAM TXID:VOUT DEST (--fee | --vsize)spend PROGRAM WITNESS TXID:VOUT DEST (--fee | --vsize)prove PROGRAM TXID:VOUT DEST --prove CMD --witness FILE{sighash}), builds, and proves again if the fee must risekeyspend PROGRAM TXID:VOUT DEST --secret-file Fbroadcast TX.hexEvery command takes
--network liquid|liquidtestnet|elementsregtest.--broadcastsends; without it, nothing is sent.How the fee works
The proof binds the spending transaction, fee included, so the fee has to be known before proving. There are two ways to give it:
sighashprints the sighash for a fee; the prover runs;spendbuilds the transaction from the witness file.prove. It runs the prover itself, measures the transaction, and proves again if the size needs a higher fee.The fee is
--feein satoshis, or--fee-rate(default 0.1 sat/vB, Liquid's minimum relay feerate) times the size plus 10 vB of slack. The size is--vsizefrom an earlier spend, or the sizeprovemeasures.What it refuses
{sighash}, or writes no witness file;--node: a node on another chain than--network, and a transaction thattestmempoolacceptrefuses (the tool runs it first).Before it sends anything,
deployexecutes the transaction and refuses it if the cost exceeds the budget, if it needs more Bit Machine cells than consensus allows, or if it is above the standard weight.Verification
tests/test_liquid.py(added tomake testand the CI matrix) fakes the chain anddeploy. It covers:proveloop: it proves again only while the fee must rise, including when each proof is a few WU larger;It passes on Python 3.10, 3.13 and 3.14.
Elements 23.3.1 regtest, through
--node:prove --broadcastfor the Noir verifier (67.8 kWU, whose hex is too long for a command-line argument) and for Groth16;sighash/spendpath;broadcastandkeyspend.All were accepted and mined.
Liquid testnet.
faucetfunded each toy verifier's address, andprove --broadcastspent it, paying the faucet's return address:e2ef29c6…, 53,314 WU, fee 1,334 sat6224147f…, 67,812 WU, fee 1,697 satdc5b3334…, 126,577 WU, fee 3,166 sat5a64e6be…, 185,285 WU, fee 4,634 sataddressandutxoswere run against Blockstream's Liquid API.deploy's built-in genesis hashes match both chains' block 0.prove --feeandkeyspend;utxos;deploy's notes hidden;Docs
README. A section "On Liquid testnet and Liquid":
The support table gets a "spent on" row.
docs/benchmarks.md. The testnet spends above, beside the regtest ones.
docs/fflonk.md and docs/noir.md. Pointers to the tool.
🤖 Generated with Claude Code