diff options
author | furszy <matiasfurszyfer@protonmail.com> | 2022-12-08 15:55:41 -0300 |
---|---|---|
committer | furszy <matiasfurszyfer@protonmail.com> | 2022-12-08 15:56:36 -0300 |
commit | 89c1491d35389eac0c1fecc59333cdfae3b1bd2c (patch) | |
tree | 24f4081c6ed4ccf1bdfacd0e1480316be9eea8e4 /src | |
parent | 3eaf7be6ade22c99f3c0000122e49b94de868d74 (diff) |
wallet: if only have one output type, don't perform "mixed" coin selection
there is nothing to mix.
Diffstat (limited to 'src')
-rw-r--r-- | src/wallet/spend.cpp | 5 | ||||
-rw-r--r-- | src/wallet/spend.h | 2 |
2 files changed, 5 insertions, 2 deletions
diff --git a/src/wallet/spend.cpp b/src/wallet/spend.cpp index 3ced3ebeb5..d4148037d2 100644 --- a/src/wallet/spend.cpp +++ b/src/wallet/spend.cpp @@ -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 we can't fund the transaction from any individual OutputType, run coin selection one last time - // over all available coins, which would allow mixing - if (allow_mixed_output_types) { + // over all available coins, which would allow mixing. + // 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)}) { return result; } diff --git a/src/wallet/spend.h b/src/wallet/spend.h index 2b861c2361..46144d4c92 100644 --- a/src/wallet/spend.h +++ b/src/wallet/spend.h @@ -46,6 +46,8 @@ struct CoinsResult { /** 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 */ size_t Size() const; + /** Return how many different output types this struct stores */ + size_t TypesCount() const { return coins.size(); } void Clear(); void Erase(const std::unordered_set<COutPoint, SaltedOutpointHasher>& coins_to_remove); void Shuffle(FastRandomContext& rng_fast); |