| 3502 | |
| 3503 | |
| 3504 | bool CWallet::SetAddressBook(const CTxDestination& address, const string& strName, const string& strPurpose) |
| 3505 | { |
| 3506 | bool fUpdated = false; |
| 3507 | { |
| 3508 | LOCK(cs_wallet); // mapAddressBook |
| 3509 | std::map<CTxDestination, CAddressBookData>::iterator mi = mapAddressBook.find(address); |
| 3510 | fUpdated = mi != mapAddressBook.end(); |
| 3511 | mapAddressBook[address].name = strName; |
| 3512 | if (!strPurpose.empty()) /* update purpose only if requested */ |
| 3513 | mapAddressBook[address].purpose = strPurpose; |
| 3514 | } |
| 3515 | NotifyAddressBookChanged(this, address, strName, ::IsMine(*this, address) != ISMINE_NO, |
| 3516 | strPurpose, (fUpdated ? CT_UPDATED : CT_NEW)); |
| 3517 | if (!fFileBacked) |
| 3518 | return false; |
| 3519 | if (!strPurpose.empty() && !CWalletDB(strWalletFile).WritePurpose(EncodeDestination(address), strPurpose)) |
| 3520 | return false; |
| 3521 | return CWalletDB(strWalletFile).WriteName(EncodeDestination(address), strName); |
| 3522 | } |
| 3523 | |
| 3524 | bool CWallet::DelAddressBook(const CTxDestination& address) |
| 3525 | { |