@@ -63,7 +63,7 @@ struct {
63
63
64
64
static const size_t TOTAL_TRIES = 100000 ;
65
65
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)
67
67
{
68
68
SelectionResult result (selection_target, SelectionAlgorithm::BNB);
69
69
CAmount curr_value = 0 ;
@@ -78,7 +78,7 @@ std::optional<SelectionResult> SelectCoinsBnB(std::vector<OutputGroup>& utxo_poo
78
78
curr_available_value += utxo.GetSelectionAmount ();
79
79
}
80
80
if (curr_available_value < selection_target) {
81
- return std::nullopt ;
81
+ return util::Error () ;
82
82
}
83
83
84
84
// Sort the utxo_pool
@@ -152,7 +152,7 @@ std::optional<SelectionResult> SelectCoinsBnB(std::vector<OutputGroup>& utxo_poo
152
152
153
153
// Check for solution
154
154
if (best_selection.empty ()) {
155
- return std::nullopt ;
155
+ return util::Error () ;
156
156
}
157
157
158
158
// Set output set
@@ -165,7 +165,7 @@ std::optional<SelectionResult> SelectCoinsBnB(std::vector<OutputGroup>& utxo_poo
165
165
return result;
166
166
}
167
167
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)
169
169
{
170
170
SelectionResult result (target_value, SelectionAlgorithm::SRD);
171
171
@@ -190,7 +190,7 @@ std::optional<SelectionResult> SelectCoinsSRD(const std::vector<OutputGroup>& ut
190
190
return result;
191
191
}
192
192
}
193
- return std::nullopt ;
193
+ return util::Error () ;
194
194
}
195
195
196
196
/* * 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
252
252
}
253
253
}
254
254
255
- std::optional <SelectionResult> KnapsackSolver (std::vector<OutputGroup>& groups, const CAmount& nTargetValue,
255
+ util::Result <SelectionResult> KnapsackSolver (std::vector<OutputGroup>& groups, const CAmount& nTargetValue,
256
256
CAmount change_target, FastRandomContext& rng)
257
257
{
258
258
SelectionResult result (nTargetValue, SelectionAlgorithm::KNAPSACK);
@@ -286,7 +286,7 @@ std::optional<SelectionResult> KnapsackSolver(std::vector<OutputGroup>& groups,
286
286
}
287
287
288
288
if (nTotalLower < nTargetValue) {
289
- if (!lowest_larger) return std::nullopt ;
289
+ if (!lowest_larger) return util::Error () ;
290
290
result.AddInput (*lowest_larger);
291
291
return result;
292
292
}
0 commit comments