-
Notifications
You must be signed in to change notification settings - Fork 2.2k
lnwallet: enforce fee floor and dust-reserve adherence #1215
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: enforce fee floor and dust-reserve adherence #1215
Conversation
Roasbeef
left a comment
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.
Nice! Only major comment is that we also need to bump up the reserve (before we send it to the remote party), if we detect that the value is below the dust limit.
lnwallet/fee_estimator.go
Outdated
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.
When would this fail?
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.
It shouldn't, but it doesn't hurt to check the error.
lnwallet/fee_estimator.go
Outdated
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.
May be worth adding a debug logging statement here for future diagnostic purposes.
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.
Fixed.
lnwallet/reservation.go
Outdated
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.
We also need to ensure that the reserve we propose is above the dust limit. If it is, then we should increase the reserve until it's safely above the dust limit.
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.
Fixed.
fundingmanager.go
Outdated
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.
What's the rational for this change?
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.
Removed.
lnwallet/fee_estimator.go
Outdated
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.
Could you fetch the RelayFee in Start() instead?
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.
Fixed.
lnwallet/fee_estimator.go
Outdated
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.
same
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.
Fixed.
lnwallet/reservation.go
Outdated
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.
Re-reading BOLT#2 it looks like the reserve must be >= then both sides's dust limits.
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.
- So when receiving an
open_channel: make sureopen_channel.reserve >= open_channel.dustlimit && open_channel.reserve >= ourDustlimit - When sending
accept_channel: make sureaccept_channel.reserve >= accept_channel.dustlimit && accept_channel.reserve >= open_channel.dustLimit
===============================
- When sending an
openChannel: make sureopenChannel.reserve >= openChannel.dustLimit && openChannel.reserve >= ourDustlimit, if they reject because of low reserve, we must resend with higher reserve - When receiving
accept_channel: make sureaccept_channel.reserve >= accept_channel.dustlimit && accept_channel.reserve >= openChannel.dustLimit
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.
I believe this should be good to go now.
In this commit, we fix an issue where sometimes transactions wouldn't provide enough of a fee to be relayed by the backend node. This would especially cause issues when sweeping outputs after a contract breach, etc. Now, we'll fetch the minimum relay fee from the backend node and ensure it is set as a lower bound if the estimated fee ends up dipping below it.
Roasbeef
left a comment
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.
LGTM 🥁
In this PR, we fix an issue where sometimes transactions wouldn't provide enough of a fee to be relayed by the backend node. This was caused due to
bitcoindno longer using the minimum relay fee when estimating fees (see bitcoin/bitcoin@fd29d3d). This would especially cause issues when sweeping outputs after a contract breach, etc. Now, we'll fetch the minimum relay fee from the backend node and ensure it is set as a lower bound if the estimated fee ends up dipping below it.We also enforce that the channel reserve is above the dust limit. The minimum channel size has also been modified to reflect this change. This allows us to avoid dust outputs from being created in the commitment transactions. This fixes some incompatibility issues between
c-lightningandlnd, due tolndnot fully being BOLT-2 compliant.Fixes #1030.