Skip to content

Commit 7d05645

Browse files
committed
Merge pull request #4465
d88af56 Fee fixes (Cozz Lovan)
2 parents 1fedd65 + d88af56 commit 7d05645

File tree

4 files changed

+24
-10
lines changed

4 files changed

+24
-10
lines changed

src/core.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,12 @@ CFeeRate::CFeeRate(int64_t nFeePaid, size_t nSize)
8282

8383
int64_t CFeeRate::GetFee(size_t nSize) const
8484
{
85-
return nSatoshisPerK*nSize / 1000;
85+
int64_t nFee = nSatoshisPerK*nSize / 1000;
86+
87+
if (nFee == 0 && nSatoshisPerK > 0)
88+
nFee = nSatoshisPerK;
89+
90+
return nFee;
8691
}
8792

8893
std::string CFeeRate::ToString() const

src/init.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,8 @@ std::string HelpMessage(HelpMessageMode mode)
253253
#ifdef ENABLE_WALLET
254254
strUsage += "\n" + _("Wallet options:") + "\n";
255255
strUsage += " -disablewallet " + _("Do not load the wallet and disable wallet RPC calls") + "\n";
256-
strUsage += " -mintxfee=<amt> " + strprintf(_("Fees (in BTC/Kb) smaller than this are considered zero fee for transaction creation (default: %s)"), FormatMoney(CWallet::minTxFee.GetFeePerK())) + "\n";
256+
if (GetBoolArg("-help-debug", false))
257+
strUsage += " -mintxfee=<amt> " + strprintf(_("Fees (in BTC/Kb) smaller than this are considered zero fee for transaction creation (default: %s)"), FormatMoney(CWallet::minTxFee.GetFeePerK())) + "\n";
257258
strUsage += " -paytxfee=<amt> " + strprintf(_("Fee (in BTC/kB) to add to transactions you send (default: %s)"), FormatMoney(payTxFee.GetFeePerK())) + "\n";
258259
strUsage += " -rescan " + _("Rescan the block chain for missing wallet transactions") + " " + _("on startup") + "\n";
259260
strUsage += " -respendnotify=<cmd> " + _("Execute command when a network tx respends wallet tx input (%s=respend TxID, %t=wallet TxID)") + "\n";

src/qt/coincontroldialog.cpp

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,8 @@ QString CoinControlDialog::getPriorityLabel(const CTxMemPool& pool, double dPrio
419419
}
420420
// Note: if mempool hasn't accumulated enough history (estimatePriority
421421
// returns -1) we're conservative and classify as "lowest"
422+
if (mempool.estimatePriority(nTxConfirmTarget) <= 0 && AllowFree(dPriority))
423+
return ">=" + tr("medium");
422424
return tr("lowest");
423425
}
424426

@@ -523,15 +525,21 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
523525
dPriority = dPriorityInputs / (nBytes - nBytesInputs + (nQuantityUncompressed * 29)); // 29 = 180 - 151 (uncompressed public keys are over the limit. max 151 bytes of the input are ignored for priority)
524526
sPriorityLabel = CoinControlDialog::getPriorityLabel(mempool, dPriority);
525527

528+
// Voluntary Fee
529+
nPayFee = payTxFee.GetFee(max((unsigned int)1000, nBytes));
530+
526531
// Min Fee
527-
nPayFee = CWallet::GetMinimumFee(nBytes, nTxConfirmTarget, mempool);
532+
if (nPayFee == 0)
533+
{
534+
nPayFee = CWallet::GetMinimumFee(nBytes, nTxConfirmTarget, mempool);
528535

529-
double dPriorityNeeded = mempool.estimatePriority(nTxConfirmTarget);
530-
if (dPriorityNeeded <= 0) // Not enough mempool history: never send free
531-
dPriorityNeeded = std::numeric_limits<double>::max();
536+
double dPriorityNeeded = mempool.estimatePriority(nTxConfirmTarget);
537+
if (dPriorityNeeded <= 0 && !AllowFree(dPriority)) // not enough mempool history: never send free
538+
dPriorityNeeded = std::numeric_limits<double>::max();
532539

533-
if (nBytes <= MAX_FREE_TRANSACTION_CREATE_SIZE && dPriority >= dPriorityNeeded)
534-
nPayFee = 0;
540+
if (nBytes <= MAX_FREE_TRANSACTION_CREATE_SIZE && dPriority >= dPriorityNeeded)
541+
nPayFee = 0;
542+
}
535543

536544
if (nPayAmount > 0)
537545
{
@@ -612,7 +620,7 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
612620
QString toolTip3 = tr("This label turns red, if any recipient receives an amount smaller than %1.").arg(BitcoinUnits::formatWithUnit(nDisplayUnit, ::minRelayTxFee.GetFee(546)));
613621

614622
// how many satoshis the estimated fee can vary per byte we guess wrong
615-
double dFeeVary = (double)std::max(CWallet::minTxFee.GetFeePerK(), payTxFee.GetFeePerK()) / 1000;
623+
double dFeeVary = (double)std::max(CWallet::minTxFee.GetFeePerK(), std::max(payTxFee.GetFeePerK(), mempool.estimateFee(nTxConfirmTarget).GetFeePerK())) / 1000;
616624
QString toolTip4 = tr("Can vary +/- %1 satoshi(s) per input.").arg(dFeeVary);
617625

618626
l3->setToolTip(toolTip4);

src/wallet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1484,7 +1484,7 @@ bool CWallet::CreateTransaction(const vector<pair<CScript, int64_t> >& vecSend,
14841484
break;
14851485

14861486
// Small enough, and priority high enough, to send for free
1487-
if (dPriority >= dPriorityNeeded)
1487+
if (dPriorityNeeded > 0 && dPriority >= dPriorityNeeded)
14881488
break;
14891489

14901490
// Include more fee and try again.

0 commit comments

Comments
 (0)