Skip to content

Commit

Permalink
wallet: error if an explicit fee rate was given but the needed fee ra…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
kallewoof authored and PiRK committed Aug 26, 2021
1 parent a049e43 commit 21214d0
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/wallet/wallet.cpp
Expand Up @@ -3077,6 +3077,16 @@ bool CWallet::CreateTransactionInternal(const std::vector<CRecipient> &vecSend,

// Get the fee rate to use effective values in coin selection
CFeeRate nFeeRateNeeded = GetMinimumFeeRate(*this, coin_control);
// 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) {
error = strprintf(_("Fee rate (%s) is lower than the minimum fee "
"rate setting (%s)"),
coin_control.m_feerate->ToString(),
nFeeRateNeeded.ToString());
return false;
}

nFeeRet = Amount::zero();
bool pick_new_inputs = true;
Expand Down

0 comments on commit 21214d0

Please sign in to comment.