diff options
author | Luke Dashjr <luke-jr+git@utopios.org> | 2020-02-22 01:52:47 +0000 |
---|---|---|
committer | Luke Dashjr <luke-jr+git@utopios.org> | 2020-04-02 16:01:36 +0000 |
commit | 144b2f85da4d51bf7d72b987888ddcaf5b429eed (patch) | |
tree | 756637308d5c336f6b45819936d99cb11d1638e9 /src/wallet | |
parent | b86cd155f6f661052042048aa7cfc2a397afe4f7 (diff) |
Wallet: Require usage of new CAddressBookData::setLabel to change label
Diffstat (limited to 'src/wallet')
-rw-r--r-- | src/wallet/wallet.cpp | 2 | ||||
-rw-r--r-- | src/wallet/wallet.h | 10 | ||||
-rw-r--r-- | src/wallet/walletdb.cpp | 4 |
3 files changed, 12 insertions, 4 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 6737270e52..6b061308ec 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -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; } diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index c6f288a480..47268ba88c 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -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 diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index 2e08a044da..568b21ed00 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -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; |