-
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
Add maxFeeRatio
parameter to sanityCheckFee in psbt coin selection
#8600
Add maxFeeRatio
parameter to sanityCheckFee in psbt coin selection
#8600
Conversation
Important Review skippedAuto reviews are limited to specific labels. 🏷️ Labels to auto review (1)
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 using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Change makes sense. Didn't think about very small amounts when adding the fee sanity check.
lnrpc/walletrpc/walletkit_server.go
Outdated
@@ -1546,7 +1546,7 @@ func (w *WalletKit) fundPsbtCoinSelect(account string, changeIndex int32, | |||
|
|||
changeAmt, needMore, err := chanfunding.CalculateChangeAmount( | |||
inputSum, outputSum, packetFeeNoChange, | |||
packetFeeWithChange, changeDustLimit, changeType, | |||
packetFeeWithChange, changeDustLimit, changeType, true, |
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 think adding this flag makes sense, as you might want to be able to craft a 1-in-1-out transaction that pays more than 20% fees when it's a small input amount. But I think we should also expose this to the RPC and not just set this to true
statically here.
So a new bool RPC parameter, for example allow_high_fees
which by default is false
.
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.
Ok, very happy to see that you agree with this approach.
I didn't expose this on RPC only because of "bloating" concerns, as I didn't want this extra flag to reach the user-facing params.
But I also think a psbt related call is the place to be specific and have fine control, on the other hand. So will change it as per your suggestion 👌
!lightninglabs-deploy mute 720h30m |
@GeorgeTsagk, remember to re-request review from reviewers when ready |
!lightninglabs-deploy mute |
There's renewed interest in shipping these features. Will unmute to try to merge the code. If alerts are bothersome for a long time, we can remute !lightninglabs-deploy unmute |
129145c
to
1f32b5f
Compare
chanfunding.CoinSelect
when coming from RPC FundPsbt
maxFeeRatio
parameter to sanityCheckFee in psbt coin selection
1f32b5f
to
155d1a0
Compare
hmm, I think rather than adding a ratio, what about skipping the sanity_fee check, because I think the ratio idea is basically the same as skipping it, at least that's how I envision it will be used. instead of a ratio, just add maybe a flag to skip the fee-check |
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.
Needs some commit massaging, otherwise looks pretty good.
155d1a0
to
0e487e4
Compare
@guggero all commits can compile now |
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.
Linter and commit check still fails.
Other than that looks good to me.
Helper command to make sure each commit compiles individually:
git rebase -i origin/master --exec "make unit pkg=... case=_NONE_"
0e487e4
to
5eda335
Compare
Ah yes, the first commit that updates the func didn't have the unit tests calling the funcs with all args, used dummy values just for the commit to compile, should be good now |
909891c
to
e138fa7
Compare
Forgot to update the |
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.
Just nits, otherwise LGTM 🎉
ca72f74
to
582fe81
Compare
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.
Still not convinced about the ratio approach but i am open to hear your side of the argument why we should not just instead go with a boolean here ?
I think the use-case will look like this:
- User funds psbt, and gets the error that the fee exceeds 20%
- Probably we currently also return the acutaly ratio with would be needed
- User just selects this ratio, however because we use a > maxFee, he will probably do it twice
So I would favour just a skipFee boolean, which imo does exactly the right thing.
Yeah I agree that a Although this is also meant for external automated software that uses lnd for the funding of psbts Could have a protocol/wallet that needs to craft PSBTs, and depending on what the application is I might want to select a certain ratio across all my calls to If we had the I don't really have better arguments than this, and that I'd rather have a bit more expressiveness by default |
51d09d5
to
33320ba
Compare
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.
Ok agree, the ratio idea can make sense for external software 👍
Had some final comments.
33320ba
to
b19fac1
Compare
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
b19fac1
to
6116039
Compare
Fixed some more unit tests which expected the old err format, waiting for CI |
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.
Some last minute changes made it into the wrong commit.
6116039
to
c1f5908
Compare
Thanks for the last second nits @guggero 💪 |
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, LGTM 🎉
Description
With the introduction of new template options for
WalletKit.FundPsbt
(see related PR) we made use ofchanfunding.CoinSelect
which introduces a slight change in behavior compared to the other template options, it performs a "fee sanity check" which will error out if the total fees exceed the 20% of the total outputs amount.While this makes sense for channel funding, it may be a limitation the user won't always desire when manually funding PSBTs via the RPC.
Solution [Updated]
This PR simply adds a float parameter to the
chanfunding.CoinSelect
namedmaxFeeRatio
which controls the maximum allowed fee to total output amt ratio. Any other path other than theWalletKit.FundPsbt
rpc uses the default ratio of0.2
(20% of total output amount). When calling this function from the RPC we use the value provided by the RPC, or the default if it wasn't set.References