wallet: if only have one output type, don't perform "mixed" coin selection
there is nothing to mix.
This commit is contained in:
2 files changed
+5
-2
No files matched your search
@@ -524,8 +524,9 @@ std::optional<SelectionResult> AttemptSelection(const CWallet& wallet, const CAm
|
|||||||
if (results.size() > 0) return *std::min_element(results.begin(), results.end());
|
if (results.size() > 0) return *std::min_element(results.begin(), results.end());
|
||||||
|
|
||||||
// If we can't fund the transaction from any individual OutputType, run coin selection one last time
|
// If we can't fund the transaction from any individual OutputType, run coin selection one last time
|
||||||
// over all available coins, which would allow mixing
|
// over all available coins, which would allow mixing.
|
||||||
if (allow_mixed_output_types) {
|
// If TypesCount() <= 1, there is nothing to mix.
|
||||||
|
if (allow_mixed_output_types && available_coins.TypesCount() > 1) {
|
||||||
if (auto result{ChooseSelectionResult(wallet, nTargetValue, eligibility_filter, available_coins.All(), coin_selection_params)}) {
|
if (auto result{ChooseSelectionResult(wallet, nTargetValue, eligibility_filter, available_coins.All(), coin_selection_params)}) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,6 +46,8 @@ struct CoinsResult {
|
|||||||
/** The following methods are provided so that CoinsResult can mimic a vector,
|
/** The following methods are provided so that CoinsResult can mimic a vector,
|
||||||
* i.e., methods can work with individual OutputType vectors or on the entire object */
|
* i.e., methods can work with individual OutputType vectors or on the entire object */
|
||||||
size_t Size() const;
|
size_t Size() const;
|
||||||
|
/** Return how many different output types this struct stores */
|
||||||
|
size_t TypesCount() const { return coins.size(); }
|
||||||
void Clear();
|
void Clear();
|
||||||
void Erase(const std::unordered_set<COutPoint, SaltedOutpointHasher>& coins_to_remove);
|
void Erase(const std::unordered_set<COutPoint, SaltedOutpointHasher>& coins_to_remove);
|
||||||
void Shuffle(FastRandomContext& rng_fast);
|
void Shuffle(FastRandomContext& rng_fast);
|
||||||
|
|||||||
Reference in new issue
Block a user