diff options
author | Andrew Chow <achow101-github@achow101.com> | 2021-05-21 18:39:41 -0400 |
---|---|---|
committer | Andrew Chow <achow101-github@achow101.com> | 2021-12-05 13:44:09 -0500 |
commit | 9d9b101d2019d8237546eedd022e74519feb07bb (patch) | |
tree | f8eca393c9991093763e7a527dd7e83c3d56b8a2 /src/wallet/spend.h | |
parent | bb50850a447bdf461ffb76d47d4a4db904fce324 (diff) |
Use SelectionResult in AttemptSelection
Replace setCoinsRet and nValueRet with a SelectionResult in
AttemptSelection
Diffstat (limited to 'src/wallet/spend.h')
-rw-r--r-- | src/wallet/spend.h | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/wallet/spend.h b/src/wallet/spend.h index 7467dd9fa3..982ba44a37 100644 --- a/src/wallet/spend.h +++ b/src/wallet/spend.h @@ -101,18 +101,20 @@ std::map<CTxDestination, std::vector<COutput>> ListCoins(const CWallet& wallet) std::vector<OutputGroup> GroupOutputs(const CWallet& wallet, const std::vector<COutput>& outputs, const CoinSelectionParams& coin_sel_params, const CoinEligibilityFilter& filter, bool positive_only); /** - * Shuffle and select coins until nTargetValue is reached while avoiding - * small change; This method is stochastic for some inputs and upon - * completion the coin set and corresponding actual target value is - * assembled - * param@[in] coins Set of UTXOs to consider. These will be categorized into - * OutputGroups and filtered using eligibility_filter before - * selecting coins. - * param@[out] setCoinsRet Populated with the coins selected if successful. - * param@[out] nValueRet Used to return the total value of selected coins. + * Attempt to find a valid input set that meets the provided eligibility filter and target. + * Multiple coin selection algorithms will be run and the input set that produces the least waste + * (according to the waste metric) will be chosen. + * + * param@[in] wallet The wallet which provides solving data for the coins + * param@[in] nTargetValue The target value + * param@[in] eligilibity_filter A filter containing rules for which coins are allowed to be included in this selection + * param@[in] coins The vector of coins available for selection prior to filtering + * param@[in] coin_selection_params Parameters for the coin selection + * returns If successful, a SelectionResult containing the input set + * If failed, a nullopt */ -bool AttemptSelection(const CWallet& wallet, const CAmount& nTargetValue, const CoinEligibilityFilter& eligibility_filter, std::vector<COutput> coins, - std::set<CInputCoin>& setCoinsRet, CAmount& nValueRet, const CoinSelectionParams& coin_selection_params); +std::optional<SelectionResult> AttemptSelection(const CWallet& wallet, const CAmount& nTargetValue, const CoinEligibilityFilter& eligibility_filter, std::vector<COutput> coins, + const CoinSelectionParams& coin_selection_params); /** * Select a set of coins such that nValueRet >= nTargetValue and at least |