Skip to content

Commit 8e64b8c

Browse files
committed
Wallet: New FindAddressBookEntry method to filter out change entries (and skip ->second everywhere)
1 parent 65b6bdc commit 8e64b8c

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/wallet/wallet.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4104,6 +4104,16 @@ std::shared_ptr<CWallet> CWallet::CreateWalletFromFile(interfaces::Chain& chain,
41044104
return walletInstance;
41054105
}
41064106

4107+
const CAddressBookData* CWallet::FindAddressBookEntry(const CTxDestination& dest, bool allow_change) const
4108+
{
4109+
const auto& address_book_it = m_address_book.find(dest);
4110+
if (address_book_it == m_address_book.end()) return nullptr;
4111+
if ((!allow_change) && address_book_it->second.IsChange()) {
4112+
return nullptr;
4113+
}
4114+
return &address_book_it->second;
4115+
}
4116+
41074117
void CWallet::postInitProcess()
41084118
{
41094119
auto locked_chain = chain().lock();

src/wallet/wallet.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,7 @@ class CWallet final : public WalletStorage, public interfaces::Chain::Notificati
785785
uint64_t nAccountingEntryNumber = 0;
786786

787787
std::map<CTxDestination, CAddressBookData> m_address_book GUARDED_BY(cs_wallet);
788+
const CAddressBookData* FindAddressBookEntry(const CTxDestination&, bool allow_change = false) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
788789

789790
std::set<COutPoint> setLockedCoins GUARDED_BY(cs_wallet);
790791

0 commit comments

Comments
 (0)