Skip to content

Serialize rgb_payment for pending inbound and outbound HTLCs#20

Merged
gofman8 merged 1 commit into
UTEXO-Protocol:devfrom
dcorral:fix/rgb-payment-htlc-serialization
Jun 23, 2026
Merged

Serialize rgb_payment for pending inbound and outbound HTLCs#20
gofman8 merged 1 commit into
UTEXO-Protocol:devfrom
dcorral:fix/rgb-payment-htlc-serialization

Conversation

@dcorral

@dcorral dcorral commented Jun 23, 2026

Copy link
Copy Markdown

A channel writes the rgb_payment field only for holding-cell HTLCs, but reads it back for pending inbound and outbound HTLCs too. The read and write sides disagree, so the fix simply writes rgb_payment for those HTLCs as well — making the two sides symmetric. The read path is unchanged.

If a channel is saved while it still has a pending inbound or outbound HTLC, the extra read with no matching write makes the deserializer read past the field, drift, and fail with DecodeError::InvalidValue. In practice that means the whole ChannelManager can't be loaded and the node won't restart. It stays hidden as long as HTLCs settle before the channel is saved, and shows up as soon as one is still in flight at save time.

Test

Reproduced end-to-end in rgb-lightning-node by restart_with_pending_rgb_htlc_recovers_channel. It pays a hodl invoice to hold an RGB HTLC open, restarts both nodes, and checks the channel comes back and the payment can be settled. The test fails (InvalidValue on restart) without this fix and passes with it.

@dcorral dcorral self-assigned this Jun 23, 2026
@dcorral dcorral added bug Something isn't working protocol labels Jun 23, 2026
@dcorral dcorral moved this from Todo to In progress in alpha-protocol Jun 23, 2026
@dcorral dcorral requested review from gofman8, rmn-boiko and txalkan June 23, 2026 10:23
@gofman8 gofman8 merged commit 3313e10 into UTEXO-Protocol:dev Jun 23, 2026
6 checks passed
@github-project-automation github-project-automation Bot moved this from In progress to Done in alpha-protocol Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working protocol

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants