From 2b48642499016cb357e4bcec32481cd50361194e Mon Sep 17 00:00:00 2001 From: furszy Date: Sat, 11 Jun 2022 11:38:19 -0300 Subject: [PATCH] refactor: use ForEachAddrBookEntry in interfaces::getAddresses --- src/interfaces/wallet.h | 2 +- src/wallet/interfaces.cpp | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/interfaces/wallet.h b/src/interfaces/wallet.h index f26ac866dcf95..b3cb0ae3875d8 100644 --- a/src/interfaces/wallet.h +++ b/src/interfaces/wallet.h @@ -114,7 +114,7 @@ class Wallet std::string* purpose) = 0; //! Get wallet address list. - virtual std::vector getAddresses() = 0; + virtual std::vector getAddresses() const = 0; //! Get receive requests. virtual std::vector getAddressReceiveRequests() = 0; diff --git a/src/wallet/interfaces.cpp b/src/wallet/interfaces.cpp index 5cfcf16e16424..823deed71ba91 100644 --- a/src/wallet/interfaces.cpp +++ b/src/wallet/interfaces.cpp @@ -204,14 +204,14 @@ class WalletImpl : public Wallet } return true; } - std::vector getAddresses() override + std::vector getAddresses() const override { LOCK(m_wallet->cs_wallet); std::vector result; - for (const auto& item : m_wallet->m_address_book) { - if (item.second.IsChange()) continue; - result.emplace_back(item.first, m_wallet->IsMine(item.first), item.second.GetLabel(), item.second.purpose); - } + m_wallet->ForEachAddrBookEntry([&](const CTxDestination& dest, const std::string& label, const std::string& purpose, bool is_change) EXCLUSIVE_LOCKS_REQUIRED(m_wallet->cs_wallet) { + if (is_change) return; + result.emplace_back(dest, m_wallet->IsMine(dest), label, purpose); + }); return result; } std::vector getAddressReceiveRequests() override {