aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfanquake <fanquake@gmail.com>2021-12-14 09:27:18 +0800
committerfanquake <fanquake@gmail.com>2021-12-14 09:27:27 +0800
commitab879d9885f7e0abf0a8b834d1ade00bec0b816d (patch)
tree6c60ba170b9505a2d56985276253d3c9dfb3156f /src
parent5dd28e5cff8a8177b969181ecb58d045e7f80a72 (diff)
parentfa26c5564429d3201f43850afaf1b4df2ed11ad9 (diff)
downloadbitcoin-ab879d9885f7e0abf0a8b834d1ade00bec0b816d.tar.xz
Merge bitcoin/bitcoin#23762: wallet: Replace Assume with Assert where needed in coinselection
fa26c5564429d3201f43850afaf1b4df2ed11ad9 wallet: Replace Assume with Assert where needed in coinselection (MarcoFalke) Pull request description: `Assume` should only be used when a failed check is recoverable. The checks here don't recover and would run into UB, so use `Assert` instead. ACKs for top commit: theStack: Code-review ACK fa26c5564429d3201f43850afaf1b4df2ed11ad9 Tree-SHA512: 0cf9435f9ec44794022ce0274cba602aec95102ab73f4c8a93dae54ef4c0a594f6a81640477039719ddfb6f23b05f8ece3e4886ef7f8a725efff45685ac49d92
Diffstat (limited to 'src')
-rw-r--r--src/wallet/coinselection.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/wallet/coinselection.cpp b/src/wallet/coinselection.cpp
index ddf6a8b829..25874c601c 100644
--- a/src/wallet/coinselection.cpp
+++ b/src/wallet/coinselection.cpp
@@ -390,8 +390,7 @@ void SelectionResult::ComputeAndSetWaste(CAmount change_cost)
CAmount SelectionResult::GetWaste() const
{
- Assume(m_waste != std::nullopt);
- return *m_waste;
+ return *Assert(m_waste);
}
CAmount SelectionResult::GetSelectedValue() const
@@ -425,8 +424,8 @@ std::vector<CInputCoin> SelectionResult::GetShuffledInputVector() const
bool SelectionResult::operator<(SelectionResult other) const
{
- Assume(m_waste != std::nullopt);
- Assume(other.m_waste != std::nullopt);
+ Assert(m_waste.has_value());
+ Assert(other.m_waste.has_value());
// As this operator is only used in std::min_element, we want the result that has more inputs when waste are equal.
return *m_waste < *other.m_waste || (*m_waste == *other.m_waste && m_selected_inputs.size() > other.m_selected_inputs.size());
}