@@ -352,7 +352,7 @@ std::vector<OutputGroup> CWallet::GroupOutputs(const std::vector<COutput>& outpu
352
352
return groups_out;
353
353
}
354
354
355
- bool CWallet::SelectCoinsMinConf (const CAmount& nTargetValue, const CoinEligibilityFilter& eligibility_filter, std::vector<COutput> coins,
355
+ bool CWallet::AttemptSelection (const CAmount& nTargetValue, const CoinEligibilityFilter& eligibility_filter, std::vector<COutput> coins,
356
356
std::set<CInputCoin>& setCoinsRet, CAmount& nValueRet, const CoinSelectionParams& coin_selection_params) const
357
357
{
358
358
setCoinsRet.clear ();
@@ -456,40 +456,40 @@ bool CWallet::SelectCoins(const std::vector<COutput>& vAvailableCoins, const CAm
456
456
457
457
// If possible, fund the transaction with confirmed UTXOs only. Prefer at least six
458
458
// confirmations on outputs received from other wallets and only spend confirmed change.
459
- if (SelectCoinsMinConf (value_to_select, CoinEligibilityFilter (1 , 6 , 0 ), vCoins, setCoinsRet, nValueRet, coin_selection_params)) return true ;
460
- if (SelectCoinsMinConf (value_to_select, CoinEligibilityFilter (1 , 1 , 0 ), vCoins, setCoinsRet, nValueRet, coin_selection_params)) return true ;
459
+ if (AttemptSelection (value_to_select, CoinEligibilityFilter (1 , 6 , 0 ), vCoins, setCoinsRet, nValueRet, coin_selection_params)) return true ;
460
+ if (AttemptSelection (value_to_select, CoinEligibilityFilter (1 , 1 , 0 ), vCoins, setCoinsRet, nValueRet, coin_selection_params)) return true ;
461
461
462
462
// Fall back to using zero confirmation change (but with as few ancestors in the mempool as
463
463
// possible) if we cannot fund the transaction otherwise.
464
464
if (m_spend_zero_conf_change) {
465
- if (SelectCoinsMinConf (value_to_select, CoinEligibilityFilter (0 , 1 , 2 ), vCoins, setCoinsRet, nValueRet, coin_selection_params)) return true ;
466
- if (SelectCoinsMinConf (value_to_select, CoinEligibilityFilter (0 , 1 , std::min ((size_t )4 , max_ancestors/3 ), std::min ((size_t )4 , max_descendants/3 )),
465
+ if (AttemptSelection (value_to_select, CoinEligibilityFilter (0 , 1 , 2 ), vCoins, setCoinsRet, nValueRet, coin_selection_params)) return true ;
466
+ if (AttemptSelection (value_to_select, CoinEligibilityFilter (0 , 1 , std::min ((size_t )4 , max_ancestors/3 ), std::min ((size_t )4 , max_descendants/3 )),
467
467
vCoins, setCoinsRet, nValueRet, coin_selection_params)) {
468
468
return true ;
469
469
}
470
- if (SelectCoinsMinConf (value_to_select, CoinEligibilityFilter (0 , 1 , max_ancestors/2 , max_descendants/2 ),
470
+ if (AttemptSelection (value_to_select, CoinEligibilityFilter (0 , 1 , max_ancestors/2 , max_descendants/2 ),
471
471
vCoins, setCoinsRet, nValueRet, coin_selection_params)) {
472
472
return true ;
473
473
}
474
474
// If partial groups are allowed, relax the requirement of spending OutputGroups (groups
475
475
// of UTXOs sent to the same address, which are obviously controlled by a single wallet)
476
476
// in their entirety.
477
- if (SelectCoinsMinConf (value_to_select, CoinEligibilityFilter (0 , 1 , max_ancestors-1 , max_descendants-1 , true /* include_partial_groups */ ),
477
+ if (AttemptSelection (value_to_select, CoinEligibilityFilter (0 , 1 , max_ancestors-1 , max_descendants-1 , true /* include_partial_groups */ ),
478
478
vCoins, setCoinsRet, nValueRet, coin_selection_params)) {
479
479
return true ;
480
480
}
481
481
// Try with unsafe inputs if they are allowed. This may spend unconfirmed outputs
482
482
// received from other wallets.
483
483
if (coin_control.m_include_unsafe_inputs
484
- && SelectCoinsMinConf (value_to_select,
484
+ && AttemptSelection (value_to_select,
485
485
CoinEligibilityFilter (0 /* conf_mine */ , 0 /* conf_theirs */ , max_ancestors-1 , max_descendants-1 , true /* include_partial_groups */ ),
486
486
vCoins, setCoinsRet, nValueRet, coin_selection_params)) {
487
487
return true ;
488
488
}
489
489
// Try with unlimited ancestors/descendants. The transaction will still need to meet
490
490
// mempool ancestor/descendant policy to be accepted to mempool and broadcasted, but
491
491
// OutputGroups use heuristics that may overestimate ancestor/descendant counts.
492
- if (!fRejectLongChains && SelectCoinsMinConf (value_to_select,
492
+ if (!fRejectLongChains && AttemptSelection (value_to_select,
493
493
CoinEligibilityFilter (0 , 1 , std::numeric_limits<uint64_t >::max (), std::numeric_limits<uint64_t >::max (), true /* include_partial_groups */ ),
494
494
vCoins, setCoinsRet, nValueRet, coin_selection_params)) {
495
495
return true ;
@@ -499,7 +499,7 @@ bool CWallet::SelectCoins(const std::vector<COutput>& vAvailableCoins, const CAm
499
499
return false ;
500
500
}();
501
501
502
- // SelectCoinsMinConf clears setCoinsRet, so add the preset inputs from coin_control to the coinset
502
+ // AttemptSelection clears setCoinsRet, so add the preset inputs from coin_control to the coinset
503
503
util::insert (setCoinsRet, setPresetCoins);
504
504
505
505
// add preset inputs to the total value selected
0 commit comments