Skip to content

Commit abd8b76

Browse files
author
MarcoFalke
committed
[qt] Properly display required fee instead of minTxFee
1 parent 46f7437 commit abd8b76

File tree

5 files changed

+26
-12
lines changed

5 files changed

+26
-12
lines changed

src/qt/coincontroldialog.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -636,21 +636,21 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
636636

637637
// tool tips
638638
QString toolTip1 = tr("This label turns red if the transaction size is greater than 1000 bytes.") + "<br /><br />";
639-
toolTip1 += tr("This means a fee of at least %1 per kB is required.").arg(BitcoinUnits::formatWithUnit(nDisplayUnit, CWallet::minTxFee.GetFeePerK())) + "<br /><br />";
639+
toolTip1 += tr("This means a fee of at least %1 per kB is required.").arg(BitcoinUnits::formatWithUnit(nDisplayUnit, CWallet::GetRequiredFee(1000))) + "<br /><br />";
640640
toolTip1 += tr("Can vary +/- 1 byte per input.");
641641

642642
QString toolTip2 = tr("Transactions with higher priority are more likely to get included into a block.") + "<br /><br />";
643643
toolTip2 += tr("This label turns red if the priority is smaller than \"medium\".") + "<br /><br />";
644-
toolTip2 += tr("This means a fee of at least %1 per kB is required.").arg(BitcoinUnits::formatWithUnit(nDisplayUnit, CWallet::minTxFee.GetFeePerK()));
644+
toolTip2 += tr("This means a fee of at least %1 per kB is required.").arg(BitcoinUnits::formatWithUnit(nDisplayUnit, CWallet::GetRequiredFee(1000)));
645645

646646
QString toolTip3 = tr("This label turns red if any recipient receives an amount smaller than %1.").arg(BitcoinUnits::formatWithUnit(nDisplayUnit, ::minRelayTxFee.GetFee(546)));
647647

648648
// how many satoshis the estimated fee can vary per byte we guess wrong
649649
double dFeeVary;
650650
if (payTxFee.GetFeePerK() > 0)
651-
dFeeVary = (double)std::max(CWallet::minTxFee.GetFeePerK(), payTxFee.GetFeePerK()) / 1000;
651+
dFeeVary = (double)std::max(CWallet::GetRequiredFee(1000), payTxFee.GetFeePerK()) / 1000;
652652
else
653-
dFeeVary = (double)std::max(CWallet::minTxFee.GetFeePerK(), mempool.estimateFee(nTxConfirmTarget).GetFeePerK()) / 1000;
653+
dFeeVary = (double)std::max(CWallet::GetRequiredFee(1000), mempool.estimateFee(nTxConfirmTarget).GetFeePerK()) / 1000;
654654
QString toolTip4 = tr("Can vary +/- %1 satoshi(s) per input.").arg(dFeeVary);
655655

656656
l3->setToolTip(toolTip4);

src/qt/optionsdialog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include "txdb.h" // for -dbcache defaults
1919

2020
#ifdef ENABLE_WALLET
21-
#include "wallet/wallet.h" // for CWallet::minTxFee
21+
#include "wallet/wallet.h" // for CWallet::GetRequiredFee()
2222
#endif
2323

2424
#include <boost/thread.hpp>

src/qt/sendcoinsdialog.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ void SendCoinsDialog::setModel(WalletModel *model)
172172
connect(ui->checkBoxMinimumFee, SIGNAL(stateChanged(int)), this, SLOT(coinControlUpdateLabels()));
173173
connect(ui->checkBoxFreeTx, SIGNAL(stateChanged(int)), this, SLOT(updateGlobalFeeVariables()));
174174
connect(ui->checkBoxFreeTx, SIGNAL(stateChanged(int)), this, SLOT(coinControlUpdateLabels()));
175-
ui->customFee->setSingleStep(CWallet::minTxFee.GetFeePerK());
175+
ui->customFee->setSingleStep(CWallet::GetRequiredFee(1000));
176176
updateFeeSectionControls();
177177
updateMinFeeLabel();
178178
updateSmartFeeLabel();
@@ -569,7 +569,7 @@ void SendCoinsDialog::on_buttonMinimizeFee_clicked()
569569
void SendCoinsDialog::setMinimumFee()
570570
{
571571
ui->radioCustomPerKilobyte->setChecked(true);
572-
ui->customFee->setValue(CWallet::minTxFee.GetFeePerK());
572+
ui->customFee->setValue(CWallet::GetRequiredFee(1000));
573573
}
574574

