-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lnwallet: respect local dust limit in cooperative close #8767
base: master
Are you sure you want to change the base?
lnwallet: respect local dust limit in cooperative close #8767
Conversation
When the remote dustlimit is lower than the local one, a cooperative closure could create an output that doesn't respect the local dustlimit. By comparing the remote balance to the local dustlimit we're protected against creating invalid cooperative close transactions according to the local standards.
Important Auto Review SkippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
It's probably better to have an agreed value on |
That's a decision you can make. To either fail the closing procedure, because you have in invalid signature according to the remote party, or to omit your own output. Probably a good reasoning to decide whether you should omit your own output is:
For now, this PR only ensures you never create a transaction below your own dust limit in the first place. Deciding to omit your own output can be future improvements. |
The reason we haven't done this is because iirc each implementation does something slightly different. I'd defer work on this PR until we can all agree on the logic here. Additionally, changing this now will result in incompatibility with older LND nodes. |
I agree there will be an incompatibility with older LND nodes. In fact, there will be an incompatibility between upgraded LND nodes too. If one party omits the peers output, but the peer doesn't, there's an incompatibility. But it also doesn't ever make sense to construct a closing transaction with an output below your own dustlimit. So the incompatibility already exists. This change just makes it more obvious. |
@@ -8616,7 +8616,7 @@ func CreateCooperativeCloseTx(fundingTxIn wire.TxIn, | |||
Value: int64(ourBalance), | |||
}) | |||
} | |||
if theirBalance >= remoteDust { | |||
if theirBalance >= remoteDust && theirBalance >= localDust { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
technically, the wording of the spec means this should be if theirBalance >= localDust
. I think some clarification in the spec meeting would be helpful here. You're right an incompatibility exists even with this change which is why I think it's important to nail down the specifics and see if we can get rid of that incompatibility for coop close v1. I don't think a partial fix is worth doing. When coop close v2 is deployed (slated for 0.18.1 but may get pushed to 0.19), this logic is likely to get superseded but may be toggle-able at first.
FWIW rbf-coop close will make this explicit, as the ender of a signature states which outputs is does/doesn't cover: #8453 |
@JssDWt, remember to re-request review from reviewers when ready |
Change Description
When the remote dustlimit is lower than the local one, a cooperative closure could create an output that doesn't respect the local dustlimit. By comparing the remote balance to the local dustlimit we're protected against creating invalid cooperative close transactions according to the local standards.
This requirement is part of the BOLTs: https://github.com/lightning/bolts/blob/5f8fea8dc3c8c612167dd9645c4a21fe9de2f147/03-transactions.md?plain=1#L373
Unfortunately this now leads to failure to close the channel. But that's better than crafting invalid transactions in my opinion.
Next steps will be
Steps to Test
Pull Request Checklist
Testing
Code Style and Documentation
[skip ci]
in the commit message for small changes.📝 Please see our Contribution Guidelines for further guidance.