lnd
lnd copied to clipboard
lnwallet: respect local dust limit in cooperative close
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
- allowing the remote peer to eliminate its own output (spec).
- potentially having a ruleset to in some circumstances eliminate the local output if it's small enough.
Steps to Test
- Create a channel with Alice and Bob
- Alice has dustlimit 10000
- Bob has dustlimit 2000
- Bob's balance is 2500
- Attempt to cooperatively close the channel
- Alice should not include Bob's output in the closing transaction
Pull Request Checklist
Testing
- [ ] Your PR passes all CI checks.
- [x] Tests covering the positive and negative (error paths) are included.
- [x] Bug fixes contain tests triggering the bug to prevent regressions.
Code Style and Documentation
- [x] The change obeys the Code Documentation and Commenting guidelines, and lines wrap at 80.
- [x] Commits follow the Ideal Git Commit Structure.
- [x] Any new logging statements use an appropriate subsystem and logging level.
- [x] Any new lncli commands have appropriate tags in the comments for the rpc in the proto file.
- [x] There is a change description in the release notes, or
[skip ci]
in the commit message for small changes.
📝 Please see our Contribution Guidelines for further guidance.