Skip to content

Commit 144b2f8

Browse files
committed
Wallet: Require usage of new CAddressBookData::setLabel to change label
1 parent b86cd15 commit 144b2f8

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

src/wallet/wallet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3193,7 +3193,7 @@ bool CWallet::SetAddressBookWithDB(WalletBatch& batch, const CTxDestination& add
31933193
LOCK(cs_wallet);
31943194
std::map<CTxDestination, CAddressBookData>::iterator mi = m_address_book.find(address);
31953195
fUpdated = mi != m_address_book.end();
3196-
m_address_book[address].name = strName;
3196+
m_address_book[address].SetLabel(strName);
31973197
if (!strPurpose.empty()) /* update purpose only if requested */
31983198
m_address_book[address].purpose = strPurpose;
31993199
}

src/wallet/wallet.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,14 +181,20 @@ class ReserveDestination
181181
/** Address book data */
182182
class CAddressBookData
183183
{
184+
private:
185+
std::string m_label;
184186
public:
185-
std::string name;
187+
const std::string& name;
186188
std::string purpose;
187189

188-
CAddressBookData() : purpose("unknown") {}
190+
CAddressBookData() : name(m_label), purpose("unknown") {}
189191

190192
typedef std::map<std::string, std::string> StringMap;
191193
StringMap destdata;
194+
195+
void SetLabel(const std::string& label) {
196+
m_label = label;
197+
}
192198
};
193199

194200
struct CRecipient

src/wallet/walletdb.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,9 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue,
206206
if (strType == DBKeys::NAME) {
207207
std::string strAddress;
208208
ssKey >> strAddress;
209-
ssValue >> pwallet->m_address_book[DecodeDestination(strAddress)].name;
209+
std::string label;
210+
ssValue >> label;
211+
pwallet->m_address_book[DecodeDestination(strAddress)].SetLabel(label);
210212
} else if (strType == DBKeys::PURPOSE) {
211213
std::string strAddress;
212214
ssKey >> strAddress;

0 commit comments

Comments
 (0)