Skip to content

Commit f9cd2bf

Browse files
committed
Rename CoinSelectionParams::effective_fee to m_effective_feerate
It's a feerate, not a fee. Also follow the style guide for member names.
1 parent bdd0c29 commit f9cd2bf

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

src/bench/coin_selection.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ static void CoinSelection(benchmark::Bench& bench)
5050

5151
const CoinEligibilityFilter filter_standard(1, 6, 0);
5252
const CoinSelectionParams coin_selection_params(/* use_bnb= */ true, /* change_output_size= */ 34,
53-
/* change_spend_size= */ 148, /* effective_fee= */ CFeeRate(0),
53+
/* change_spend_size= */ 148, /* effective_feerate= */ CFeeRate(0),
5454
/* long_term_feerate= */ CFeeRate(0), /* discard_feerate= */ CFeeRate(0),
5555
/* tx_no_inputs_size= */ 0, /* avoid_partial= */ false);
5656
bench.run([&] {

src/wallet/test/coinselector_tests.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ CoinEligibilityFilter filter_standard(1, 6, 0);
3636
CoinEligibilityFilter filter_confirmed(1, 1, 0);
3737
CoinEligibilityFilter filter_standard_extra(6, 6, 0);
3838
CoinSelectionParams coin_selection_params(/* use_bnb= */ false, /* change_output_size= */ 0,
39-
/* change_spend_size= */ 0, /* effective_fee= */ CFeeRate(0),
39+
/* change_spend_size= */ 0, /* effective_feerate= */ CFeeRate(0),
4040
/* long_term_feerate= */ CFeeRate(0), /* discard_feerate= */ CFeeRate(0),
4141
/* tx_no_inputs_size= */ 0, /* avoid_partial= */ false);
4242

@@ -273,7 +273,7 @@ BOOST_AUTO_TEST_CASE(bnb_search_test)
273273

274274
// Make sure that effective value is working in SelectCoinsMinConf when BnB is used
275275
CoinSelectionParams coin_selection_params_bnb(/* use_bnb= */ true, /* change_output_size= */ 0,
276-
/* change_spend_size= */ 0, /* effective_fee= */ CFeeRate(3000),
276+
/* change_spend_size= */ 0, /* effective_feerate= */ CFeeRate(3000),
277277
/* long_term_feerate= */ CFeeRate(1000), /* discard_feerate= */ CFeeRate(1000),
278278
/* tx_no_inputs_size= */ 0, /* avoid_partial= */ false);
279279
CoinSet setCoinsRet;
@@ -307,7 +307,7 @@ BOOST_AUTO_TEST_CASE(bnb_search_test)
307307
CCoinControl coin_control;
308308
coin_control.fAllowOtherInputs = true;
309309
coin_control.Select(COutPoint(vCoins.at(0).tx->GetHash(), vCoins.at(0).i));
310-
coin_selection_params_bnb.effective_fee = CFeeRate(0);
310+
coin_selection_params_bnb.m_effective_feerate = CFeeRate(0);
311311
BOOST_CHECK(wallet->SelectCoins(vCoins, 10 * CENT, setCoinsRet, nValueRet, coin_control, coin_selection_params_bnb, bnb_used));
312312
BOOST_CHECK(bnb_used);
313313
BOOST_CHECK(coin_selection_params_bnb.use_bnb);
@@ -646,11 +646,11 @@ BOOST_AUTO_TEST_CASE(SelectCoins_test)
646646

647647
// Perform selection
648648
CoinSelectionParams coin_selection_params_knapsack(/* use_bnb= */ false, /* change_output_size= */ 34,
649-
/* change_spend_size= */ 148, /* effective_fee= */ CFeeRate(0),
649+
/* change_spend_size= */ 148, /* effective_feerate= */ CFeeRate(0),
650650
/* long_term_feerate= */ CFeeRate(0), /* discard_feerate= */ CFeeRate(0),
651651
/* tx_no_inputs_size= */ 0, /* avoid_partial= */ false);
652652
CoinSelectionParams coin_selection_params_bnb(/* use_bnb= */ true, /* change_output_size= */ 34,
653-
/* change_spend_size= */ 148, /* effective_fee= */ CFeeRate(0),
653+
/* change_spend_size= */ 148, /* effective_feerate= */ CFeeRate(0),
654654
/* long_term_feerate= */ CFeeRate(0), /* discard_feerate= */ CFeeRate(0),
655655
/* tx_no_inputs_size= */ 0, /* avoid_partial= */ false);
656656
CoinSet out_set;

src/wallet/wallet.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2368,16 +2368,16 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, const CoinEligibil
23682368
// When subtracting the fee from the outputs, we want the effective feerate to be 0
23692369
CFeeRate effective_feerate{0};
23702370
if (!coin_selection_params.m_subtract_fee_outputs) {
2371-
effective_feerate = coin_selection_params.effective_fee;
2371+
effective_feerate = coin_selection_params.m_effective_feerate;
23722372
}
23732373

23742374
std::vector<OutputGroup> groups = GroupOutputs(coins, !coin_selection_params.m_avoid_partial_spends, effective_feerate, coin_selection_params.m_long_term_feerate, eligibility_filter, true /* positive_only */);
23752375

23762376
// Calculate cost of change
2377-
CAmount cost_of_change = coin_selection_params.m_discard_feerate.GetFee(coin_selection_params.change_spend_size) + coin_selection_params.effective_fee.GetFee(coin_selection_params.change_output_size);
2377+
CAmount cost_of_change = coin_selection_params.m_discard_feerate.GetFee(coin_selection_params.change_spend_size) + coin_selection_params.m_effective_feerate.GetFee(coin_selection_params.change_output_size);
23782378

23792379
// Calculate the fees for things that aren't inputs
2380-
CAmount not_input_fees = coin_selection_params.effective_fee.GetFee(coin_selection_params.tx_noinputs_size);
2380+
CAmount not_input_fees = coin_selection_params.m_effective_feerate.GetFee(coin_selection_params.tx_noinputs_size);
23812381
bnb_used = true;
23822382
return SelectCoinsBnB(groups, nTargetValue, cost_of_change, setCoinsRet, nValueRet, not_input_fees);
23832383
} else {
@@ -2431,7 +2431,7 @@ bool CWallet::SelectCoins(const std::vector<COutput>& vAvailableCoins, const CAm
24312431
if (coin.m_input_bytes <= 0) {
24322432
return false; // Not solvable, can't estimate size for fee
24332433
}
2434-
coin.effective_value = coin.txout.nValue - coin_selection_params.effective_fee.GetFee(coin.m_input_bytes);
2434+
coin.effective_value = coin.txout.nValue - coin_selection_params.m_effective_feerate.GetFee(coin.m_input_bytes);
24352435
if (coin_selection_params.use_bnb) {
24362436
value_to_select -= coin.effective_value;
24372437
} else {
@@ -2802,11 +2802,11 @@ bool CWallet::CreateTransactionInternal(
28022802
coin_selection_params.m_discard_feerate = GetDiscardRate(*this);
28032803

28042804
// Get the fee rate to use effective values in coin selection
2805-
coin_selection_params.effective_fee = GetMinimumFeeRate(*this, coin_control, &feeCalc);
2805+
coin_selection_params.m_effective_feerate = GetMinimumFeeRate(*this, coin_control, &feeCalc);
28062806
// Do not, ever, assume that it's fine to change the fee rate if the user has explicitly
28072807
// provided one
2808-
if (coin_control.m_feerate && coin_selection_params.effective_fee > *coin_control.m_feerate) {
2809-
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));
2808+
if (coin_control.m_feerate && coin_selection_params.m_effective_feerate > *coin_control.m_feerate) {
2809+
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.m_effective_feerate.ToString(FeeEstimateMode::SAT_VB));
28102810
return false;
28112811
}
28122812
if (feeCalc.reason == FeeReason::FALLBACK && !m_allow_fallback_fee) {
@@ -2955,7 +2955,7 @@ bool CWallet::CreateTransactionInternal(
29552955
return false;
29562956
}
29572957

2958-
nFeeNeeded = coin_selection_params.effective_fee.GetFee(nBytes);
2958+
nFeeNeeded = coin_selection_params.m_effective_feerate.GetFee(nBytes);
29592959
if (nFeeRet >= nFeeNeeded) {
29602960
// Reduce fee to only the needed amount if possible. This
29612961
// prevents potential overpayment in fees if the coins
@@ -2969,7 +2969,7 @@ bool CWallet::CreateTransactionInternal(
29692969
// change output. Only try this once.
29702970
if (nChangePosInOut == -1 && nSubtractFeeFromAmount == 0 && pick_new_inputs) {
29712971
unsigned int tx_size_with_change = nBytes + coin_selection_params.change_output_size + 2; // Add 2 as a buffer in case increasing # of outputs changes compact size
2972-
CAmount fee_needed_with_change = coin_selection_params.effective_fee.GetFee(tx_size_with_change);
2972+
CAmount fee_needed_with_change = coin_selection_params.m_effective_feerate.GetFee(tx_size_with_change);
29732973
CAmount minimum_value_for_change = GetDustThreshold(change_prototype_txout, coin_selection_params.m_discard_feerate);
29742974
if (nFeeRet >= fee_needed_with_change + minimum_value_for_change) {
29752975
pick_new_inputs = false;

src/wallet/wallet.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -606,20 +606,20 @@ struct CoinSelectionParams
606606
bool use_bnb = true;
607607
size_t change_output_size = 0;
608608
size_t change_spend_size = 0;
609-
CFeeRate effective_fee = CFeeRate(0);
609+
CFeeRate m_effective_feerate;
610610
CFeeRate m_long_term_feerate;
611611
CFeeRate m_discard_feerate;
612612
size_t tx_noinputs_size = 0;
613613
//! Indicate that we are subtracting the fee from outputs
614614
bool m_subtract_fee_outputs = false;
615615
bool m_avoid_partial_spends = false;
616616

617-
CoinSelectionParams(bool use_bnb, size_t change_output_size, size_t change_spend_size, CFeeRate effective_fee,
617+
CoinSelectionParams(bool use_bnb, size_t change_output_size, size_t change_spend_size, CFeeRate effective_feerate,
618618
CFeeRate long_term_feerate, CFeeRate discard_feerate, size_t tx_noinputs_size, bool avoid_partial) :
619619
use_bnb(use_bnb),
620620
change_output_size(change_output_size),
621621
change_spend_size(change_spend_size),
622-
effective_fee(effective_fee),
622+
m_effective_feerate(effective_feerate),
623623
m_long_term_feerate(long_term_feerate),
624624
m_discard_feerate(discard_feerate),
625625
tx_noinputs_size(tx_noinputs_size),

0 commit comments

Comments
 (0)