Skip to content

fix(rgb): settle RGB on justice sweeps and color both commitment views - #56

Open
ABallarini wants to merge 1 commit into
devfrom
fix/penalty-tx
Open

ABallarini wants to merge 1 commit into
devfrom
fix/penalty-tx

Conversation

@ABallarini

Copy link
Copy Markdown

Summary

Justice (penalty) sweeps now carry the channel's RGB state transition, so the RGB assigned to a revoked commitment settles for the honest peer instead of being burned, and every node colors both commitment views of each state, so whichever commitment is broadcast, both nodes hold its allocation.

  • color_claim (new): colors the justice transaction with the RGB of the revoked vouts it actually spends, reading the {txid}_transfer_info of every transaction it spends (inputs grouped by spent txid); a zero-value RGB OP_RETURN is appended before signing and accounted for in package_weight. Inputs without transfer info are logged and excluded; the transaction is left uncolored only when nothing is loadable or the total is zero. The claim's transfer info is published to the KVStore (RGB_TRANSFER_INFO_NS) in addition to the file, so the daemon's sweeper, which detects RGB outputs from the KVStore, picks the justice output up and settles the RGB.
  • Per-commitment blinding: commitment seals are witness-relative, so with a shared blinding the two sibling commitments of one state produce content-identical transitions (same OpId) anchored under both witnesses and consignment generation can select the never-broadcast witness. The blinding is now derived from the uncolored commitment txid, identically on both nodes.
  • Runtime plumbing: ldk_data_dir and rgb_kv_store are threaded through the monitor into OnchainTxHandler (via ReadableArgs, never serialized, monitor bytes unchanged) so the justice path can reach the transfer info and build the RGB wallet at claim time.
  • color_commitment/color_closing: rgb-lib errors map to ChannelError::close instead of panicking; all channel.rs call sites handle the result (?, logged abort, or logged skip, fail-closed via the signature check).
  • Bounding guard: an existing {colored_txid}_transfer_info marks the identical transition as already consumed (state rebuild); the duplicate consume_fascia is skipped.

Verified end-to-end by the companion rgb-lightning-node PR (penalty E2E, two stages: the honest party holding 0 or 100 RGB at the revoked state): the justice tx is colored through the new plumbing and the RGB settles via the daemon's prepared-sweep flow.

Documentation: https://hackmd.io/@6IaNVzsDRAeobScrx7A32A/ByoCXc12fe

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant