From e255b2c27872eb3163ec9700fcc19e77535378eb Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Sun, 25 Oct 2015 02:47:04 +0200 Subject: [PATCH] [qt] Properly display required fee instead of minTxFee Zcash: Only includes non-QT parts --- src/wallet/wallet.cpp | 9 +++++++-- src/wallet/wallet.h | 9 +++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index d71e54cb7..6a4a6a9be 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -3636,6 +3636,11 @@ bool CWallet::CommitTransaction(CWalletTx& wtxNew, boost::optional return true; } +CAmount CWallet::GetRequiredFee(unsigned int nTxBytes) +{ + return std::max(minTxFee.GetFee(nTxBytes), ::minRelayTxFee.GetFee(nTxBytes)); +} + CAmount CWallet::GetMinimumFee(unsigned int nTxBytes, unsigned int nConfirmTarget, const CTxMemPool& pool) { // payTxFee is user-set "I want to pay this much" @@ -3647,9 +3652,9 @@ CAmount CWallet::GetMinimumFee(unsigned int nTxBytes, unsigned int nConfirmTarge if (nFeeNeeded == 0) nFeeNeeded = pool.estimateFee(nConfirmTarget).GetFee(nTxBytes); // ... unless we don't have enough mempool data, in which case fall - // back to a hard-coded fee + // back to the required fee if (nFeeNeeded == 0) - nFeeNeeded = minTxFee.GetFee(nTxBytes); + nFeeNeeded = GetRequiredFee(nTxBytes); // prevent user from paying a non-sense fee (like 1 satoshi): 0 < fee < minRelayFee if (nFeeNeeded < ::minRelayTxFee.GetFee(nTxBytes)) nFeeNeeded = ::minRelayTxFee.GetFee(nTxBytes); diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 291e2c239..58d359e52 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -1176,7 +1176,16 @@ public: bool CommitTransaction(CWalletTx& wtxNew, boost::optional reservekey); static CFeeRate minTxFee; + /** + * Estimate the minimum fee considering user set parameters + * and the required fee + */ static CAmount GetMinimumFee(unsigned int nTxBytes, unsigned int nConfirmTarget, const CTxMemPool& pool); + /** + * Return the minimum required fee taking into account the + * floating relay fee and user set minimum transaction fee + */ + static CAmount GetRequiredFee(unsigned int nTxBytes); bool NewKeyPool(); bool TopUpKeyPool(unsigned int kpSize = 0);