Wallet: Require usage of new CAddressBookData::setLabel to change label

This commit is contained in:
Luke Dashjr
2020-02-22 01:52:47 +00:00
parent b86cd155f6
commit 144b2f85da
3 changed files with 12 additions and 4 deletions

View File

@@ -3193,7 +3193,7 @@ bool CWallet::SetAddressBookWithDB(WalletBatch& batch, const CTxDestination& add
LOCK(cs_wallet);
std::map<CTxDestination, CAddressBookData>::iterator mi = m_address_book.find(address);
fUpdated = mi != m_address_book.end();
m_address_book[address].name = strName;
m_address_book[address].SetLabel(strName);
if (!strPurpose.empty()) /* update purpose only if requested */
m_address_book[address].purpose = strPurpose;
}

View File

@@ -181,14 +181,20 @@ public:
/** Address book data */
class CAddressBookData
{
private:
std::string m_label;
public:
std::string name;
const std::string& name;
std::string purpose;
CAddressBookData() : purpose("unknown") {}
CAddressBookData() : name(m_label), purpose("unknown") {}
typedef std::map<std::string, std::string> StringMap;
StringMap destdata;
void SetLabel(const std::string& label) {
m_label = label;
}
};
struct CRecipient

View File

@@ -206,7 +206,9 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue,
if (strType == DBKeys::NAME) {
std::string strAddress;
ssKey >> strAddress;
ssValue >> pwallet->m_address_book[DecodeDestination(strAddress)].name;
std::string label;
ssValue >> label;
pwallet->m_address_book[DecodeDestination(strAddress)].SetLabel(label);
} else if (strType == DBKeys::PURPOSE) {
std::string strAddress;
ssKey >> strAddress;