@@ -63,76 +63,62 @@ class CCoinControl
63
63
64
64
CCoinControl ();
65
65
66
- bool HasSelected () const
67
- {
68
- return !m_selected_inputs.empty ();
69
- }
70
-
71
- bool IsSelected (const COutPoint& output) const
72
- {
73
- return m_selected_inputs.count (output) > 0 ;
74
- }
75
-
76
- bool IsExternalSelected (const COutPoint& output) const
77
- {
78
- return m_external_txouts.count (output) > 0 ;
79
- }
80
-
81
- std::optional<CTxOut> GetExternalOutput (const COutPoint& outpoint) const
82
- {
83
- const auto ext_it = m_external_txouts.find (outpoint);
84
- if (ext_it == m_external_txouts.end ()) {
85
- return std::nullopt;
86
- }
87
-
88
- return std::make_optional (ext_it->second );
89
- }
90
-
91
- void Select (const COutPoint& output)
92
- {
93
- m_selected_inputs.insert (output);
94
- }
95
-
96
- void SelectExternal (const COutPoint& outpoint, const CTxOut& txout)
97
- {
98
- m_selected_inputs.insert (outpoint);
99
- m_external_txouts.emplace (outpoint, txout);
100
- }
101
-
102
- void UnSelect (const COutPoint& output)
103
- {
104
- m_selected_inputs.erase (output);
105
- }
106
-
107
- void UnSelectAll ()
108
- {
109
- m_selected_inputs.clear ();
110
- }
111
-
112
- void ListSelected (std::vector<COutPoint>& vOutpoints) const
113
- {
114
- vOutpoints.assign (m_selected_inputs.begin (), m_selected_inputs.end ());
115
- }
116
-
117
- void SetInputWeight (const COutPoint& outpoint, int64_t weight)
118
- {
119
- m_input_weights[outpoint] = weight;
120
- }
121
-
122
- bool HasInputWeight (const COutPoint& outpoint) const
123
- {
124
- return m_input_weights.count (outpoint) > 0 ;
125
- }
126
-
127
- int64_t GetInputWeight (const COutPoint& outpoint) const
128
- {
129
- auto it = m_input_weights.find (outpoint);
130
- assert (it != m_input_weights.end ());
131
- return it->second ;
132
- }
66
+ /* *
67
+ * Returns true if there are pre-selected inputs.
68
+ */
69
+ bool HasSelected () const ;
70
+ /* *
71
+ * Returns true if the given output is pre-selected.
72
+ */
73
+ bool IsSelected (const COutPoint& output) const ;
74
+ /* *
75
+ * Returns true if the given output is selected as an external input.
76
+ */
77
+ bool IsExternalSelected (const COutPoint& output) const ;
78
+ /* *
79
+ * Returns the external output for the given outpoint if it exists.
80
+ */
81
+ std::optional<CTxOut> GetExternalOutput (const COutPoint& outpoint) const ;
82
+ /* *
83
+ * Lock-in the given output for spending.
84
+ * The output will be included in the transaction even if it's not the most optimal choice.
85
+ */
86
+ void Select (const COutPoint& output);
87
+ /* *
88
+ * Lock-in the given output as an external input for spending because it is not in the wallet.
89
+ * The output will be included in the transaction even if it's not the most optimal choice.
90
+ */
91
+ void SelectExternal (const COutPoint& outpoint, const CTxOut& txout);
92
+ /* *
93
+ * Unselects the given output.
94
+ */
95
+ void UnSelect (const COutPoint& output);
96
+ /* *
97
+ * Unselects all outputs.
98
+ */
99
+ void UnSelectAll ();
100
+ /* *
101
+ * List the selected inputs.
102
+ */
103
+ void ListSelected (std::vector<COutPoint>& vOutpoints) const ;
104
+ /* *
105
+ * Set an input's weight.
106
+ */
107
+ void SetInputWeight (const COutPoint& outpoint, int64_t weight);
108
+ /* *
109
+ * Returns true if the input weight is set.
110
+ */
111
+ bool HasInputWeight (const COutPoint& outpoint) const ;
112
+ /* *
113
+ * Returns the input weight.
114
+ */
115
+ int64_t GetInputWeight (const COutPoint& outpoint) const ;
133
116
134
117
private:
118
+ // ! Selected inputs (inputs that will be used, regardless of whether they're optimal or not)
135
119
std::set<COutPoint> m_selected_inputs;
120
+ // ! Map of external inputs to include in the transaction
121
+ // ! These are not in the wallet, so we need to track them separately
136
122
std::map<COutPoint, CTxOut> m_external_txouts;
137
123
// ! Map of COutPoints to the maximum weight for that input
138
124
std::map<COutPoint, int64_t > m_input_weights;
0 commit comments