aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLuke Dashjr <luke-jr+git@utopios.org>2020-02-22 02:50:46 +0000
committerLuke Dashjr <luke-jr+git@utopios.org>2020-04-02 16:02:56 +0000
commit8e64b8c84bcbd63caea06f3af087af1f0609eaf5 (patch)
treeb3d79070111058aaa90c0ca4ba9167fc7a0ba761 /src
parent65b6bdc2b164343ec3cc3d32a0297daff9e24fec (diff)
downloadbitcoin-8e64b8c84bcbd63caea06f3af087af1f0609eaf5.tar.xz
Wallet: New FindAddressBookEntry method to filter out change entries (and skip ->second everywhere)
Diffstat (limited to 'src')
-rw-r--r--src/wallet/wallet.cpp10
-rw-r--r--src/wallet/wallet.h1
2 files changed, 11 insertions, 0 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index 6b061308ec..ab36dacf37 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -4104,6 +4104,16 @@ std::shared_ptr<CWallet> CWallet::CreateWalletFromFile(interfaces::Chain& chain,
return walletInstance;
}
+const CAddressBookData* CWallet::FindAddressBookEntry(const CTxDestination& dest, bool allow_change) const
+{
+ const auto& address_book_it = m_address_book.find(dest);
+ if (address_book_it == m_address_book.end()) return nullptr;
+ if ((!allow_change) && address_book_it->second.IsChange()) {
+ return nullptr;
+ }
+ return &address_book_it->second;
+}
+
void CWallet::postInitProcess()
{
auto locked_chain = chain().lock();
diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h
index 788f29c039..c681dd28c8 100644
--- a/src/wallet/wallet.h
+++ b/src/wallet/wallet.h
@@ -785,6 +785,7 @@ public:
uint64_t nAccountingEntryNumber = 0;
std::map<CTxDestination, CAddressBookData> m_address_book GUARDED_BY(cs_wallet);
+ const CAddressBookData* FindAddressBookEntry(const CTxDestination&, bool allow_change = false) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
std::set<COutPoint> setLockedCoins GUARDED_BY(cs_wallet);