Skip to content

Commit 2fffaa9

Browse files
committed
Make QT fee displays use GetMinimumFee instead of estimateSmartFee
Remove helper function (CalculateEstimateType) for determining whether estimates should be conservative or not, now that this is only called once from GetMinimumFee and incorporate the logic directly there.
1 parent 1983ca6 commit 2fffaa9

File tree

5 files changed

+14
-35
lines changed

5 files changed

+14
-35
lines changed

src/qt/coincontroldialog.cpp

+2-8
Original file line numberDiff line numberDiff line change
@@ -490,8 +490,6 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
490490
else nBytesInputs += 148;
491491
}
492492

493-
bool conservative_estimate = CalculateEstimateType(FeeEstimateMode::UNSET, coinControl->signalRbf);
494-
495493
// calculation
496494
if (nQuantity > 0)
497495
{
@@ -583,12 +581,8 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
583581
QString toolTipDust = tr("This label turns red if any recipient receives an amount smaller than the current dust threshold.");
584582

585583
// how many satoshis the estimated fee can vary per byte we guess wrong
586-
double dFeeVary;
587-
if (payTxFee.GetFeePerK() > 0)
588-
dFeeVary = (double)std::max(CWallet::GetRequiredFee(1000), payTxFee.GetFeePerK()) / 1000;
589-
else {
590-
dFeeVary = (double)std::max(CWallet::GetRequiredFee(1000), ::feeEstimator.estimateSmartFee(*coinControl->m_confirm_target, NULL, ::mempool, conservative_estimate).GetFeePerK()) / 1000;
591-
}
584+
double dFeeVary = (double)nPayFee / nBytes;
585+
592586
QString toolTip4 = tr("Can vary +/- %1 satoshi(s) per input.").arg(dFeeVary);
593587

594588
l3->setToolTip(toolTip4);

src/qt/sendcoinsdialog.cpp

+6-10
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@ void SendCoinsDialog::updateCoinControlState(CCoinControl& ctrl)
652652
if (ui->radioCustomFee->isChecked()) {
653653
ctrl.m_feerate = CFeeRate(ui->customFee->value());
654654
} else {
655-
ctrl.m_feerate = boost::none;
655+
ctrl.m_feerate.reset();
656656
}
657657
// Avoid using global defaults when sending money from the GUI
658658
// Either custom fee will be used or if not selected, the confirmation target from dropdown box
@@ -666,15 +666,13 @@ void SendCoinsDialog::updateSmartFeeLabel()
666666
return;
667667
CCoinControl coin_control;
668668
updateCoinControlState(coin_control);
669-
coin_control.m_feerate = boost::none; // Explicitly use only fee estimation rate for smart fee labels
669+
coin_control.m_feerate.reset(); // Explicitly use only fee estimation rate for smart fee labels
670670
FeeCalculation feeCalc;
671-
bool conservative_estimate = CalculateEstimateType(FeeEstimateMode::UNSET, coin_control.signalRbf);
672-
CFeeRate feeRate = ::feeEstimator.estimateSmartFee(*coin_control.m_confirm_target, &feeCalc, ::mempool, conservative_estimate);
671+
CFeeRate feeRate = CFeeRate(CWallet::GetMinimumFee(1000, coin_control, ::mempool, ::feeEstimator, &feeCalc));
673672

674-
if (feeRate <= CFeeRate(0)) // not enough data => minfee
675-
{
676-
ui->labelSmartFee->setText(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(),
677-
std::max(CWallet::fallbackFee.GetFeePerK(), CWallet::GetRequiredFee(1000))) + "/kB");
673+
ui->labelSmartFee->setText(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), feeRate.GetFeePerK()) + "/kB");
674+
675+
if (feeCalc.reason == FeeReason::FALLBACK) {
678676
ui->labelSmartFee2->show(); // (Smart fee not initialized yet. This usually takes a few blocks...)
679677
ui->labelFeeEstimation->setText("");
680678
ui->fallbackFeeWarningLabel->setVisible(true);
@@ -685,8 +683,6 @@ void SendCoinsDialog::updateSmartFeeLabel()
685683
}
686684
else
687685
{
688-
ui->labelSmartFee->setText(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(),
689-
std::max(feeRate.GetFeePerK(), CWallet::GetRequiredFee(1000))) + "/kB");
690686
ui->labelSmartFee2->hide();
691687
ui->labelFeeEstimation->setText(tr("Estimated to begin confirmation within %n block(s).", "", feeCalc.returnedTarget));
692688
ui->fallbackFeeWarningLabel->setVisible(false);

src/wallet/coincontrol.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ class CCoinControl
4343
fAllowOtherInputs = false;
4444
fAllowWatchOnly = false;
4545
setSelected.clear();
46-
m_feerate = boost::none;
46+
m_feerate.reset();
4747
fOverrideFeeRate = false;
48-
m_confirm_target = boost::none;
48+
m_confirm_target.reset();
4949
signalRbf = fWalletRbf;
5050
m_fee_mode = FeeEstimateMode::UNSET;
5151
}

src/wallet/wallet.cpp

+4-13
Original file line numberDiff line numberDiff line change
@@ -2945,8 +2945,11 @@ CAmount CWallet::GetMinimumFee(unsigned int nTxBytes, const CCoinControl& coin_c
29452945
else { // 2. or 4.
29462946
// We will use smart fee estimation
29472947
unsigned int target = coin_control.m_confirm_target ? *coin_control.m_confirm_target : ::nTxConfirmTarget;
2948+
// By default estimates are economical iff we are signaling opt-in-RBF
2949+
bool conservative_estimate = !coin_control.signalRbf;
29482950
// Allow to override the default fee estimate mode over the CoinControl instance
2949-
bool conservative_estimate = CalculateEstimateType(coin_control.m_fee_mode, coin_control.signalRbf);
2951+
if (coin_control.m_fee_mode == FeeEstimateMode::CONSERVATIVE) conservative_estimate = true;
2952+
else if (coin_control.m_fee_mode == FeeEstimateMode::ECONOMICAL) conservative_estimate = false;
29502953

29512954
fee_needed = estimator.estimateSmartFee(target, feeCalc, pool, conservative_estimate).GetFee(nTxBytes);
29522955
if (fee_needed == 0) {
@@ -4194,15 +4197,3 @@ bool CMerkleTx::AcceptToMemoryPool(const CAmount& nAbsurdFee, CValidationState&
41944197
{
41954198
return ::AcceptToMemoryPool(mempool, state, tx, true, NULL, NULL, false, nAbsurdFee);
41964199
}
4197-
4198-
bool CalculateEstimateType(FeeEstimateMode mode, bool opt_in_rbf) {
4199-
switch (mode) {
4200-
case FeeEstimateMode::UNSET:
4201-
return !opt_in_rbf; // Allow for lower fees if RBF is an option
4202-
case FeeEstimateMode::CONSERVATIVE:
4203-
return true;
4204-
case FeeEstimateMode::ECONOMICAL:
4205-
return false;
4206-
}
4207-
return true;
4208-
}

src/wallet/wallet.h

-2
Original file line numberDiff line numberDiff line change
@@ -1213,6 +1213,4 @@ bool CWallet::DummySignTx(CMutableTransaction &txNew, const ContainerType &coins
12131213
return true;
12141214
}
12151215

1216-
bool CalculateEstimateType(FeeEstimateMode mode, bool opt_in_rbf);
1217-
12181216
#endif // BITCOIN_WALLET_WALLET_H

0 commit comments

Comments
 (0)