Skip to content

Commit 3694b74

Browse files
committed
Merge pull request #6887
53238ff Clarify what minrelaytxfee does (MarcoFalke) abd8b76 [qt] Properly display required fee instead of minTxFee (MarcoFalke)
2 parents 7945652 + 53238ff commit 3694b74

File tree

7 files changed

+28
-14
lines changed

7 files changed

+28
-14
lines changed

src/init.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ std::string HelpMessage(HelpMessageMode mode)
439439
strUsage += HelpMessageOpt("-relaypriority", strprintf("Require high priority for relaying free or low-fee transactions (default: %u)", 1));
440440
strUsage += HelpMessageOpt("-maxsigcachesize=<n>", strprintf("Limit size of signature cache to <n> entries (default: %u)", 50000));
441441
}
442-
strUsage += HelpMessageOpt("-minrelaytxfee=<amt>", strprintf(_("Fees (in %s/kB) smaller than this are considered zero fee for relaying (default: %s)"),
442+
strUsage += HelpMessageOpt("-minrelaytxfee=<amt>", strprintf(_("Fees (in %s/kB) smaller than this are considered zero fee for relaying, mining and transaction creation (default: %s)"),
443443
CURRENCY_UNIT, FormatMoney(::minRelayTxFee.GetFeePerK())));
444444
strUsage += HelpMessageOpt("-printtoconsole", _("Send trace/debug info to console instead of debug.log file"));
445445
if (showDebug)

src/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ size_t nCoinCacheUsage = 5000 * 300;
7474
uint64_t nPruneTarget = 0;
7575
bool fAlerts = DEFAULT_ALERTS;
7676

77-
/** Fees smaller than this (in satoshi) are considered zero fee (for relaying and mining) */
77+
/** Fees smaller than this (in satoshi) are considered zero fee (for relaying, mining and transaction creation) */
7878
CFeeRate minRelayTxFee = CFeeRate(1000);
7979

8080
CTxMemPool mempool(::minRelayTxFee);

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
@@ -2118,6 +2118,11 @@ bool CWallet::CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey)
21182118
return true;
21192119
}
21202120

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

src/wallet/wallet.h

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

659659
static CFeeRate minTxFee;
660+
/**
661+
* Estimate the minimum fee considering user set parameters
662+
* and the required fee
663+
*/
660664
static CAmount GetMinimumFee(unsigned int nTxBytes, unsigned int nConfirmTarget, const CTxMemPool& pool);
665+
/**
666+
* Return the minimum required fee taking into account the
667+
* floating relay fee and user set minimum transaction fee
668+
*/
669+
static CAmount GetRequiredFee(unsigned int nTxBytes);
661670

662671
bool NewKeyPool();
663672
bool TopUpKeyPool(unsigned int kpSize = 0);

0 commit comments

Comments
 (0)