wallet: Replace nFeeRateNeeded with effective_fee

Make sure that all fee calculations use the same feerate.
coin_selection_params.effective_fee is the variable we use for all fee
calculations, so get rid of remaining nFeeRateNeeded usages and just
directly set coin_selection_params.effective_fee.

Does not change behavior.
This commit is contained in:
Andrew Chow committed 2021-03-16 12:32:56 -04:00
1 parent 1a6a0b0dfb
commit e2f429e6bb
1 file changed
+3 -4
+3 -4
View File
@@ -2807,11 +2807,11 @@ bool CWallet::CreateTransactionInternal(
CFeeRate discard_rate = GetDiscardRate(*this); CFeeRate discard_rate = GetDiscardRate(*this);
// Get the fee rate to use effective values in coin selection // Get the fee rate to use effective values in coin selection
CFeeRate nFeeRateNeeded = GetMinimumFeeRate(*this, coin_control, &feeCalc); coin_selection_params.effective_fee = GetMinimumFeeRate(*this, coin_control, &feeCalc);
// Do not, ever, assume that it's fine to change the fee rate if the user has explicitly // Do not, ever, assume that it's fine to change the fee rate if the user has explicitly
// provided one // provided one
if (coin_control.m_feerate && nFeeRateNeeded > *coin_control.m_feerate) { if (coin_control.m_feerate && coin_selection_params.effective_fee > *coin_control.m_feerate) {
error = strprintf(_("Fee rate (%s) is lower than the minimum fee rate setting (%s)"), coin_control.m_feerate->ToString(FeeEstimateMode::SAT_VB), nFeeRateNeeded.ToString(FeeEstimateMode::SAT_VB)); error = strprintf(_("Fee rate (%s) is lower than the minimum fee rate setting (%s)"), coin_control.m_feerate->ToString(FeeEstimateMode::SAT_VB), coin_selection_params.effective_fee.ToString(FeeEstimateMode::SAT_VB));
return false; return false;
} }
if (feeCalc.reason == FeeReason::FALLBACK && !m_allow_fallback_fee) { if (feeCalc.reason == FeeReason::FALLBACK && !m_allow_fallback_fee) {
@@ -2893,7 +2893,6 @@ bool CWallet::CreateTransactionInternal(
} else { } else {
coin_selection_params.change_spend_size = (size_t)change_spend_size; coin_selection_params.change_spend_size = (size_t)change_spend_size;
} }
coin_selection_params.effective_fee = nFeeRateNeeded;
if (!SelectCoins(vAvailableCoins, nValueToSelect, setCoins, nValueIn, coin_control, coin_selection_params, bnb_used)) if (!SelectCoins(vAvailableCoins, nValueToSelect, setCoins, nValueIn, coin_control, coin_selection_params, bnb_used))
{ {
// If BnB was used, it was the first pass. No longer the first pass and continue loop with knapsack. // If BnB was used, it was the first pass. No longer the first pass and continue loop with knapsack.