Repository navigation
fix: move RGB channel balance only when an HTLC settles - #52
Open
orbitalturtle wants to merge 1 commit into
Open
orbitalturtle wants to merge 1 commit into
orbitalturtle wants to merge 1 commit into
Conversation
The pending RGB amounts moved when an HTLC was committed and never moved back when it failed, so a failed RGB HTLC handed its assets to the counterparty at close. Track the settled RGB balance next to value_to_self_msat and color commitments from it, like LDK does for BTC. Co-Authored-By: Claude
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The pending RGB amounts moved when an HTLC was committed and never moved back when it failed, so a failed RGB HTLC handed its assets to the counterparty at close, as reproduced in the test in #[TBD]. This PR proposes a potential fix: track the settled RGB balance next to
value_to_self_msatand color commitments from it, like LDK does for BTC.Why settle-time and not reverting on failure
We considered two fixes: keep moving the balance at commit time and undo it when the HTLC fails, or move the balance only once the HTLC settles. We went with the second because:
value_to_self_msatexcludes pending HTLCs and only changes in therevoke_and_ackbranches where an HTLC is irrevocably fulfilled (inboundLocalRemoved(Fulfill)and outboundAwaitingRemovedRemoteRevoke(Success)). An in-flight HTLC's value sits in its own HTLC output, not in either party's balance. RGB amounts now follow the same rule, so the RGB and BTC sides of the channel can't drift apart.update_fail_htlc,update_fail_malformed_htlc, timeouts, failures from the holding cell or after a reconnect, and on-chain resolution. Undoing the move would need correct handling on every one of these paths, and missing one brings the bug back. Moving the balance on settle touches a single place.