@@ -63,7 +63,7 @@ struct {
6363
6464static const size_t TOTAL_TRIES = 100000 ;
6565
66- std::optional <SelectionResult> SelectCoinsBnB (std::vector<OutputGroup>& utxo_pool, const CAmount& selection_target, const CAmount& cost_of_change)
66+ util::Result <SelectionResult> SelectCoinsBnB (std::vector<OutputGroup>& utxo_pool, const CAmount& selection_target, const CAmount& cost_of_change)
6767{
6868 SelectionResult result (selection_target, SelectionAlgorithm::BNB);
6969 CAmount curr_value = 0 ;
@@ -78,7 +78,7 @@ std::optional<SelectionResult> SelectCoinsBnB(std::vector<OutputGroup>& utxo_poo
7878 curr_available_value += utxo.GetSelectionAmount ();
7979 }
8080 if (curr_available_value < selection_target) {
81- return std:: nullopt ;
81+ return util::Error () ;
8282 }
8383
8484 // Sort the utxo_pool
@@ -152,7 +152,7 @@ std::optional<SelectionResult> SelectCoinsBnB(std::vector<OutputGroup>& utxo_poo
152152
153153 // Check for solution
154154 if (best_selection.empty ()) {
155- return std:: nullopt ;
155+ return util::Error () ;
156156 }
157157
158158 // Set output set
@@ -165,7 +165,7 @@ std::optional<SelectionResult> SelectCoinsBnB(std::vector<OutputGroup>& utxo_poo
165165 return result;
166166}
167167
168- std::optional <SelectionResult> SelectCoinsSRD (const std::vector<OutputGroup>& utxo_pool, CAmount target_value, FastRandomContext& rng)
168+ util::Result <SelectionResult> SelectCoinsSRD (const std::vector<OutputGroup>& utxo_pool, CAmount target_value, FastRandomContext& rng)
169169{
170170 SelectionResult result (target_value, SelectionAlgorithm::SRD);
171171
@@ -190,7 +190,7 @@ std::optional<SelectionResult> SelectCoinsSRD(const std::vector<OutputGroup>& ut
190190 return result;
191191 }
192192 }
193- return std:: nullopt ;
193+ return util::Error () ;
194194}
195195
196196/* * Find a subset of the OutputGroups that is at least as large as, but as close as possible to, the
@@ -252,7 +252,7 @@ static void ApproximateBestSubset(FastRandomContext& insecure_rand, const std::v
252252 }
253253}
254254
255- std::optional <SelectionResult> KnapsackSolver (std::vector<OutputGroup>& groups, const CAmount& nTargetValue,
255+ util::Result <SelectionResult> KnapsackSolver (std::vector<OutputGroup>& groups, const CAmount& nTargetValue,
256256 CAmount change_target, FastRandomContext& rng)
257257{
258258 SelectionResult result (nTargetValue, SelectionAlgorithm::KNAPSACK);
@@ -286,7 +286,7 @@ std::optional<SelectionResult> KnapsackSolver(std::vector<OutputGroup>& groups,
286286 }
287287
288288 if (nTotalLower < nTargetValue) {
289- if (!lowest_larger) return std:: nullopt ;
289+ if (!lowest_larger) return util::Error () ;
290290 result.AddInput (*lowest_larger);
291291 return result;
292292 }
0 commit comments