The Commitment Transaction
The operator gathers many users into one onchain transaction, the commitment transaction, which every participant signs. Within it, outputs are swapped atomically in three flows:- Boarding (onchain to virtual): onchain outputs become virtual outputs.
- Renewal (virtual to virtual): existing virtual outputs are swapped for fresh, settled ones. This is a batch swap.
- Offboarding (virtual to onchain): virtual outputs become onchain outputs, with the operator cosigning.
Batch Swaps
A batch swap moves preconfirmed virtual outputs to Bitcoin finality, and there are three reasons to settle:- Trust. Preconfirmed outputs rely on the operator. Settled outputs do not.
- Exit cost. Long transaction chains make unilateral exit more expensive. Settlement resets the chain.
- Expiry. A batch swap gives virtual outputs a new expiry, and the SDK runs one automatically before their batch expires.
How Batch Swaps Work
Register
Each user submits a batch registration request that lists the virtual outputs to swap and the scripts and amounts of the new ones. The request also carries the user’s cosigner keys for the new batch’s transaction tree.
Build the commitment transaction
Next, the operator builds the commitment transaction, with a batch output for all participants’ new virtual outputs and a connector output that makes the swap atomic.
Sign the virtual transaction tree
The operator builds the tree of virtual transactions that splits the batch output into each participant’s virtual output. Using MuSig2, the participants and the operator then check the tree and sign it together.
Sign forfeit transactions
Each user signs a forfeit transaction for each old virtual output. Because it spends both the old virtual output and a connector output, the operator can claim the old output only if the new commitment transaction confirms.
Batch Anatomy
Depending on the batch, a commitment transaction can have these outputs:- Batch output. Holds all participants’ new virtual outputs in a virtual transaction tree.
- Connector output. An output of the operator, present when users give up virtual outputs. It splits into a tree of dust-amount connectors, one for each virtual output that needs a forfeit transaction.
- Onchain outputs for offboarding, and the operator’s change.