Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/wallet.cpp
Show First 20 Lines • Show All 3,062 Lines • ▼ Show 20 Lines | assert(txNew.nLockTime < LOCKTIME_THRESHOLD); | ||||
dPriority = txNewConst.ComputePriority(dPriority, nBytes); | dPriority = txNewConst.ComputePriority(dPriority, nBytes); | ||||
// Remove scriptSigs to eliminate the fee calculation dummy | // Remove scriptSigs to eliminate the fee calculation dummy | ||||
// signatures. | // signatures. | ||||
for (auto &vin : txNew.vin) { | for (auto &vin : txNew.vin) { | ||||
vin.scriptSig = CScript(); | vin.scriptSig = CScript(); | ||||
} | } | ||||
Amount nFeeNeeded = GetMinimumFee(nBytes, g_mempool); | // Allow to override the default confirmation target over the | ||||
// CoinControl instance. | |||||
int currentConfirmationTarget = nTxConfirmTarget; | |||||
if (coinControl && coinControl->nConfirmTarget > 0) { | |||||
currentConfirmationTarget = coinControl->nConfirmTarget; | |||||
} | |||||
Amount nFeeNeeded = | |||||
GetMinimumFee(nBytes, currentConfirmationTarget, g_mempool); | |||||
if (coinControl && coinControl->fOverrideFeeRate) { | if (coinControl && coinControl->fOverrideFeeRate) { | ||||
nFeeNeeded = coinControl->nFeeRate.GetFeeCeiling(nBytes); | nFeeNeeded = coinControl->nFeeRate.GetFeeCeiling(nBytes); | ||||
} | } | ||||
// If we made it here and we aren't even able to meet the relay fee | // If we made it here and we aren't even able to meet the relay fee | ||||
// on the next pass, give up because we must be at the maximum | // on the next pass, give up because we must be at the maximum | ||||
// allowed fee. | // allowed fee. | ||||
Amount minFee = GetConfig().GetMinFeePerKB().GetFeeCeiling(nBytes); | Amount minFee = GetConfig().GetMinFeePerKB().GetFeeCeiling(nBytes); | ||||
Show All 13 Lines | assert(txNew.nLockTime < LOCKTIME_THRESHOLD); | ||||
// and not the change output. | // and not the change output. | ||||
// If we have no change and a big enough excess fee, then try to | // If we have no change and a big enough excess fee, then try to | ||||
// construct transaction again only without picking new inputs. | // construct transaction again only without picking new inputs. | ||||
// We now know we only need the smaller fee (because of reduced | // We now know we only need the smaller fee (because of reduced | ||||
// tx size) and so we should add a change output. Only try this | // tx size) and so we should add a change output. Only try this | ||||
// once. | // once. | ||||
Amount fee_needed_for_change = | Amount fee_needed_for_change = | ||||
GetMinimumFee(change_prototype_size, g_mempool); | GetMinimumFee(change_prototype_size, | ||||
currentConfirmationTarget, g_mempool); | |||||
Amount minimum_value_for_change = | Amount minimum_value_for_change = | ||||
change_prototype_txout.GetDustThreshold(dustRelayFee); | change_prototype_txout.GetDustThreshold(dustRelayFee); | ||||
Amount max_excess_fee = | Amount max_excess_fee = | ||||
fee_needed_for_change + minimum_value_for_change; | fee_needed_for_change + minimum_value_for_change; | ||||
if (nFeeRet > nFeeNeeded + max_excess_fee && | if (nFeeRet > nFeeNeeded + max_excess_fee && | ||||
nChangePosInOut == -1 && nSubtractFeeFromAmount == 0 && | nChangePosInOut == -1 && nSubtractFeeFromAmount == 0 && | ||||
pick_new_inputs) { | pick_new_inputs) { | ||||
pick_new_inputs = false; | pick_new_inputs = false; | ||||
▲ Show 20 Lines • Show All 1,334 Lines • Show Last 20 Lines |