diff options
author | furszy <matiasfurszyfer@protonmail.com> | 2023-01-04 10:22:53 -0300 |
---|---|---|
committer | furszy <matiasfurszyfer@protonmail.com> | 2023-03-07 09:01:57 -0300 |
commit | 1284223691127e76135a46d251c52416104f0ff1 (patch) | |
tree | fc27b5e98573a1ac564ab96a4080dbaad916e3ab /src/wallet/coinselection.h | |
parent | 86bacd75e76eff207ef8f7bdb897365f5b6e7b6b (diff) | |
download | bitcoin-1284223691127e76135a46d251c52416104f0ff1.tar.xz |
wallet: refactor coin selection algos to return util::Result
so the selection processes can retrieve different errors and not
uninformative std::nullopt
Diffstat (limited to 'src/wallet/coinselection.h')
-rw-r--r-- | src/wallet/coinselection.h | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/wallet/coinselection.h b/src/wallet/coinselection.h index 3abd22c207..95a3bb2bc8 100644 --- a/src/wallet/coinselection.h +++ b/src/wallet/coinselection.h @@ -13,6 +13,7 @@ #include <random.h> #include <util/system.h> #include <util/check.h> +#include <util/result.h> #include <optional> @@ -408,7 +409,7 @@ public: int GetWeight() const { return m_weight; } }; -std::optional<SelectionResult> SelectCoinsBnB(std::vector<OutputGroup>& utxo_pool, const CAmount& selection_target, const CAmount& cost_of_change); +util::Result<SelectionResult> SelectCoinsBnB(std::vector<OutputGroup>& utxo_pool, const CAmount& selection_target, const CAmount& cost_of_change); /** Select coins by Single Random Draw. OutputGroups are selected randomly from the eligible * outputs until the target is satisfied @@ -417,10 +418,10 @@ std::optional<SelectionResult> SelectCoinsBnB(std::vector<OutputGroup>& utxo_poo * @param[in] target_value The target value to select for * @returns If successful, a SelectionResult, otherwise, std::nullopt */ -std::optional<SelectionResult> SelectCoinsSRD(const std::vector<OutputGroup>& utxo_pool, CAmount target_value, FastRandomContext& rng); +util::Result<SelectionResult> SelectCoinsSRD(const std::vector<OutputGroup>& utxo_pool, CAmount target_value, FastRandomContext& rng); // Original coin selection algorithm as a fallback -std::optional<SelectionResult> KnapsackSolver(std::vector<OutputGroup>& groups, const CAmount& nTargetValue, +util::Result<SelectionResult> KnapsackSolver(std::vector<OutputGroup>& groups, const CAmount& nTargetValue, CAmount change_target, FastRandomContext& rng); } // namespace wallet |