aboutsummaryrefslogtreecommitdiff
path: root/src/wallet
diff options
context:
space:
mode:
authorAlex Morcos <morcos@chaincode.com>2016-01-05 13:11:34 -0500
committerAlex Morcos <morcos@chaincode.com>2016-01-05 13:13:23 -0500
commite420a1b15e3be8c9d862173d9d554563405b34a7 (patch)
tree13af0732d92b76ab8279d9632b797f3ce3ec7aa9 /src/wallet
parent995b9f385b935e4e9b9fa46e82f642204cc85cba (diff)
downloadbitcoin-e420a1b15e3be8c9d862173d9d554563405b34a7.tar.xz
Add sane fallback for fee estimation
Add new commandline option "-fallbackfee" to use when fee estimation does not have sufficient data.
Diffstat (limited to 'src/wallet')
-rw-r--r--src/wallet/wallet.cpp9
-rw-r--r--src/wallet/wallet.h3
2 files changed, 12 insertions, 0 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index 244bc37e76..581c688fc7 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -47,6 +47,12 @@ bool fSendFreeTransactions = DEFAULT_SEND_FREE_TRANSACTIONS;
* Override with -mintxfee
*/
CFeeRate CWallet::minTxFee = CFeeRate(DEFAULT_TRANSACTION_MINFEE);
+/**
+ * If fee estimation does not have enough data to provide estimates, use this fee instead.
+ * Has no effect if not using fee estimation
+ * Override with -fallbackfee
+ */
+CFeeRate CWallet::fallbackFee = CFeeRate(DEFAULT_FALLBACK_FEE);
/** @defgroup mapWallet
*
@@ -2223,6 +2229,9 @@ CAmount CWallet::GetMinimumFee(unsigned int nTxBytes, unsigned int nConfirmTarge
if (nFeeNeeded == 0) {
int estimateFoundTarget = nConfirmTarget;
nFeeNeeded = pool.estimateSmartFee(nConfirmTarget, &estimateFoundTarget).GetFee(nTxBytes);
+ // ... unless we don't have enough mempool data for estimatefee, then use fallbackFee
+ if (nFeeNeeded == 0)
+ nFeeNeeded = fallbackFee.GetFee(nTxBytes);
}
// prevent user from paying a fee below minRelayTxFee or minTxFee
nFeeNeeded = std::max(nFeeNeeded, GetRequiredFee(nTxBytes));
diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h
index 53a2b96690..ce57f4dae1 100644
--- a/src/wallet/wallet.h
+++ b/src/wallet/wallet.h
@@ -41,6 +41,8 @@ static const unsigned int DEFAULT_KEYPOOL_SIZE = 100;
static const CAmount DEFAULT_TRANSACTION_FEE = 0;
//! -paytxfee will warn if called with a higher fee than this amount (in satoshis) per KB
static const CAmount nHighTransactionFeeWarning = 0.01 * COIN;
+//! -fallbackfee default
+static const CAmount DEFAULT_FALLBACK_FEE = 20000;
//! -mintxfee default
static const CAmount DEFAULT_TRANSACTION_MINFEE = 1000;
//! -maxtxfee default
@@ -666,6 +668,7 @@ public:
bool AddAccountingEntry(const CAccountingEntry&, CWalletDB & pwalletdb);
static CFeeRate minTxFee;
+ static CFeeRate fallbackFee;
/**
* Estimate the minimum fee considering user set parameters
* and the required fee