MCPcopy Create free account
hub / github.com/ElementsProject/elements / DelAddressBook

Method DelAddressBook

src/wallet/wallet.cpp:2421–2448  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2419}
2420
2421bool CWallet::DelAddressBook(const CTxDestination& address)
2422{
2423 bool is_mine;
2424 WalletBatch batch(GetDatabase());
2425 {
2426 LOCK(cs_wallet);
2427 // If we want to delete receiving addresses, we need to take care that DestData "used" (and possibly newer DestData) gets preserved (and the "deleted" address transformed into a change entry instead of actually being deleted)
2428 // NOTE: This isn't a problem for sending addresses because they never have any DestData yet!
2429 // When adding new DestData, it should be considered here whether to retain or delete it (or move it?).
2430 if (IsMine(address)) {
2431 WalletLogPrintf("%s called with IsMine address, NOT SUPPORTED. Please report this bug! %s\n", __func__, PACKAGE_BUGREPORT);
2432 return false;
2433 }
2434 // Delete destdata tuples associated with address
2435 std::string strAddress = EncodeDestination(address);
2436 for (const std::pair<const std::string, std::string> &item : m_address_book[address].destdata)
2437 {
2438 batch.EraseDestData(strAddress, item.first);
2439 }
2440 m_address_book.erase(address);
2441 is_mine = IsMine(address) != ISMINE_NO;
2442 }
2443
2444 NotifyAddressBookChanged(address, "", is_mine, "", CT_DELETED);
2445
2446 batch.ErasePurpose(EncodeDestination(address));
2447 return batch.EraseName(EncodeDestination(address));
2448}
2449
2450size_t CWallet::KeypoolCountExternalKeys() const
2451{

Callers 1

delAddressBookMethod · 0.80

Calls 6

EncodeDestinationFunction · 0.85
NotifyAddressBookChangedFunction · 0.85
EraseDestDataMethod · 0.80
ErasePurposeMethod · 0.80
EraseNameMethod · 0.80
eraseMethod · 0.45

Tested by

no test coverage detected