Skip to content

Commit ff330ba

Browse files
committed
Default to bnb_used = false as there are many cases where BnB is not used
1 parent 0b79caf commit ff330ba

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/wallet/wallet.cpp

+4-7
Original file line numberDiff line numberDiff line change
@@ -2270,12 +2270,12 @@ bool CWallet::SelectCoins(const std::vector<COutput>& vAvailableCoins, const CAm
22702270
std::vector<COutput> vCoins(vAvailableCoins);
22712271
CAmount value_to_select = nTargetValue;
22722272

2273+
// Default to bnb was not used. If we use it, we set it later
2274+
bnb_used = false;
2275+
22732276
// coin control -> return all selected outputs (we want all selected to go into the transaction for sure)
22742277
if (coin_control.HasSelected() && !coin_control.fAllowOtherInputs)
22752278
{
2276-
// We didn't use BnB here, so set it to false.
2277-
bnb_used = false;
2278-
22792279
for (const COutput& out : vCoins)
22802280
{
22812281
if (!out.fSpendable)
@@ -2300,14 +2300,12 @@ bool CWallet::SelectCoins(const std::vector<COutput>& vAvailableCoins, const CAm
23002300
const CWalletTx& wtx = it->second;
23012301
// Clearly invalid input, fail
23022302
if (wtx.tx->vout.size() <= outpoint.n) {
2303-
bnb_used = false;
23042303
return false;
23052304
}
23062305
// Just to calculate the marginal byte size
23072306
CInputCoin coin(wtx.tx, outpoint.n, wtx.GetSpendSize(outpoint.n, false));
23082307
nValueFromPresetInputs += coin.txout.nValue;
23092308
if (coin.m_input_bytes <= 0) {
2310-
bnb_used = false;
23112309
return false; // Not solvable, can't estimate size for fee
23122310
}
23132311
coin.effective_value = coin.txout.nValue - coin_selection_params.effective_fee.GetFee(coin.m_input_bytes);
@@ -2318,7 +2316,6 @@ bool CWallet::SelectCoins(const std::vector<COutput>& vAvailableCoins, const CAm
23182316
}
23192317
setPresetCoins.insert(coin);
23202318
} else {
2321-
bnb_used = false;
23222319
return false; // TODO: Allow non-wallet inputs
23232320
}
23242321
}
@@ -2678,7 +2675,7 @@ bool CWallet::CreateTransaction(interfaces::Chain::Lock& locked_chain, const std
26782675
}
26792676

26802677
// Choose coins to use
2681-
bool bnb_used;
2678+
bool bnb_used = false;
26822679
if (pick_new_inputs) {
26832680
nValueIn = 0;
26842681
setCoins.clear();

0 commit comments

Comments
 (0)