Skip to content

Commit 4060c50

Browse files
committed
wallet: add input weights to CCoinControl
In order to allow coin selection to take weights from the user, CCoinControl needs to be able to set and get them.
1 parent e3de7cb commit 4060c50

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/wallet/coincontrol.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,28 @@ class CCoinControl
115115
vOutpoints.assign(setSelected.begin(), setSelected.end());
116116
}
117117

118+
void SetInputWeight(const COutPoint& outpoint, int64_t weight)
119+
{
120+
m_input_weights[outpoint] = weight;
121+
}
122+
123+
bool HasInputWeight(const COutPoint& outpoint) const
124+
{
125+
return m_input_weights.count(outpoint) > 0;
126+
}
127+
128+
int64_t GetInputWeight(const COutPoint& outpoint) const
129+
{
130+
auto it = m_input_weights.find(outpoint);
131+
assert(it != m_input_weights.end());
132+
return it->second;
133+
}
134+
118135
private:
119136
std::set<COutPoint> setSelected;
120137
std::map<COutPoint, CTxOut> m_external_txouts;
138+
//! Map of COutPoints to the maximum weight for that input
139+
std::map<COutPoint, int64_t> m_input_weights;
121140
};
122141
} // namespace wallet
123142

0 commit comments

Comments
 (0)