aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/wallet/coinselection.cpp12
-rw-r--r--src/wallet/coinselection.h8
2 files changed, 20 insertions, 0 deletions
diff --git a/src/wallet/coinselection.cpp b/src/wallet/coinselection.cpp
index 20944b3c8d..abd710d56d 100644
--- a/src/wallet/coinselection.cpp
+++ b/src/wallet/coinselection.cpp
@@ -426,6 +426,7 @@ util::Result<SelectionResult> CoinGrinder(std::vector<OutputGroup>& utxo_pool, c
if (curr_try >= TOTAL_TRIES) {
// Solution is not guaranteed to be optimal if `curr_try` hit TOTAL_TRIES
+ result.SetAlgoCompleted(false);
break;
}
@@ -447,6 +448,7 @@ util::Result<SelectionResult> CoinGrinder(std::vector<OutputGroup>& utxo_pool, c
// Set `next_utxo` to one after last selected, then deselect last selected UTXO
if (curr_selection.empty()) {
// Exhausted search space before running into attempt limit
+ result.SetAlgoCompleted(true);
break;
}
next_utxo = curr_selection.back() + 1;
@@ -794,6 +796,16 @@ void SelectionResult::ComputeAndSetWaste(const CAmount min_viable_change, const
}
}
+void SelectionResult::SetAlgoCompleted(bool algo_completed)
+{
+ m_algo_completed = algo_completed;
+}
+
+bool SelectionResult::GetAlgoCompleted() const
+{
+ return m_algo_completed;
+}
+
void SelectionResult::SetSelectionsEvaluated(size_t attempts)
{
m_selections_evaluated = attempts;
diff --git a/src/wallet/coinselection.h b/src/wallet/coinselection.h
index ba9e6bafd9..80c92e1b0e 100644
--- a/src/wallet/coinselection.h
+++ b/src/wallet/coinselection.h
@@ -330,6 +330,8 @@ private:
bool m_use_effective{false};
/** The computed waste */
std::optional<CAmount> m_waste;
+ /** False if algorithm was cut short by hitting limit of attempts and solution is non-optimal */
+ bool m_algo_completed{true};
/** The count of selections that were evaluated by this coin selection attempt */
size_t m_selections_evaluated;
/** Total weight of the selected inputs */
@@ -389,6 +391,12 @@ public:
void ComputeAndSetWaste(const CAmount min_viable_change, const CAmount change_cost, const CAmount change_fee);
[[nodiscard]] CAmount GetWaste() const;
+ /** Tracks that algorithm was able to exhaustively search the entire combination space before hitting limit of tries */
+ void SetAlgoCompleted(bool algo_completed);
+
+ /** Get m_algo_completed */
+ bool GetAlgoCompleted() const;
+
/** Record the number of selections that were evaluated */
void SetSelectionsEvaluated(size_t attempts);