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

Method SetAddressBookWithDB

src/wallet/wallet.cpp:2395–2413  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2393}
2394
2395bool CWallet::SetAddressBookWithDB(WalletBatch& batch, const CTxDestination& address, const std::string& strName, const std::string& strPurpose)
2396{
2397 bool fUpdated = false;
2398 bool is_mine;
2399 {
2400 LOCK(cs_wallet);
2401 std::map<CTxDestination, CAddressBookData>::iterator mi = m_address_book.find(address);
2402 fUpdated = (mi != m_address_book.end() && !mi->second.IsChange());
2403 m_address_book[address].SetLabel(strName);
2404 if (!strPurpose.empty()) /* update purpose only if requested */
2405 m_address_book[address].purpose = strPurpose;
2406 is_mine = IsMine(address) != ISMINE_NO;
2407 }
2408 NotifyAddressBookChanged(address, strName, is_mine,
2409 strPurpose, (fUpdated ? CT_UPDATED : CT_NEW));
2410 if (!strPurpose.empty() && !batch.WritePurpose(EncodeDestination(address), strPurpose))
2411 return false;
2412 return batch.WriteName(EncodeDestination(address), strName);
2413}
2414
2415bool CWallet::SetAddressBook(const CTxDestination& address, const std::string& strName, const std::string& strPurpose)
2416{

Callers

nothing calls this directly

Calls 9

NotifyAddressBookChangedFunction · 0.85
EncodeDestinationFunction · 0.85
findMethod · 0.80
IsChangeMethod · 0.80
SetLabelMethod · 0.80
WritePurposeMethod · 0.80
WriteNameMethod · 0.80
endMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected