Skip to content

Proposal: two-phase RGB HTLC claim/refund flow #90

Description

@sbn20241

Proposal: HTLC claim / refund

We want rgb-lib to support RGB locked on a Bitcoin HTLC, then claimed or refunded into a normal wallet output.

The asset is locked on a normal Bitcoin HTLC outpoint, not on one of our UTXOs. rgb-lib should not treat that as a balance.

Later that outpoint is spent — claim, or refund after timeout — into a normal witness_receive destination. rgb-lib colors that spend and then accepts RGB on our output.

We cannot color and consume fascia in one shot. Consume is not reversible: if the tx never hits the network, we cannot undo the stash.

Before claiming we check the lock with contract_assignments_for_outpoints (right asset and amount on that outpoint). Then psbt_op_prepare: color the spend from the lock, store consignments under the operation dir, return operation_id and colored_psbt. We sign and broadcast. Once the indexer sees the tx we call psbt_op_apply; if not, psbt_op_abort.

Then we put the consignment on the proxy under the invoice recipient_id / proxy_recipient_id. The receiver downloads it with fetch_and_accept_transfer_by_recipient_id: pin output[vout] to the witness_receive script, then accept.

witness_receive already exists. We just need the lock to stay a foreign UTXO, and a way to color that spend without consuming fascia until the tx is actually on the network.

What we need in rgb-lib

These should be on Uniffi as well (we call them from Go).

  1. contract_assignments_for_outpoints — read RGB on that outpoint.
  2. psbt_op_prepare — color a spend of a UTXO the wallet does not own, write the consignment to the operation dir, return operation_id and colored_psbt. Do not consume fascia yet.
  3. psbt_op_apply — consume fascia after the indexer sees the tx.
  4. psbt_op_abort — if the tx never shows up.
  5. fetch_and_accept_transfer_by_recipient_id — download the consignment from the proxy by recipient_id or proxy_recipient_id, pin output[vout] to the witness_receive script, then accept.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions