diff options
Diffstat (limited to 'src/wallet/coincontrol.h')
-rw-r--r-- | src/wallet/coincontrol.h | 42 |
1 files changed, 32 insertions, 10 deletions
diff --git a/src/wallet/coincontrol.h b/src/wallet/coincontrol.h index 71593e236f..4f87d13d99 100644 --- a/src/wallet/coincontrol.h +++ b/src/wallet/coincontrol.h @@ -24,6 +24,33 @@ const int DEFAULT_MAX_DEPTH = 9999999; //! Default for -avoidpartialspends static constexpr bool DEFAULT_AVOIDPARTIALSPENDS = false; +class PreselectedInput +{ +private: + //! The previous output being spent by this input + std::optional<CTxOut> m_txout; + //! The input weight for spending this input + std::optional<int64_t> m_weight; + +public: + /** + * Set the previous output for this input. + * Only necessary if the input is expected to be an external input. + */ + void SetTxOut(const CTxOut& txout); + /** Retrieve the previous output for this input. */ + CTxOut GetTxOut() const; + /** Return whether the previous output is set for this input. */ + bool HasTxOut() const; + + /** Set the weight for this input. */ + void SetInputWeight(int64_t weight); + /** Retrieve the input weight for this input. */ + int64_t GetInputWeight() const; + /** Return whether the input weight is set. */ + bool HasInputWeight() const; +}; + /** Coin Control Features. */ class CCoinControl { @@ -69,11 +96,11 @@ public: /** * Returns true if the given output is pre-selected. */ - bool IsSelected(const COutPoint& output) const; + bool IsSelected(const COutPoint& outpoint) const; /** * Returns true if the given output is selected as an external input. */ - bool IsExternalSelected(const COutPoint& output) const; + bool IsExternalSelected(const COutPoint& outpoint) const; /** * Returns the external output for the given outpoint if it exists. */ @@ -82,7 +109,7 @@ public: * Lock-in the given output for spending. * The output will be included in the transaction even if it's not the most optimal choice. */ - void Select(const COutPoint& output); + PreselectedInput& Select(const COutPoint& outpoint); /** * Lock-in the given output as an external input for spending because it is not in the wallet. * The output will be included in the transaction even if it's not the most optimal choice. @@ -91,7 +118,7 @@ public: /** * Unselects the given output. */ - void UnSelect(const COutPoint& output); + void UnSelect(const COutPoint& outpoint); /** * Unselects all outputs. */ @@ -115,12 +142,7 @@ public: private: //! Selected inputs (inputs that will be used, regardless of whether they're optimal or not) - std::set<COutPoint> m_selected_inputs; - //! Map of external inputs to include in the transaction - //! These are not in the wallet, so we need to track them separately - std::map<COutPoint, CTxOut> m_external_txouts; - //! Map of COutPoints to the maximum weight for that input - std::map<COutPoint, int64_t> m_input_weights; + std::map<COutPoint, PreselectedInput> m_selected; }; } // namespace wallet |