Skip to content

Commit 1bf4a62

Browse files
committed
scripted-diff: rename some variables
actual_target -> selection_target nChange -> change_and_fee -BEGIN VERIFY SCRIPT- sed -i -e 's/actual_target/selection_target/g' src/wallet/coinselection.cpp sed -i -e '2801,3691s/nChange /change_and_fee /g' src/wallet/wallet.cpp sed -i -e '2801,3691s/nChange,/change_and_fee,/g' src/wallet/wallet.cpp sed -i -e '2801,3691s/nChange;/change_and_fee;/g' src/wallet/wallet.cpp -END VERIFY SCRIPT-
1 parent b34bf2b commit 1bf4a62

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

src/wallet/coinselection.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ bool SelectCoinsBnB(std::vector<OutputGroup>& utxo_pool, const CAmount& target_v
7070

7171
std::vector<bool> curr_selection; // select the utxo at this index
7272
curr_selection.reserve(utxo_pool.size());
73-
CAmount actual_target = not_input_fees + target_value;
73+
CAmount selection_target = not_input_fees + target_value;
7474

7575
// Calculate curr_available_value
7676
CAmount curr_available_value = 0;
@@ -79,7 +79,7 @@ bool SelectCoinsBnB(std::vector<OutputGroup>& utxo_pool, const CAmount& target_v
7979
assert(utxo.effective_value > 0);
8080
curr_available_value += utxo.effective_value;
8181
}
82-
if (curr_available_value < actual_target) {
82+
if (curr_available_value < selection_target) {
8383
return false;
8484
}
8585

@@ -94,12 +94,12 @@ bool SelectCoinsBnB(std::vector<OutputGroup>& utxo_pool, const CAmount& target_v
9494
for (size_t i = 0; i < TOTAL_TRIES; ++i) {
9595
// Conditions for starting a backtrack
9696
bool backtrack = false;
97-
if (curr_value + curr_available_value < actual_target || // Cannot possibly reach target with the amount remaining in the curr_available_value.
98-
curr_value > actual_target + cost_of_change || // Selected value is out of range, go back and try other branch
97+
if (curr_value + curr_available_value < selection_target || // Cannot possibly reach target with the amount remaining in the curr_available_value.
98+
curr_value > selection_target + cost_of_change || // Selected value is out of range, go back and try other branch
9999
(curr_waste > best_waste && (utxo_pool.at(0).fee - utxo_pool.at(0).long_term_fee) > 0)) { // Don't select things which we know will be more wasteful if the waste is increasing
100100
backtrack = true;
101-
} else if (curr_value >= actual_target) { // Selected value is within range
102-
curr_waste += (curr_value - actual_target); // This is the excess value which is added to the waste for the below comparison
101+
} else if (curr_value >= selection_target) { // Selected value is within range
102+
curr_waste += (curr_value - selection_target); // This is the excess value which is added to the waste for the below comparison
103103
// Adding another UTXO after this check could bring the waste down if the long term fee is higher than the current fee.
104104
// However we are not going to explore that because this optimization for the waste is only done when we have hit our target
105105
// value. Adding any more UTXOs will be just burning the UTXO; it will go entirely to fees. Thus we aren't going to
@@ -112,7 +112,7 @@ bool SelectCoinsBnB(std::vector<OutputGroup>& utxo_pool, const CAmount& target_v
112112
break;
113113
}
114114
}
115-
curr_waste -= (curr_value - actual_target); // Remove the excess value as we will be selecting different coins now
115+
curr_waste -= (curr_value - selection_target); // Remove the excess value as we will be selecting different coins now
116116
backtrack = true;
117117
}
118118

src/wallet/wallet.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2990,19 +2990,19 @@ bool CWallet::CreateTransactionInternal(
29902990
bnb_used = false;
29912991
}
29922992

2993-
const CAmount nChange = nValueIn - nValueToSelect;
2994-
if (nChange > 0)
2993+
const CAmount change_and_fee = nValueIn - nValueToSelect;
2994+
if (change_and_fee > 0)
29952995
{
29962996
// Fill a vout to ourself
2997-
CTxOut newTxOut(nChange, scriptChange);
2997+
CTxOut newTxOut(change_and_fee, scriptChange);
29982998

29992999
// Never create dust outputs; if we would, just
30003000
// add the dust to the fee.
3001-
// The nChange when BnB is used is always going to go to fees.
3001+
// The change_and_fee when BnB is used is always going to go to fees.
30023002
if (IsDust(newTxOut, coin_selection_params.m_discard_feerate) || bnb_used)
30033003
{
30043004
nChangePosInOut = -1;
3005-
nFeeRet += nChange;
3005+
nFeeRet += change_and_fee;
30063006
}
30073007
else
30083008
{

0 commit comments

Comments
 (0)