diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 2d0ccece0..ed8755f59 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2636,19 +2636,15 @@ void CWallet::LoadDestData(const CTxDestination &dest, const std::string &key, c m_address_book[dest].destdata.insert(std::make_pair(key, value)); } +bool CWallet::IsUsedInAddrBook(const CAddressBookData& data) const +{ + return data.destdata.find("used") != data.destdata.end(); +} + bool CWallet::IsAddressUsed(const CTxDestination& dest) const { - const std::string key{"used"}; std::map::const_iterator i = m_address_book.find(dest); - if(i != m_address_book.end()) - { - CAddressBookData::StringMap::const_iterator j = i->second.destdata.find(key); - if(j != i->second.destdata.end()) - { - return true; - } - } - return false; + return i != m_address_book.end() && IsUsedInAddrBook(i->second); } std::vector CWallet::GetAddressReceiveRequests() const diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index efe2c40c6..b1b8a3fa7 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -296,6 +296,7 @@ class CWallet final : public WalletStorage, public interfaces::Chain::Notificati std::atomic m_wallet_flags{0}; bool SetAddressBookWithDB(WalletBatch& batch, const CTxDestination& address, const std::string& strName, const std::string& strPurpose); + bool IsUsedInAddrBook(const CAddressBookData& data) const; //! Unsets a wallet flag and saves it to disk void UnsetWalletFlagWithDB(WalletBatch& batch, uint64_t flag);