mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 23:18:14 +01:00
Merge pull request #7296
bebe58bSQUASHME: Fix rpc tests that assumed fallback to minRelayTxFee (Alex Morcos)e420a1bAdd sane fallback for fee estimation (Alex Morcos)995b9f3Always respect GetRequiredFee for wallet txs (Alex Morcos)
This commit is contained in:
@@ -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
|
||||
*
|
||||
@@ -2230,14 +2236,12 @@ 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 our desired target
|
||||
// so we make sure we're paying at least minTxFee
|
||||
if (nFeeNeeded == 0 || (unsigned int)estimateFoundTarget > nConfirmTarget)
|
||||
nFeeNeeded = std::max(nFeeNeeded, GetRequiredFee(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 non-sense fee (like 1 satoshi): 0 < fee < minRelayFee
|
||||
if (nFeeNeeded < ::minRelayTxFee.GetFee(nTxBytes))
|
||||
nFeeNeeded = ::minRelayTxFee.GetFee(nTxBytes);
|
||||
// prevent user from paying a fee below minRelayTxFee or minTxFee
|
||||
nFeeNeeded = std::max(nFeeNeeded, GetRequiredFee(nTxBytes));
|
||||
// But always obey the maximum
|
||||
if (nFeeNeeded > maxTxFee)
|
||||
nFeeNeeded = maxTxFee;
|
||||
|
||||
Reference in New Issue
Block a user