Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/wallet.cpp
Show First 20 Lines • Show All 2,940 Lines • ▼ Show 20 Lines | assert(txNew.nLockTime < LOCKTIME_THRESHOLD); | ||||
if (coinControl && coinControl->fOverrideFeeRate) { | if (coinControl && coinControl->fOverrideFeeRate) { | ||||
nFeeNeeded = coinControl->nFeeRate.GetFee(nBytes); | nFeeNeeded = coinControl->nFeeRate.GetFee(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. | ||||
if (nFeeNeeded < ::minRelayTxFee.GetFee(nBytes)) { | Amount minFee = GetConfig().GetMinFeePerKB().GetFee(nBytes); | ||||
jasonbcox: I know the old code didn't do this, but I think we should start differentiating between fee and… | |||||
schancelAuthorUnsubmitted Not Done Inline ActionsNot going to do it in this diff, but yes I intend to clean that stuff up once I simplify the fee insanity. schancel: Not going to do it in this diff, but yes I intend to clean that stuff up once I simplify the… | |||||
jasonbcoxUnsubmitted Not Done Inline ActionsGreat, thanks! jasonbcox: Great, thanks! | |||||
if (nFeeNeeded < minFee) { | |||||
strFailReason = _("Transaction too large for fee policy"); | strFailReason = _("Transaction too large for fee policy"); | ||||
return false; | return false; | ||||
} | } | ||||
if (nFeeRet >= nFeeNeeded) { | if (nFeeRet >= nFeeNeeded) { | ||||
// Reduce fee to only the needed amount if we have change output | // Reduce fee to only the needed amount if we have change output | ||||
// to increase. This prevents potential overpayment in fees if | // to increase. This prevents potential overpayment in fees if | ||||
// the coins selected to meet nFeeNeeded result in a transaction | // the coins selected to meet nFeeNeeded result in a transaction | ||||
▲ Show 20 Lines • Show All 165 Lines • ▼ Show 20 Lines | bool CWallet::AddAccountingEntry(const CAccountingEntry &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(unsigned int nTxBytes) { | ||||
return std::max(minTxFee.GetFee(nTxBytes), | return std::max(minTxFee.GetFee(nTxBytes), | ||||
::minRelayTxFee.GetFee(nTxBytes)); | GetConfig().GetMinFeePerKB().GetFee(nTxBytes)); | ||||
} | } | ||||
Amount CWallet::GetMinimumFee(unsigned int nTxBytes, | Amount CWallet::GetMinimumFee(unsigned int nTxBytes, | ||||
unsigned int nConfirmTarget, | 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.GetFee(nTxBytes)); | payTxFee.GetFee(nTxBytes)); | ||||
▲ Show 20 Lines • Show All 1,189 Lines • ▼ Show 20 Lines | void CWallet::postInitProcess(CScheduler &scheduler) { | ||||
// Run a thread to flush wallet periodically. | // Run a thread to flush wallet periodically. | ||||
if (!CWallet::fFlushScheduled.exchange(true)) { | if (!CWallet::fFlushScheduled.exchange(true)) { | ||||
scheduler.scheduleEvery(MaybeCompactWalletDB, 500); | scheduler.scheduleEvery(MaybeCompactWalletDB, 500); | ||||
} | } | ||||
} | } | ||||
bool CWallet::ParameterInteraction() { | bool CWallet::ParameterInteraction() { | ||||
CFeeRate minRelayTxFee = GetConfig().GetMinFeePerKB(); | |||||
gArgs.SoftSetArg("-wallet", DEFAULT_WALLET_DAT); | gArgs.SoftSetArg("-wallet", DEFAULT_WALLET_DAT); | ||||
const bool is_multiwallet = gArgs.GetArgs("-wallet").size() > 1; | const bool is_multiwallet = gArgs.GetArgs("-wallet").size() > 1; | ||||
if (gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET)) { | if (gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET)) { | ||||
return true; | return true; | ||||
} | } | ||||
if (gArgs.GetBoolArg("-blocksonly", DEFAULT_BLOCKSONLY) && | if (gArgs.GetBoolArg("-blocksonly", DEFAULT_BLOCKSONLY) && | ||||
▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | bool CWallet::ParameterInteraction() { | ||||
} | } | ||||
if (gArgs.GetArg("-prune", 0) && gArgs.GetBoolArg("-rescan", false)) { | if (gArgs.GetArg("-prune", 0) && gArgs.GetBoolArg("-rescan", false)) { | ||||
return InitError( | return InitError( | ||||
_("Rescans are not possible in pruned mode. You will need to use " | _("Rescans are not possible in pruned mode. You will need to use " | ||||
"-reindex which will download the whole blockchain again.")); | "-reindex which will download the whole blockchain again.")); | ||||
} | } | ||||
if (::minRelayTxFee.GetFeePerK() > HIGH_TX_FEE_PER_KB) { | if (minRelayTxFee.GetFeePerK() > HIGH_TX_FEE_PER_KB) { | ||||
InitWarning( | InitWarning( | ||||
AmountHighWarn("-minrelaytxfee") + " " + | AmountHighWarn("-minrelaytxfee") + " " + | ||||
_("The wallet will avoid paying less than the minimum relay fee.")); | _("The wallet will avoid paying less than the minimum relay fee.")); | ||||
} | } | ||||
if (gArgs.IsArgSet("-mintxfee")) { | if (gArgs.IsArgSet("-mintxfee")) { | ||||
Amount n(0); | Amount n(0); | ||||
auto parsed = ParseMoney(gArgs.GetArg("-mintxfee", ""), n); | auto parsed = ParseMoney(gArgs.GetArg("-mintxfee", ""), n); | ||||
Show All 37 Lines | if (gArgs.IsArgSet("-paytxfee")) { | ||||
if (nFeePerK > HIGH_TX_FEE_PER_KB) { | if (nFeePerK > HIGH_TX_FEE_PER_KB) { | ||||
InitWarning(AmountHighWarn("-paytxfee") + " " + | InitWarning(AmountHighWarn("-paytxfee") + " " + | ||||
_("This is the transaction fee you will pay if you " | _("This is the transaction fee you will pay if you " | ||||
"send a transaction.")); | "send a transaction.")); | ||||
} | } | ||||
payTxFee = CFeeRate(nFeePerK, 1000); | payTxFee = CFeeRate(nFeePerK, 1000); | ||||
if (payTxFee < ::minRelayTxFee) { | if (payTxFee < minRelayTxFee) { | ||||
return InitError(strprintf( | return InitError(strprintf( | ||||
_("Invalid amount for -paytxfee=<amount>: '%s' (must " | _("Invalid amount for -paytxfee=<amount>: '%s' (must " | ||||
"be at least %s)"), | "be at least %s)"), | ||||
gArgs.GetArg("-paytxfee", ""), ::minRelayTxFee.ToString())); | gArgs.GetArg("-paytxfee", ""), minRelayTxFee.ToString())); | ||||
} | } | ||||
} | } | ||||
if (gArgs.IsArgSet("-maxtxfee")) { | if (gArgs.IsArgSet("-maxtxfee")) { | ||||
Amount nMaxFee(0); | Amount nMaxFee(0); | ||||
if (!ParseMoney(gArgs.GetArg("-maxtxfee", ""), nMaxFee)) { | if (!ParseMoney(gArgs.GetArg("-maxtxfee", ""), nMaxFee)) { | ||||
return InitError( | return InitError( | ||||
AmountErrMsg("maxtxfee", gArgs.GetArg("-maxtxfee", ""))); | AmountErrMsg("maxtxfee", gArgs.GetArg("-maxtxfee", ""))); | ||||
} | } | ||||
if (nMaxFee > HIGH_MAX_TX_FEE) { | if (nMaxFee > HIGH_MAX_TX_FEE) { | ||||
InitWarning(_("-maxtxfee is set very high! Fees this large could " | InitWarning(_("-maxtxfee is set very high! Fees this large could " | ||||
"be paid on a single transaction.")); | "be paid on a single transaction.")); | ||||
} | } | ||||
maxTxFee = nMaxFee; | maxTxFee = nMaxFee; | ||||
if (CFeeRate(maxTxFee, 1000) < ::minRelayTxFee) { | if (CFeeRate(maxTxFee, 1000) < minRelayTxFee) { | ||||
return InitError(strprintf( | return InitError(strprintf( | ||||
_("Invalid amount for -maxtxfee=<amount>: '%s' (must " | _("Invalid amount for -maxtxfee=<amount>: '%s' (must " | ||||
"be at least the minrelay fee of %s to prevent " | "be at least the minrelay fee of %s to prevent " | ||||
"stuck transactions)"), | "stuck transactions)"), | ||||
gArgs.GetArg("-maxtxfee", ""), ::minRelayTxFee.ToString())); | gArgs.GetArg("-maxtxfee", ""), minRelayTxFee.ToString())); | ||||
} | } | ||||
} | } | ||||
nTxConfirmTarget = | nTxConfirmTarget = | ||||
gArgs.GetArg("-txconfirmtarget", DEFAULT_TX_CONFIRM_TARGET); | gArgs.GetArg("-txconfirmtarget", DEFAULT_TX_CONFIRM_TARGET); | ||||
bSpendZeroConfChange = | bSpendZeroConfChange = | ||||
gArgs.GetBoolArg("-spendzeroconfchange", DEFAULT_SPEND_ZEROCONF_CHANGE); | gArgs.GetBoolArg("-spendzeroconfchange", DEFAULT_SPEND_ZEROCONF_CHANGE); | ||||
fSendFreeTransactions = gArgs.GetBoolArg("-sendfreetransactions", | fSendFreeTransactions = gArgs.GetBoolArg("-sendfreetransactions", | ||||
▲ Show 20 Lines • Show All 75 Lines • Show Last 20 Lines |
I know the old code didn't do this, but I think we should start differentiating between fee and fee-rate. This minFee is a total fee, whereas most of the other variables in this diff are fee-rates. Can you update the variable names accordingly?