From 70f31f1a81710aa59e95770de9a84bf58cbce1e8 Mon Sep 17 00:00:00 2001 From: Andrew Chow Date: Mon, 17 Jan 2022 17:18:31 -0500 Subject: coinselection: Use COutput instead of CInputCoin Also rename setPresetCoins to preset_coins --- src/wallet/coinselection.h | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'src/wallet/coinselection.h') diff --git a/src/wallet/coinselection.h b/src/wallet/coinselection.h index 5dbb63310c..4d39be364c 100644 --- a/src/wallet/coinselection.h +++ b/src/wallet/coinselection.h @@ -138,6 +138,18 @@ public: { return CInputCoin(outpoint, txout, input_bytes); } + + bool operator<(const COutput& rhs) const { + return outpoint < rhs.outpoint; + } + + bool operator!=(const COutput& rhs) const { + return outpoint != rhs.outpoint; + } + + bool operator==(const COutput& rhs) const { + return outpoint == rhs.outpoint; + } }; /** Parameters for one iteration of Coin Selection. */ @@ -207,7 +219,7 @@ struct CoinEligibilityFilter struct OutputGroup { /** The list of UTXOs contained in this output group. */ - std::vector m_outputs; + std::vector m_outputs; /** Whether the UTXOs were sent by the wallet to itself. This is relevant because we may want at * least a certain number of confirmations on UTXOs received from outside wallets while trusting * our own UTXOs more. */ @@ -244,7 +256,7 @@ struct OutputGroup m_subtract_fee_outputs(params.m_subtract_fee_outputs) {} - void Insert(const CInputCoin& output, int depth, bool from_me, size_t ancestors, size_t descendants, bool positive_only); + void Insert(const COutput& output, size_t ancestors, size_t descendants, bool positive_only); bool EligibleForSpending(const CoinEligibilityFilter& eligibility_filter) const; CAmount GetSelectionAmount() const; }; @@ -266,13 +278,13 @@ struct OutputGroup * @param[in] use_effective_value Whether to use the input's effective value (when true) or the real value (when false). * @return The waste */ -[[nodiscard]] CAmount GetSelectionWaste(const std::set& inputs, CAmount change_cost, CAmount target, bool use_effective_value = true); +[[nodiscard]] CAmount GetSelectionWaste(const std::set& inputs, CAmount change_cost, CAmount target, bool use_effective_value = true); struct SelectionResult { private: /** Set of inputs selected by the algorithm to use in the transaction */ - std::set m_selected_inputs; + std::set m_selected_inputs; /** The target the algorithm selected for. Note that this may not be equal to the recipient amount as it can include non-input fees */ const CAmount m_target; /** Whether the input values for calculations should be the effective value (true) or normal value (false) */ @@ -298,9 +310,9 @@ public: [[nodiscard]] CAmount GetWaste() const; /** Get m_selected_inputs */ - const std::set& GetInputSet() const; - /** Get the vector of CInputCoins that will be used to fill in a CTransaction's vin */ - std::vector GetShuffledInputVector() const; + const std::set& GetInputSet() const; + /** Get the vector of COutputs that will be used to fill in a CTransaction's vin */ + std::vector GetShuffledInputVector() const; bool operator<(SelectionResult other) const; }; -- cgit v1.2.3