Skip to content

Commit 988f349

Browse files
committed
[qt] Properly display required fee instead of minTxFee
backports bitcoin/bitcoin@abd8b76 and bitcoin/53238ff0b1085352e4aaa796d0e473551e573143
1 parent c5c9df0 commit 988f349

File tree

7 files changed

+29
-13
lines changed

7 files changed

+29
-13
lines changed

src/init.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ std::string HelpMessage(HelpMessageMode mode)
516516
strUsage += HelpMessageOpt("-maxsigcachesize=<n>", strprintf(_("Limit size of signature cache to <n> entries (default: %u)"), 50000));
517517
}
518518
strUsage += HelpMessageOpt("-maxtipage=<n>", strprintf("Maximum tip age in seconds to consider node in initial block download (default: %u)", DEFAULT_MAX_TIP_AGE));
519-
strUsage += HelpMessageOpt("-minrelaytxfee=<amt>", strprintf(_("Fees (in %s/Kb) smaller than this are considered zero fee for relaying (default: %s)"), CURRENCY_UNIT, FormatMoney(::minRelayTxFee.GetFeePerK())));
519+
strUsage += HelpMessageOpt("-minrelaytxfee=<amt>", strprintf(_("Fees (in %s/Kb) smaller than this are considered zero fee for relaying, mining and transaction creation (default: %s)"), CURRENCY_UNIT, FormatMoney(::minRelayTxFee.GetFeePerK())));
520520
strUsage += HelpMessageOpt("-printtoconsole", strprintf(_("Send trace/debug info to console instead of debug.log file (default: %u)"), 0));
521521
if (GetBoolArg("-help-debug", false)) {
522522
strUsage += HelpMessageOpt("-printpriority", strprintf(_("Log transaction priority and fee per kB when mining blocks (default: %u)"), 0));

src/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ size_t nCoinCacheUsage = 5000 * 300;
9999
/* If the tip is older than this (in seconds), the node is considered to be in initial block download. */
100100
int64_t nMaxTipAge = DEFAULT_MAX_TIP_AGE;
101101

102-
/** Fees smaller than this (in upiv) are considered zero fee (for relaying and mining)
102+
/** Fees smaller than this (in upiv) are considered zero fee (for relaying, mining and transaction creation)
103103
* We are ~100 times smaller then bitcoin now (2015-06-23), set minRelayTxFee only 10 times higher
104104
* so it's still 10 times lower comparing to bitcoin.
105105
*/

src/qt/coincontroldialog.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -721,21 +721,23 @@ void CoinControlDialog::updateLabels(WalletModel* model, QDialog* dialog)
721721

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

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

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

733733
// how many satoshis the estimated fee can vary per byte we guess wrong
734734
double dFeeVary;
735-
if (payTxFee.GetFeePerK() > 0)
736-
dFeeVary = (double)std::max(CWallet::minTxFee.GetFeePerK(), payTxFee.GetFeePerK()) / 1000;
737-
else
738-
dFeeVary = (double)std::max(CWallet::minTxFee.GetFeePerK(), mempool.estimateFee(nTxConfirmTarget).GetFeePerK()) / 1000;
735+
if (payTxFee.GetFeePerK() > 0) {
736+
dFeeVary = (double)std::max(CWallet::GetRequiredFee(1000), payTxFee.GetFeePerK()) / 1000;
737+
} else {
738+
dFeeVary = (double)std::max(CWallet::GetRequiredFee(1000), mempool.estimateFee(nTxConfirmTarget).GetFeePerK()) / 1000;
739+
}
740+
739741
QString toolTip4 = tr("Can vary +/- %1 upiv per input.").arg(dFeeVary);
740742

741743
l3->setToolTip(toolTip4);

src/qt/optionsmodel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ QVariant OptionsModel::data(const QModelIndex& index, int role) const
269269
case fUseCustomFee:
270270
return QVariant((pwalletMain) ? pwalletMain->fUseCustomFee : false);
271271
case nCustomFee:
272-
return QVariant(static_cast<qlonglong>((pwalletMain) ? pwalletMain->nCustomFee : CWallet::minTxFee.GetFeePerK()));
272+
return QVariant(static_cast<qlonglong>((pwalletMain) ? pwalletMain->nCustomFee : CWallet::GetRequiredFee(1000)));
273273
#endif
274274
case DisplayUnit:
275275
return nDisplayUnit;

src/qt/pivx/sendcustomfeedialog.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,9 @@ void SendCustomFeeDialog::accept()
125125
if (customFee >= insaneFee) {
126126
inform(tr("Fee too high. Must be below: %1").arg(
127127
BitcoinUnits::formatWithUnit(walletModel->getOptionsModel()->getDisplayUnit(), insaneFee)));
128-
} else if (customFee < CWallet::minTxFee.GetFeePerK()) {
128+
} else if (customFee < CWallet::GetRequiredFee(1000)) {
129129
inform(tr("Fee too low. Must be at least: %1").arg(
130-
BitcoinUnits::formatWithUnit(walletModel->getOptionsModel()->getDisplayUnit(), CWallet::minTxFee.GetFeePerK())));
130+
BitcoinUnits::formatWithUnit(walletModel->getOptionsModel()->getDisplayUnit(), CWallet::GetRequiredFee(1000))));
131131
} else {
132132
walletModel->setWalletCustomFee(fUseCustomFee, customFee);
133133
QDialog::accept();

src/wallet/wallet.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2803,6 +2803,11 @@ bool CWallet::AddAccountingEntry(const CAccountingEntry& acentry, CWalletDB & pw
28032803
return true;
28042804
}
28052805

2806+
CAmount CWallet::GetRequiredFee(unsigned int nTxBytes)
2807+
{
2808+
return std::max(minTxFee.GetFee(nTxBytes), ::minRelayTxFee.GetFee(nTxBytes));
2809+
}
2810+
28062811
CAmount CWallet::GetMinimumFee(unsigned int nTxBytes, unsigned int nConfirmTarget, const CTxMemPool& pool)
28072812
{
28082813
// payTxFee is user-set "I want to pay this much"
@@ -2811,9 +2816,9 @@ CAmount CWallet::GetMinimumFee(unsigned int nTxBytes, unsigned int nConfirmTarge
28112816
if (nFeeNeeded == 0)
28122817
nFeeNeeded = pool.estimateFee(nConfirmTarget).GetFee(nTxBytes);
28132818
// ... unless we don't have enough mempool data, in which case fall
2814-
// back to a hard-coded fee
2819+
// back to the required fee
28152820
if (nFeeNeeded == 0)
2816-
nFeeNeeded = minTxFee.GetFee(nTxBytes);
2821+
nFeeNeeded = GetRequiredFee(nTxBytes);
28172822
// prevent user from paying a non-sense fee (like 1 satoshi): 0 < fee < minRelayFee
28182823
if (nFeeNeeded < ::minRelayTxFee.GetFee(nTxBytes))
28192824
nFeeNeeded = ::minRelayTxFee.GetFee(nTxBytes);

src/wallet/wallet.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,16 @@ class CWallet : public CCryptoKeyStore, public CValidationInterface
481481
void AutoCombineDust();
482482

483483
static CFeeRate minTxFee;
484+
/**
485+
* Estimate the minimum fee considering user set parameters
486+
* and the required fee
487+
*/
484488
static CAmount GetMinimumFee(unsigned int nTxBytes, unsigned int nConfirmTarget, const CTxMemPool& pool);
489+
/**
490+
* Return the minimum required fee taking into account the
491+
* floating relay fee and user set minimum transaction fee
492+
*/
493+
static CAmount GetRequiredFee(unsigned int nTxBytes);
485494

486495
size_t KeypoolCountExternalKeys();
487496
bool TopUpKeyPool(unsigned int kpSize = 0);

0 commit comments

Comments
 (0)