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_RETURN
output or, if provided, to thedestination_vout
output. -
If
destination_vout
designates an invalid output (OP_RETURN
or 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
source
address for anattach
. -
For each
attach
, a row will be added to thesend
table, triggering theATTACH_TO_UTXO
event. -
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
attach
transaction is small enough that anOP_RETURN
output is always sufficient.
Detach
-
All inputs of every
detach
transaction are detached. -
If no
destination
is provided, the assets are sent to the address corresponding to the detached input. -
It is impossible to perform a
move
at the same time as adetach
. -
For each
detach
, a row will be added to thesend
table, triggering theDETACH_FROM_UTXO
event. -
The embedded data in a
detach
transaction is small enough that anOP_RETURN
output is always sufficient.
Move
-
utxo.move_assets()
is executed before all Counterparty contracts, except forattach
transaction. -
When a UTXO is spent, a row is added to the
send
table for each asset attached to this UTXO, triggering aUTXO_MOVE
event.
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:
utxo
andutxo_address
.