aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/spend.cpp
diff options
context:
space:
mode:
authorfurszy <matiasfurszyfer@protonmail.com>2022-11-22 11:39:35 -0300
committerfanquake <fanquake@gmail.com>2022-12-05 17:40:54 +0000
commit195f0dfd0ec7fadfbbb3d86decb3f6d96beae159 (patch)
treeaf72cba5175c12e917a13f06fe0946741b1d89dd /src/wallet/spend.cpp
parente5d097b639c7f75b530349b524836804cb753597 (diff)
downloadbitcoin-195f0dfd0ec7fadfbbb3d86decb3f6d96beae159.tar.xz
wallet: bugfix, 'CoinsResult::Erase' is erasing only one output of the set
The loop break shouldn't have being there. Github-Pull: #26560 Rebased-From: f930aefff9690a1e830d897d0a8c53f4219ae4a8
Diffstat (limited to 'src/wallet/spend.cpp')
-rw-r--r--src/wallet/spend.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/wallet/spend.cpp b/src/wallet/spend.cpp
index ce41a4e954..f534e10799 100644
--- a/src/wallet/spend.cpp
+++ b/src/wallet/spend.cpp
@@ -102,15 +102,13 @@ void CoinsResult::Clear() {
coins.clear();
}
-void CoinsResult::Erase(std::set<COutPoint>& preset_coins)
+void CoinsResult::Erase(const std::set<COutPoint>& coins_to_remove)
{
- for (auto& it : coins) {
- auto& vec = it.second;
- auto i = std::find_if(vec.begin(), vec.end(), [&](const COutput &c) { return preset_coins.count(c.outpoint);});
- if (i != vec.end()) {
- vec.erase(i);
- break;
- }
+ for (auto& [type, vec] : coins) {
+ auto remove_it = std::remove_if(vec.begin(), vec.end(), [&](const COutput& coin) {
+ return coins_to_remove.count(coin.outpoint) == 1;
+ });
+ vec.erase(remove_it, vec.end());
}
}