diff options
author | S3RK <1466284+s3rk@users.noreply.github.com> | 2022-11-29 19:40:40 -0300 |
---|---|---|
committer | furszy <matiasfurszyfer@protonmail.com> | 2022-12-02 12:39:15 -0300 |
commit | 3282fad59908da328f8323e1213344fe58ccf69e (patch) | |
tree | 1b4617d78a0fb72b0727e8b4c733540d7e1a0323 /src/wallet/coinselection.cpp | |
parent | c4e3b7d6a154e82cdb902fd7bcb7b725aebde5ea (diff) |
wallet: add assert to SelectionResult::Merge for safety
Diffstat (limited to 'src/wallet/coinselection.cpp')
-rw-r--r-- | src/wallet/coinselection.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/wallet/coinselection.cpp b/src/wallet/coinselection.cpp index a8be6cd83a..b889d31928 100644 --- a/src/wallet/coinselection.cpp +++ b/src/wallet/coinselection.cpp @@ -452,12 +452,16 @@ void SelectionResult::AddInputs(const std::set<COutput>& inputs, bool subtract_f void SelectionResult::Merge(const SelectionResult& other) { + // Obtain the expected selected inputs count after the merge (for now, duplicates are not allowed) + const size_t expected_count = m_selected_inputs.size() + other.m_selected_inputs.size(); + m_target += other.m_target; m_use_effective |= other.m_use_effective; if (m_algo == SelectionAlgorithm::MANUAL) { m_algo = other.m_algo; } util::insert(m_selected_inputs, other.m_selected_inputs); + assert(m_selected_inputs.size() == expected_count); } const std::set<COutput>& SelectionResult::GetInputSet() const |