575575
void SendCoinsDialog::updateFeeSectionControls()
@@ -621,8 +621,8 @@ void SendCoinsDialog::updateFeeMinimizedLabel()
621621
void SendCoinsDialog::updateMinFeeLabel()
622622
{
623623
if (model && model->getOptionsModel())
624-
ui->checkBoxMinimumFee->setText(tr("Pay only the minimum fee of %1").arg(
625-
BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), CWallet::minTxFee.GetFeePerK()) + "/kB")
624+
ui->checkBoxMinimumFee->setText(tr("Pay only the required fee of %1").arg(
625+
BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), CWallet::GetRequiredFee(1000)) + "/kB")
626626
);
627627
}
628628

@@ -635,7 +635,7 @@ void SendCoinsDialog::updateSmartFeeLabel()
635635
CFeeRate feeRate = mempool.estimateFee(nBlocksToConfirm);
636636
if (feeRate <= CFeeRate(0)) // not enough data => minfee
637637
{
638-
ui->labelSmartFee->setText(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), CWallet::minTxFee.GetFeePerK()) + "/kB");
638+
ui->labelSmartFee->setText(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), CWallet::GetRequiredFee(1000)) + "/kB");
639639
ui->labelSmartFee2->show(); // (Smart fee not initialized yet. This usually takes a few blocks...)
640640
ui->labelFeeEstimation->setText("");
641641
}

src/wallet/wallet.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2120,6 +2120,11 @@ bool CWallet::CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey)
21202120
return true;
21212121
}
21222122

2123+
CAmount CWallet::GetRequiredFee(unsigned int nTxBytes)
2124+
{
2125+
return std::max(minTxFee.GetFee(nTxBytes), ::minRelayTxFee.GetFee(nTxBytes));
2126+
}
2127+
21232128
CAmount CWallet::GetMinimumFee(unsigned int nTxBytes, unsigned int nConfirmTarget, const CTxMemPool& pool)
21242129
{
21252130
// payTxFee is user-set "I want to pay this much"
@@ -2131,9 +2136,9 @@ CAmount CWallet::GetMinimumFee(unsigned int nTxBytes, unsigned int nConfirmTarge
21312136
if (nFeeNeeded == 0)
21322137
nFeeNeeded = pool.estimateFee(nConfirmTarget).GetFee(nTxBytes);
21332138
// ... unless we don't have enough mempool data, in which case fall
2134-
// back to a hard-coded fee
2139+
// back to the required fee
21352140
if (nFeeNeeded == 0)
2136-
nFeeNeeded = minTxFee.GetFee(nTxBytes);
2141+
nFeeNeeded = GetRequiredFee(nTxBytes);
21372142
// prevent user from paying a non-sense fee (like 1 satoshi): 0 < fee < minRelayFee
21382143
if (nFeeNeeded < ::minRelayTxFee.GetFee(nTxBytes))
21392144
nFeeNeeded = ::minRelayTxFee.GetFee(nTxBytes);

src/wallet/wallet.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,16 @@ class CWallet : public CCryptoKeyStore, public CValidationInterface
628628
bool CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey);
629629

630630
static CFeeRate minTxFee;
631+
/**
632+
* Estimate the minimum fee considering user set parameters
633+
* and the required fee
634+
*/
631635
static CAmount GetMinimumFee(unsigned int nTxBytes, unsigned int nConfirmTarget, const CTxMemPool& pool);
636+
/**
637+
* Return the minimum required fee taking into account the
638+
* floating relay fee and user set minimum transaction fee
639+
*/
640+
static CAmount GetRequiredFee(unsigned int nTxBytes);
632641

633642
bool NewKeyPool();
634643
bool TopUpKeyPool(unsigned int kpSize = 0);

0 commit comments

Comments
 (0)