channels: fix coop close asset distribution for grouped asset channels#1505
Merged
channels: fix coop close asset distribution for grouped asset channels#1505
Conversation
Contributor
Author
|
Corresponding itest case that found this issue is here: lightninglabs/lightning-terminal#1056 |
Pull Request Test Coverage Report for Build 14883073599Details
💛 - Coveralls |
ffranr
reviewed
May 7, 2025
The code that groups a list of proofs by their asset ID is useful in other places, so we extract it into a re-usable function.
This commit adds a new helper function that creates a set of virtual packets from an aux commitment state and a set of input proofs (as well as some negotiated values during the coop channel close flow). The purpose of this is to use the asset allocation that has already happened to distribute the assets of different asset ID pieces within the given channel commitment again for the virtual packets of a coop close transaction. The reason we want to use the already allocated outputs vs. re-allocating them again is to make sure that the distribution matches exactly that of the commitment. See explanation in next commit for more details.
This commit fixes the actual issue. It makes sure that the way the asset pieces of different asset IDs (for example in grouped asset channels) are distributed matches exactly the last commitment transaction. See comment above call to CommitmentToPackets in this commit for more details.
c2ef059 to
83823c5
Compare
ffranr
approved these changes
May 7, 2025
Contributor
ffranr
left a comment
There was a problem hiding this comment.
Thanks for the added context in 1:1
3 tasks
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.
What this issue fixes is a bit hard to explain. So I'll just copy the comment that's above the fix: