diff options
author | furszy <matiasfurszyfer@protonmail.com> | 2022-06-11 11:38:19 -0300 |
---|---|---|
committer | furszy <matiasfurszyfer@protonmail.com> | 2022-06-21 10:23:20 -0300 |
commit | 2b48642499016cb357e4bcec32481cd50361194e (patch) | |
tree | 21ae7f6ca56f1e8ade4ec9f6eda2a2c5af2d0c3c | |
parent | 032842ae4196aaed5ea3567ea01a61ed75ab2edd (diff) |
refactor: use ForEachAddrBookEntry in interfaces::getAddresses
-rw-r--r-- | src/interfaces/wallet.h | 2 | ||||
-rw-r--r-- | 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 f26ac866dc..b3cb0ae387 100644 --- a/src/interfaces/wallet.h +++ b/src/interfaces/wallet.h @@ -114,7 +114,7 @@ public: std::string* purpose) = 0; //! Get wallet address list. - virtual std::vector<WalletAddress> getAddresses() = 0; + virtual std::vector<WalletAddress> getAddresses() const = 0; //! Get receive requests. virtual std::vector<std::string> getAddressReceiveRequests() = 0; diff --git a/src/wallet/interfaces.cpp b/src/wallet/interfaces.cpp index 5cfcf16e16..823deed71b 100644 --- a/src/wallet/interfaces.cpp +++ b/src/wallet/interfaces.cpp @@ -204,14 +204,14 @@ public: } return true; } - std::vector<WalletAddress> getAddresses() override + std::vector<WalletAddress> getAddresses() const override { LOCK(m_wallet->cs_wallet); std::vector<WalletAddress> 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<std::string> getAddressReceiveRequests() override { |