diff options
author | Aurèle Oulès <aurele@oules.com> | 2022-09-12 12:13:17 +0200 |
---|---|---|
committer | Aurèle Oulès <aurele@oules.com> | 2023-04-26 10:16:16 +0200 |
commit | 94776621ba6a79f3197ec71250bc48e974ad5e4a (patch) | |
tree | 7529d04bf923bd9f63f78da80b5b50e4b5e415e2 /src/wallet/coincontrol.cpp | |
parent | 1db23da6e163e793458ec702a9601d2837aea9cb (diff) | |
download | bitcoin-94776621ba6a79f3197ec71250bc48e974ad5e4a.tar.xz |
wallet: Move CoinCointrol definitions to .cpp
Move definitions to coincontrol.cpp and add documentation.
Diffstat (limited to 'src/wallet/coincontrol.cpp')
-rw-r--r-- | src/wallet/coincontrol.cpp | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/src/wallet/coincontrol.cpp b/src/wallet/coincontrol.cpp index ad2fab4b7d..d87b54e35c 100644 --- a/src/wallet/coincontrol.cpp +++ b/src/wallet/coincontrol.cpp @@ -11,4 +11,72 @@ CCoinControl::CCoinControl() { m_avoid_partial_spends = gArgs.GetBoolArg("-avoidpartialspends", DEFAULT_AVOIDPARTIALSPENDS); } + +bool CCoinControl::HasSelected() const +{ + return !m_selected_inputs.empty(); +} + +bool CCoinControl::IsSelected(const COutPoint& output) const +{ + return m_selected_inputs.count(output) > 0; +} + +bool CCoinControl::IsExternalSelected(const COutPoint& output) const +{ + return m_external_txouts.count(output) > 0; +} + +std::optional<CTxOut> CCoinControl::GetExternalOutput(const COutPoint& outpoint) const +{ + const auto ext_it = m_external_txouts.find(outpoint); + if (ext_it == m_external_txouts.end()) { + return std::nullopt; + } + + return std::make_optional(ext_it->second); +} + +void CCoinControl::Select(const COutPoint& output) +{ + m_selected_inputs.insert(output); +} + +void CCoinControl::SelectExternal(const COutPoint& outpoint, const CTxOut& txout) +{ + m_selected_inputs.insert(outpoint); + m_external_txouts.emplace(outpoint, txout); +} + +void CCoinControl::UnSelect(const COutPoint& output) +{ + m_selected_inputs.erase(output); +} + +void CCoinControl::UnSelectAll() +{ + m_selected_inputs.clear(); +} + +void CCoinControl::ListSelected(std::vector<COutPoint>& vOutpoints) const +{ + vOutpoints.assign(m_selected_inputs.begin(), m_selected_inputs.end()); +} + +void CCoinControl::SetInputWeight(const COutPoint& outpoint, int64_t weight) +{ + m_input_weights[outpoint] = weight; +} + +bool CCoinControl::HasInputWeight(const COutPoint& outpoint) const +{ + return m_input_weights.count(outpoint) > 0; +} + +int64_t CCoinControl::GetInputWeight(const COutPoint& outpoint) const +{ + auto it = m_input_weights.find(outpoint); + assert(it != m_input_weights.end()); + return it->second; +} } // namespace wallet |