lnd icon indicating copy to clipboard operation
lnd copied to clipboard

lnwallet: respect local dust limit in cooperative close

Open JssDWt opened this issue 9 months ago • 7 comments

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

📝 Please see our Contribution Guidelines for further guidance.

JssDWt avatar May 17 '24 15:05 JssDWt