Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/wallet.cpp
Show First 20 Lines • Show All 2,926 Lines • ▼ Show 20 Lines | assert(txNew.nLockTime < LOCKTIME_THRESHOLD); | ||||
// Allow to override the default confirmation target over the | // Allow to override the default confirmation target over the | ||||
// CoinControl instance. | // CoinControl instance. | ||||
int currentConfirmationTarget = nTxConfirmTarget; | int currentConfirmationTarget = nTxConfirmTarget; | ||||
if (coinControl && coinControl->nConfirmTarget > 0) { | if (coinControl && coinControl->nConfirmTarget > 0) { | ||||
currentConfirmationTarget = coinControl->nConfirmTarget; | currentConfirmationTarget = coinControl->nConfirmTarget; | ||||
} | } | ||||
Amount nFeeNeeded = | Amount nFeeNeeded = GetMinimumFee( | ||||
GetMinimumFee(nBytes, currentConfirmationTarget, mempool); | GetConfig(), nBytes, CTransaction(txNew).GetNetOutputs(), | ||||
currentConfirmationTarget, mempool); | |||||
if (coinControl && nFeeNeeded > Amount(0) && | if (coinControl && nFeeNeeded > Amount(0) && | ||||
coinControl->nMinimumTotalFee > nFeeNeeded) { | coinControl->nMinimumTotalFee > nFeeNeeded) { | ||||
nFeeNeeded = coinControl->nMinimumTotalFee; | nFeeNeeded = coinControl->nMinimumTotalFee; | ||||
} | } | ||||
if (coinControl && coinControl->fOverrideFeeRate) { | if (coinControl && coinControl->fOverrideFeeRate) { | ||||
nFeeNeeded = coinControl->nFeeRate.GetFee(nBytes); | nFeeNeeded = coinControl->nFeeRate.GetFee(nBytes); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 176 Lines • ▼ Show 20 Lines | bool CWallet::AddAccountingEntry(const CAccountingEntry &acentry, | ||||
laccentries.push_back(acentry); | laccentries.push_back(acentry); | ||||
CAccountingEntry &entry = laccentries.back(); | CAccountingEntry &entry = laccentries.back(); | ||||
wtxOrdered.insert(std::make_pair(entry.nOrderPos, TxPair(nullptr, &entry))); | wtxOrdered.insert(std::make_pair(entry.nOrderPos, TxPair(nullptr, &entry))); | ||||
return true; | return true; | ||||
} | } | ||||
Amount CWallet::GetRequiredFee(unsigned int nTxBytes) { | Amount CWallet::GetRequiredFee(size_t nTxBytes) { | ||||
return std::max(minTxFee.GetFee(nTxBytes), | return std::max(minTxFee.GetFee(nTxBytes), | ||||
::minRelayTxFee.GetFee(nTxBytes)); | ::minRelayTxFee.GetFee(nTxBytes)); | ||||
} | } | ||||
Amount CWallet::GetMinimumFee(unsigned int nTxBytes, | Amount CWallet::GetMinimumFee(const Config &config, size_t nTxBytes, | ||||
unsigned int nConfirmTarget, | int64_t netOuts, 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(config, nTxBytes, netOuts, nConfirmTarget, pool, | ||||
payTxFee.GetFee(nTxBytes)); | payTxFee.GetFee(nTxBytes)); | ||||
} | } | ||||
Amount CWallet::GetMinimumFee(unsigned int nTxBytes, | Amount CWallet::GetMinimumFee(const Config &config, size_t nTxBytes, | ||||
unsigned int nConfirmTarget, | int64_t netOuts, 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(0)) { | if (nFeeNeeded == Amount(0)) { | ||||
int estimateFoundTarget = nConfirmTarget; | nFeeNeeded = pool.estimateFee(config, nConfirmTarget, nTxBytes, netOuts) | ||||
nFeeNeeded = pool.estimateSmartFee(nConfirmTarget, &estimateFoundTarget) | |||||
.GetFee(nTxBytes); | .GetFee(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(0)) { | if (nFeeNeeded == Amount(0)) { | ||||
nFeeNeeded = fallbackFee.GetFee(nTxBytes); | nFeeNeeded = fallbackFee.GetFee(nTxBytes); | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,414 Lines • Show Last 20 Lines |