diff options
author | Andrew Chow <github@achow101.com> | 2023-01-23 16:59:25 -0500 |
---|---|---|
committer | Andrew Chow <github@achow101.com> | 2023-12-08 14:55:14 -0500 |
commit | 5321786b9d90eaf35059bb07e6beaaa2cbb257ac (patch) | |
tree | f7e73d72fb1df3c59ae2383c5bbdddc2ed1d4eca /src/wallet/coincontrol.cpp | |
parent | e1abfb5b2037ca4fe5a05aa578030c8016491c8b (diff) | |
download | bitcoin-5321786b9d90eaf35059bb07e6beaaa2cbb257ac.tar.xz |
coincontrol: Replace HasInputWeight with returning optional from Get
Diffstat (limited to 'src/wallet/coincontrol.cpp')
-rw-r--r-- | src/wallet/coincontrol.cpp | 19 |
1 files changed, 4 insertions, 15 deletions
diff --git a/src/wallet/coincontrol.cpp b/src/wallet/coincontrol.cpp index a4f3bdac23..94218b45c1 100644 --- a/src/wallet/coincontrol.cpp +++ b/src/wallet/coincontrol.cpp @@ -72,15 +72,10 @@ void CCoinControl::SetInputWeight(const COutPoint& outpoint, int64_t weight) m_selected[outpoint].SetInputWeight(weight); } -bool CCoinControl::HasInputWeight(const COutPoint& outpoint) const +std::optional<int64_t> CCoinControl::GetInputWeight(const COutPoint& outpoint) const { const auto it = m_selected.find(outpoint); - return it != m_selected.end() && it->second.HasInputWeight(); -} - -int64_t CCoinControl::GetInputWeight(const COutPoint& outpoint) const -{ - return m_selected.at(outpoint).GetInputWeight(); + return it != m_selected.end() ? it->second.GetInputWeight() : std::nullopt; } void PreselectedInput::SetTxOut(const CTxOut& txout) @@ -104,14 +99,8 @@ void PreselectedInput::SetInputWeight(int64_t weight) m_weight = weight; } -int64_t PreselectedInput::GetInputWeight() const -{ - assert(m_weight.has_value()); - return m_weight.value(); -} - -bool PreselectedInput::HasInputWeight() const +std::optional<int64_t> PreselectedInput::GetInputWeight() const { - return m_weight.has_value(); + return m_weight; } } // namespace wallet |