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
wallet: error if an explicit fee rate was given but the needed fee rate differed #18275
wallet: error if an explicit fee rate was given but the needed fee rate differed #18275
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
Can you add a test with |
src/wallet/wallet.cpp
Outdated
// Do not, ever, assume that it's fine to change the fee rate if the user has explicitly | ||
// provided one | ||
if (coin_control.m_feerate && nFeeRateNeeded > *coin_control.m_feerate) { | ||
strFailReason = strprintf("Fee rate is too low for the current mempool. Increase it to %s or modify -maxmempool", nFeeRateNeeded.ToString()); |
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.
The mempool fee is not considered when the user picks the fee rate. See also https://doxygen.bitcoincore.org/wallet_2fees_8cpp_source.html#l00028
How did you trigger this bug? It would be nice to include a test vector or steps to reproduce, otherwise this will just be dead code.
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.
@MarcoFalke the error is triggered by setting a fee rate below 1 sat / byte in the updated sendtoaddress
RPCs in #11413. See #11413 (comment) for discussion and some alternative ideas.
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.
If it is not possible to hit this case with Bitcoin Core master, it probably makes sense to only add it when it can be hit. And also add a test to hit it.
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.
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.
The mempool fee is not considered when the user picks the fee rate. See also https://doxygen.bitcoincore.org/wallet_2fees_8cpp_source.html#l00028
How did you trigger this bug? It would be nice to include a test vector or steps to reproduce, otherwise this will just be dead code.
That code calls mempoolMinFee()
though.
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.
That code calls mempoolMinFee() though.
No? It doesn't.
The code is
// Obey mempool min fee when using smart fee estimation
CFeeRate min_mempool_feerate = wallet.chain().mempoolMinFee();
Setting a fee manually in the gui is not "smart fee". What am I missing?
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.
You're not missing anything, because you're absolutely right. Should've read the code more carefully...
I've fixed the message.
I tried and that takes me all the way to |
f6f525c
to
7ac14a5
Compare
I was hoping this was only an RPC issue. The error message is not very GUI friendly, but this should be bellt-and-suspenders check. The GUI is supposed to prevent you from entering a too low amount. Your screenshot is a bit confusing, because the UI automatically corrects the input form when the value is below the minimum relay fee. But that correction only happens when you click somewhere else, like another field or the send button. You can also see the issue when you launch with tACK 7ac14a5 On a related note: I don't like that the GUI changes the fee amount from under me. It should just color the field red and show an error message below the field. But that's a separate PR imo, this check is useful regardless. |
tACK 7ac14a5 |
Concept ACK |
7ac14a5
to
f9b85c1
Compare
As @MarcoFalke pointed out, this actually does not rely on the current mempool limitations. I've updated the error message accordingly. It now reads
|
f9b85c1
to
b8711d0
Compare
re-ACK b8711d0 Only changes were rebasing and improvement of the error message. |
I can not reproduce with the steps given here: #18275 (comment) |
Couldn't reproduce either with |
Are you trying to reproduce on this branch or on master? On master, this is what it ends up like (note that it silently resets my desired fee rate when I defocus and/or click send): https://youtu.be/I0JZpmJ-Gls |
I mean I couldn't get the newly introduced error to execute. Not in the GUI, and not in the RPC. Just tried again with recompile. Maybe this is a mac-specific issue? Or I have something in my gui settings that prevents it. |
tACK b8711d0. Just a rebase and text improvement since my last review. |
@MarcoFalke Sorry about that [previous now-deleted comment showing 'settxfee' error], I got the messages mixed up. You're right that it doesn't seem possible to trigger this error from RPC/CLI. To trigger in QT, you need to change the fee rate and then click send without defocusing the window. This is probably platform dependent, so it may not be reproducable on non-macOS. |
Just double checked: I can still produce this error in the GUI. |
code-review-only ACK b8711d0, seems this can only be hit on macos |
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.
utACK b8711d0
There is a silent merge conflict, |
b8711d0
to
1b71a59
Compare
@meshcollider Edit: Yeah, nevermind. Fixed. |
…te differed This avoids cases where a user requests a fee rate below the minimum and is silently overruled by the wallet.
1b71a59
to
44cc75f
Compare
utACK 44cc75f (rebased) |
re-ACK 44cc75f |
…te differed This avoids cases where a user requests a fee rate below the minimum and is silently overruled by the wallet. Github-Pull: bitcoin#18275 Rebased-From: 44cc75f
Due to bitcoin/bitcoin#18275, make sure that the minimum fee bump is at least matching the required fee level for relay. Otherwise the wallet Qt tests fail because they create a zero-fee transaction and bump its fee, and then run into this new check.
…but the needed fee rate differed 44cc75f wallet: error if an explicit fee rate was given but the needed fee rate differed (Karl-Johan Alm) Pull request description: This ensures that the code doesn't silently ignore too low fee reates. It will now trigger an error in the QT client, if the user provides a fee rate below the minimum, and becomes a necessary check for bitcoin#11413. ACKs for top commit: Sjors: utACK 44cc75f (rebased) fjahr: re-ACK 44cc75f Tree-SHA512: cd5a60ee496e64f7ab37aaa53f7748a7393357b1629ccd9660839d366c6191b6413b871ce3aa7293fce1539336222c300ef6f86304f30a1ae8fe361b02310483
…te differed Summary: This avoids cases where a user requests a fee rate below the minimum and is silently overruled by the wallet. This is a backport of [[bitcoin/bitcoin#18275 | core#18275]] Test Plan: Run bitcoin-qt and manually set a too low fee when trying to send a transaction. The following patch may be needed to let the interface set a fee lower than the minimum: ``` diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp index dc9c4bf699..99da1f837d 100644 --- a/src/qt/sendcoinsdialog.cpp +++ b/src/qt/sendcoinsdialog.cpp @@ -188,7 +188,7 @@ void SendCoinsDialog::setModel(WalletModel *_model) { connect(ui->customFee, &BitcoinAmountField::valueChanged, this, &SendCoinsDialog::coinControlUpdateLabels); Amount requiredFee = model->wallet().getRequiredFee(1000); - ui->customFee->SetMinValue(requiredFee); + ui->customFee->SetMinValue(Amount::satoshi()); if (ui->customFee->value() < requiredFee) { ui->customFee->setValue(requiredFee); } ``` Reviewers: #bitcoin_abc, majcosta Reviewed By: #bitcoin_abc, majcosta Differential Revision: https://reviews.bitcoinabc.org/D9936
This ensures that the code doesn't silently ignore too low fee reates. It will now trigger an error in the QT client, if the user provides a fee rate below the minimum, and becomes a necessary check for #11413.