diff options
| author | Luke Dashjr <[email protected]> | 2020-02-22 02:50:46 +0000 |
|---|---|---|
| committer | Luke Dashjr <[email protected]> | 2020-04-02 16:02:56 +0000 |
| commit | 8e64b8c84bcbd63caea06f3af087af1f0609eaf5 (patch) | |
| tree | b3d79070111058aaa90c0ca4ba9167fc7a0ba761 /src | |
| parent | Wallet: Add CAddressBookData::IsChange which returns true iff label has never... (diff) | |
| download | discoin-8e64b8c84bcbd63caea06f3af087af1f0609eaf5.tar.xz discoin-8e64b8c84bcbd63caea06f3af087af1f0609eaf5.zip | |
Wallet: New FindAddressBookEntry method to filter out change entries (and skip ->second everywhere)
Diffstat (limited to 'src')
| -rw-r--r-- | src/wallet/wallet.cpp | 10 | ||||
| -rw-r--r-- | src/wallet/wallet.h | 1 |
2 files changed, 11 insertions, 0 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 6b061308e..ab36dacf3 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 788f29c03..c681dd28c 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); |