Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/fees.cpp
Show All 12 Lines | |||||
#include "wallet/coincontrol.h" | #include "wallet/coincontrol.h" | ||||
#include "wallet/wallet.h" | #include "wallet/wallet.h" | ||||
Amount GetMinimumFee(unsigned int nTxBytes, unsigned int nConfirmTarget, | Amount GetMinimumFee(unsigned int nTxBytes, unsigned int nConfirmTarget, | ||||
const CTxMemPool &pool, Amount targetFee) { | const CTxMemPool &pool, Amount targetFee) { | ||||
Amount nFeeNeeded = targetFee; | Amount nFeeNeeded = targetFee; | ||||
// User didn't set: use -txconfirmtarget to estimate... | // User didn't set: use -txconfirmtarget to estimate... | ||||
if (nFeeNeeded == Amount::zero()) { | if (nFeeNeeded == Amount::zero()) { | ||||
int estimateFoundTarget = nConfirmTarget; | nFeeNeeded = pool.estimateFee(nConfirmTarget).GetFeeCeiling(nTxBytes); | ||||
nFeeNeeded = pool.estimateSmartFee(nConfirmTarget, &estimateFoundTarget) | |||||
.GetFeeCeiling(nTxBytes); | |||||
// ... unless we don't have enough mempool data for estimatefee, then | // ... unless we don't have enough mempool data for estimatefee, then | ||||
// use fallbackFee. | // use fallbackFee. | ||||
if (nFeeNeeded == Amount::zero()) { | if (nFeeNeeded == Amount::zero()) { | ||||
nFeeNeeded = CWallet::fallbackFee.GetFeeCeiling(nTxBytes); | nFeeNeeded = CWallet::fallbackFee.GetFeeCeiling(nTxBytes); | ||||
} | } | ||||
} | } | ||||
// Prevent user from paying a fee below minRelayTxFee or minTxFee. | // Prevent user from paying a fee below minRelayTxFee or minTxFee. | ||||
nFeeNeeded = | nFeeNeeded = | ||||
std::max(nFeeNeeded, GetConfig().GetMinFeePerKB().GetFee(nTxBytes)); | std::max(nFeeNeeded, GetConfig().GetMinFeePerKB().GetFee(nTxBytes)); | ||||
// But always obey the maximum. | // But always obey the maximum. | ||||
if (nFeeNeeded > maxTxFee) { | if (nFeeNeeded > maxTxFee) { | ||||
nFeeNeeded = maxTxFee; | nFeeNeeded = maxTxFee; | ||||
} | } | ||||
return nFeeNeeded; | return nFeeNeeded; | ||||
} | } | ||||
Amount GetMinimumFee(unsigned int nTxBytes, unsigned int nConfirmTarget, | Amount GetMinimumFee(unsigned int nTxBytes, unsigned int nConfirmTarget, | ||||
const CTxMemPool &pool) { | const CTxMemPool &pool) { | ||||
// payTxFee is the user-set global for desired feerate. | // payTxFee is the user-set global for desired feerate. | ||||
return GetMinimumFee(nTxBytes, nConfirmTarget, pool, | return GetMinimumFee(nTxBytes, nConfirmTarget, pool, | ||||
payTxFee.GetFeeCeiling(nTxBytes)); | payTxFee.GetFeeCeiling(nTxBytes)); | ||||
} | } | ||||
No newline at end of file |