Skip to content

Fix plain channel interoperability with stock LDK - #36

Open
bitwalt wants to merge 1 commit into
RGB-Tools:rgbfrom
bitwalt:rgb-stock-ldk-interop
Open

Fix plain channel interoperability with stock LDK#36
bitwalt wants to merge 1 commit into
RGB-Tools:rgbfrom
bitwalt:rgb-stock-ldk-interop

Conversation

@bitwalt

@bitwalt bitwalt commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Fixes #35.

Makes the two RGB wire/transaction extensions conditional, so plain channels are byte-identical to upstream LDK while RGB channels are unaffected.

Commitment transaction fee

commitment_tx_base_weight goes back to upstream, and the OP_RETURN weight is added only when the channel is colored. SpecTxBuilder carries that flag, taken from the rgb_asset already on FundingScope, so every fee calculation on a channel agrees with the transaction actually built for it.

The constant and the colored fee helper live in rgb_utils, next to the rest of the RGB logic, so chan_utils and tx_builder only wire it in. The weight is documented where it is defined: 8-byte value, 1-byte script length and a 34-byte OP_RETURN OP_PUSHBYTES_32 <commitment> script, so 43 vbytes, 172 weight units.

Two details worth pointing out for review:

  • get_next_commitment_stats now uses the same commit_tx_fee_sat as build_commitment_transaction. It previously called the free function directly, which was harmless while every path unconditionally included the OP_RETURN weight, but would have left colored channels predicting a fee 172 weight units below the one baked into their own commitment transaction.
  • The colored helper keeps the fee in a single division rather than adding the OP_RETURN cost separately, so rounding matches the uncolored path exactly.

update_add_htlc

rgb_payment becomes an optional odd TLV instead of a mandatory suffix, so peers without RGB support skip it.

Open question: we chose an odd type outside the range the BOLTs may assign, following the convention already used here for skimmed_fee_msat (65537) and hold_htlc (75537), where the TODO above hold_htlc spells out the reasoning. If RGB has a preferred allocation, or you would rather this be specified somewhere first, say which type and we will match it — it is a one-line change.

Validation

Verified at the node level rather than here, since that is where a stock peer can actually be driven: RGB-Tools/rgb-lightning-node#149 adds a stock ldk-node fixture and exercises the full lifecycle in both opener directions — channel_ready, a payment each way, balances moving as expected, cooperative close settling on-chain — plus a negative test asserting an RGB channel to a stock peer never becomes ready. All three pass with this commit and fail without it.

Compatibility

Breaking on the wire for deployed nodes: plain channels between a fixed and an unfixed peer derive different commitment transactions and force-close on the next commitment_signed, and RGB channels cannot parse each other's HTLCs across the encoding change. Persisted channel state is unaffected, so restarting an upgraded node is safe, but a release carrying this wants a coordinated upgrade.

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.

Plain channels are not wire-compatible with upstream LDK

1 participant