Hello everyone,
I want to share an idea for a new Tapscript opcode that makes consolidation transactions significantly more space-efficient: OP_CHECKCONSOLIDATION (OP_CC).
It’s a simple introspection opcode: OP_CC pushes false for the first transaction input spending a particular scriptPubKey, and true for every subsequent input spending the same scriptPubKey. This enables a construction where all inputs spending the same SPK rely on the signature for the first input with that SPK.
A simple example:
- We create a Taproot SPK (“address”) with a known key-path and a single Tapscript leaf of just OP_CC.
- Now assume we have three UTXOs with that SPK and we want to spend all of them in the same transaction.
- The first UTXO is unlocked with a simple key-path spend. It’s crucial that the signature commits to all inputs and outputs (SIGHASH_ALL).
- The second and third UTXOs are unlocked with the OP_CC script-path spends. No signatures are required.
We save 58 witness bytes compared to spending all three UTXOs via key-path spends:
- Key-path witness size (per input): signature length (1), signature (64) → 65 bytes
- Script-path witness size (per input): script length (1), script (1), control block length (1), control block (33) → 36 bytes
And that’s just a simple example. The savings are much greater for n<m multisigs, and greater still in a post-quantum world with much larger signatures.
I made a draft implementation to explain the idea using code and unit tests.
I’ll post to the ML as well after collecting some initial feedback here on Delving.
Looking forward to your feedback.