UTXO Support
Motivations
With UTXO support, it is possible to attach / detach Counterparty assets directly to / from Bitcoin UTXOs, so that they can be spent just like Colored Coins–based protocols (such as Ordinals and Runes) using any Bitcoin wallets with support for sat tracking. This featuer enables single-transaction, trustless atomic swaps between BTC and Counterparty assets, as well as Counterparty assets and other L2 protocols. Attaching assets to UTXOs uses the new gas system that allows for a dynamic XCP fee for transactions to reduce the barrier to entry into Counterparty for new users.
Design
Attach
-
It is possible to attach an arbitrary number of assets from an address to a UTXO.
-
Assets are attached from transaction source address to the first UTXO non-
OP_RETURNoutput or, if provided, to thedestination_voutoutput. -
If
destination_voutdesignates an invalid output (OP_RETURNor non-existent) or if the transaction contains only a single OP_RETURN output, the transaction is invalid. -
Fees in XCP, calculated using the new gas system, will be paid by the
sourceaddress for anattach. -
For each
attach, a row will be added to thesendtable, triggering theATTACH_TO_UTXOevent. -
When assets are attached to a UTXO, it is impossible to use them for a Counterparty transaction (
order,send, etc.), apart fromdetach. -
The embedded data in a
attachtransaction is small enough that anOP_RETURNoutput is always sufficient.
Detach
-
All inputs of every
detachtransaction are detached. -
If no
destinationis provided, the assets are sent to the address corresponding to the detached input. -
It is impossible to perform a
moveat the same time as adetach. -
For each
detach, a row will be added to thesendtable, triggering theDETACH_FROM_UTXOevent. -
The embedded data in a
detachtransaction is small enough that anOP_RETURNoutput is always sufficient.
Move
-
utxo.move_assets()is executed before all Counterparty contracts, except forattachtransaction. -
When a UTXO is spent, a row is added to the
sendtable for each asset attached to this UTXO, triggering aUTXO_MOVEevent.
API
- API routes
"/v2/addresses/<address>/compose/attach": compose.compose_attach,
"/v2/utxos/<utxo>/compose/detach": compose.compose_detach,
"/v2/utxos/<utxo>/compose/movetoutxo": compose.compose_movetoutxo,
"/v2/compose/attach/estimatexcpfees": compose.get_attach_estimate_xcp_fee,
-
To prevent assets from being moved unintentionally, the transaction composition API excludes UTXOs with assets attached by default.
-
Balances contain two fields for UTXO support:
utxoandutxo_address.