@@ -2373,8 +2373,8 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, const CoinEligibil
2373
2373
setCoinsRet.clear ();
2374
2374
nValueRet = 0 ;
2375
2375
2376
- std::vector<OutputGroup> utxo_pool;
2377
2376
if (coin_selection_params.use_bnb ) {
2377
+ std::vector<OutputGroup> utxo_pool;
2378
2378
// Get long term estimate
2379
2379
FeeCalculation feeCalc;
2380
2380
CCoinControl temp;
@@ -2388,15 +2388,13 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, const CoinEligibil
2388
2388
effective_feerate = coin_selection_params.effective_fee ;
2389
2389
}
2390
2390
2391
- std::vector<OutputGroup> groups = GroupOutputs (coins, !coin_selection_params.m_avoid_partial_spends , eligibility_filter.max_ancestors , effective_feerate, long_term_feerate);
2391
+ std::vector<OutputGroup> groups = GroupOutputs (coins, !coin_selection_params.m_avoid_partial_spends , eligibility_filter.max_ancestors , effective_feerate, long_term_feerate, eligibility_filter );
2392
2392
2393
2393
// Calculate cost of change
2394
2394
CAmount cost_of_change = GetDiscardRate (*this ).GetFee (coin_selection_params.change_spend_size ) + coin_selection_params.effective_fee .GetFee (coin_selection_params.change_output_size );
2395
2395
2396
2396
// Filter by the min conf specs and add to utxo_pool and calculate effective value
2397
2397
for (OutputGroup& group : groups) {
2398
- if (!group.EligibleForSpending (eligibility_filter)) continue ;
2399
-
2400
2398
OutputGroup pos_group = group.GetPositiveOnlyGroup ();
2401
2399
if (pos_group.effective_value > 0 ) utxo_pool.push_back (pos_group);
2402
2400
}
@@ -2405,15 +2403,10 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, const CoinEligibil
2405
2403
bnb_used = true ;
2406
2404
return SelectCoinsBnB (utxo_pool, nTargetValue, cost_of_change, setCoinsRet, nValueRet, not_input_fees);
2407
2405
} else {
2408
- std::vector<OutputGroup> groups = GroupOutputs (coins, !coin_selection_params.m_avoid_partial_spends , eligibility_filter.max_ancestors , CFeeRate (0 ), CFeeRate (0 ));
2406
+ std::vector<OutputGroup> groups = GroupOutputs (coins, !coin_selection_params.m_avoid_partial_spends , eligibility_filter.max_ancestors , CFeeRate (0 ), CFeeRate (0 ), eligibility_filter );
2409
2407
2410
- // Filter by the min conf specs and add to utxo_pool
2411
- for (const OutputGroup& group : groups) {
2412
- if (!group.EligibleForSpending (eligibility_filter)) continue ;
2413
- utxo_pool.push_back (group);
2414
- }
2415
2408
bnb_used = false ;
2416
- return KnapsackSolver (nTargetValue, utxo_pool , setCoinsRet, nValueRet);
2409
+ return KnapsackSolver (nTargetValue, groups , setCoinsRet, nValueRet);
2417
2410
}
2418
2411
}
2419
2412
@@ -4206,7 +4199,7 @@ bool CWalletTx::IsImmatureCoinBase() const
4206
4199
return GetBlocksToMaturity () > 0 ;
4207
4200
}
4208
4201
4209
- std::vector<OutputGroup> CWallet::GroupOutputs (const std::vector<COutput>& outputs, bool single_coin, const size_t max_ancestors, const CFeeRate& effective_feerate, const CFeeRate& long_term_feerate) const {
4202
+ std::vector<OutputGroup> CWallet::GroupOutputs (const std::vector<COutput>& outputs, bool single_coin, const size_t max_ancestors, const CFeeRate& effective_feerate, const CFeeRate& long_term_feerate, const CoinEligibilityFilter& filter ) const {
4210
4203
std::vector<OutputGroup> groups;
4211
4204
std::map<CTxDestination, OutputGroup> gmap;
4212
4205
std::set<CTxDestination> full_groups;
@@ -4237,8 +4230,10 @@ std::vector<OutputGroup> CWallet::GroupOutputs(const std::vector<COutput>& outpu
4237
4230
ins.first ->second .Insert (input_coin, output.nDepth , output.tx ->IsFromMe (ISMINE_ALL), ancestors, descendants);
4238
4231
}
4239
4232
} else {
4240
- groups.emplace_back (effective_feerate, long_term_feerate);
4241
- groups.back ().Insert (input_coin, output.nDepth , output.tx ->IsFromMe (ISMINE_ALL), ancestors, descendants);
4233
+ // This is for if each output gets it's own OutputGroup
4234
+ OutputGroup coin (effective_feerate, long_term_feerate);
4235
+ coin.Insert (input_coin, output.nDepth , output.tx ->IsFromMe (ISMINE_ALL), ancestors, descendants);
4236
+ if (coin.EligibleForSpending (filter)) groups.push_back (coin);
4242
4237
}
4243
4238
}
4244
4239
}
@@ -4249,7 +4244,8 @@ std::vector<OutputGroup> CWallet::GroupOutputs(const std::vector<COutput>& outpu
4249
4244
// Make this unattractive as we want coin selection to avoid it if possible
4250
4245
group.m_ancestors = max_ancestors - 1 ;
4251
4246
}
4252
- groups.push_back (group);
4247
+ // If the OutputGroup is not eligible, don't add it
4248
+ if (group.EligibleForSpending (filter)) groups.push_back (group);
4253
4249
}
4254
4250
}
4255
4251
return groups;
0 commit comments