Skip to content

Commit 2952c46

Browse files
committed
Wallet: Replace CAddressBookData.name with GetLabel() method
1 parent d7092c3 commit 2952c46

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

src/interfaces/wallet.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ class WalletImpl : public Wallet
156156
return false;
157157
}
158158
if (name) {
159-
*name = it->second.name;
159+
*name = it->second.GetLabel();
160160
}
161161
if (is_mine) {
162162
*is_mine = m_wallet->IsMine(dest);
@@ -172,7 +172,7 @@ class WalletImpl : public Wallet
172172
std::vector<WalletAddress> result;
173173
for (const auto& item : m_wallet->m_address_book) {
174174
if (item.second.IsChange()) continue;
175-
result.emplace_back(item.first, m_wallet->IsMine(item.first), item.second.name, item.second.purpose);
175+
result.emplace_back(item.first, m_wallet->IsMine(item.first), item.second.GetLabel(), item.second.purpose);
176176
}
177177
return result;
178178
}

src/wallet/rpcdump.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ static bool GetWalletAddressesForKey(LegacyScriptPubKeyMan* spk_man, const CWall
6666
strAddr += ",";
6767
}
6868
strAddr += EncodeDestination(dest);
69-
strLabel = EncodeDumpString(address_book_entry->name);
69+
strLabel = EncodeDumpString(address_book_entry->GetLabel());
7070
fLabelFound = true;
7171
}
7272
}

src/wallet/rpcwallet.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ static UniValue listaddressgroupings(const JSONRPCRequest& request)
501501
{
502502
const auto* address_book_entry = pwallet->FindAddressBookEntry(address);
503503
if (address_book_entry) {
504-
addressInfo.push_back(address_book_entry->name);
504+
addressInfo.push_back(address_book_entry->GetLabel());
505505
}
506506
}
507507
jsonGrouping.push_back(addressInfo);
@@ -1109,7 +1109,7 @@ static UniValue ListReceived(interfaces::Chain::Lock& locked_chain, const CWalle
11091109
{
11101110
if (item_it->second.IsChange()) continue;
11111111
const CTxDestination& address = item_it->first;
1112-
const std::string& label = item_it->second.name;
1112+
const std::string& label = item_it->second.GetLabel();
11131113
auto it = mapTally.find(address);
11141114
if (it == mapTally.end() && !fIncludeEmpty)
11151115
continue;
@@ -1311,7 +1311,7 @@ static void ListTransactions(interfaces::Chain::Lock& locked_chain, const CWalle
13111311
entry.pushKV("amount", ValueFromAmount(-s.amount));
13121312
const auto* address_book_entry = pwallet->FindAddressBookEntry(s.destination);
13131313
if (address_book_entry) {
1314-
entry.pushKV("label", address_book_entry->name);
1314+
entry.pushKV("label", address_book_entry->GetLabel());
13151315
}
13161316
entry.pushKV("vout", s.vout);
13171317
entry.pushKV("fee", ValueFromAmount(-nFee));
@@ -1329,7 +1329,7 @@ static void ListTransactions(interfaces::Chain::Lock& locked_chain, const CWalle
13291329
std::string label;
13301330
const auto* address_book_entry = pwallet->FindAddressBookEntry(r.destination);
13311331
if (address_book_entry) {
1332-
label = address_book_entry->name;
1332+
label = address_book_entry->GetLabel();
13331333
}
13341334
if (filter_label && label != *filter_label) {
13351335
continue;
@@ -2963,7 +2963,7 @@ static UniValue listunspent(const JSONRPCRequest& request)
29632963

29642964
const auto* address_book_entry = pwallet->FindAddressBookEntry(address);
29652965
if (address_book_entry) {
2966-
entry.pushKV("label", address_book_entry->name);
2966+
entry.pushKV("label", address_book_entry->GetLabel());
29672967
}
29682968

29692969
std::unique_ptr<SigningProvider> provider = pwallet->GetSolvingProvider(scriptPubKey);
@@ -3710,7 +3710,7 @@ static UniValue AddressBookDataToJSON(const CAddressBookData& data, const bool v
37103710
{
37113711
UniValue ret(UniValue::VOBJ);
37123712
if (verbose) {
3713-
ret.pushKV("name", data.name);
3713+
ret.pushKV("name", data.GetLabel());
37143714
}
37153715
ret.pushKV("purpose", data.purpose);
37163716
return ret;
@@ -3822,7 +3822,7 @@ UniValue getaddressinfo(const JSONRPCRequest& request)
38223822
// value of the name key/value pair in the labels array below.
38233823
const auto* address_book_entry = pwallet->FindAddressBookEntry(dest);
38243824
if (pwallet->chain().rpcEnableDeprecated("label") && address_book_entry) {
3825-
ret.pushKV("label", address_book_entry->name);
3825+
ret.pushKV("label", address_book_entry->GetLabel());
38263826
}
38273827

38283828
ret.pushKV("ischange", pwallet->IsChange(scriptPubKey));
@@ -3851,7 +3851,7 @@ UniValue getaddressinfo(const JSONRPCRequest& request)
38513851
if (pwallet->chain().rpcEnableDeprecated("labelspurpose")) {
38523852
labels.push_back(AddressBookDataToJSON(*address_book_entry, true));
38533853
} else {
3854-
labels.push_back(address_book_entry->name);
3854+
labels.push_back(address_book_entry->GetLabel());
38553855
}
38563856
}
38573857
ret.pushKV("labels", std::move(labels));
@@ -3897,7 +3897,7 @@ static UniValue getaddressesbylabel(const JSONRPCRequest& request)
38973897
std::set<std::string> addresses;
38983898
for (const std::pair<const CTxDestination, CAddressBookData>& item : pwallet->m_address_book) {
38993899
if (item.second.IsChange()) continue;
3900-
if (item.second.name == label) {
3900+
if (item.second.GetLabel() == label) {
39013901
std::string address = EncodeDestination(item.first);
39023902
// CWallet::m_address_book is not expected to contain duplicate
39033903
// address strings, but build a separate set as a precaution just in
@@ -3963,7 +3963,7 @@ static UniValue listlabels(const JSONRPCRequest& request)
39633963
for (const std::pair<const CTxDestination, CAddressBookData>& entry : pwallet->m_address_book) {
39643964
if (entry.second.IsChange()) continue;
39653965
if (purpose.empty() || entry.second.purpose == purpose) {
3966-
label_set.insert(entry.second.name);
3966+
label_set.insert(entry.second.GetLabel());
39673967
}
39683968
}
39693969

src/wallet/wallet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3472,7 +3472,7 @@ std::set<CTxDestination> CWallet::GetLabelAddresses(const std::string& label) co
34723472
{
34733473
if (item.second.IsChange()) continue;
34743474
const CTxDestination& address = item.first;
3475-
const std::string& strName = item.second.name;
3475+
const std::string& strName = item.second.GetLabel();
34763476
if (strName == label)
34773477
result.insert(address);
34783478
}

src/wallet/wallet.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,15 +185,15 @@ class CAddressBookData
185185
bool m_change{true};
186186
std::string m_label;
187187
public:
188-
const std::string& name;
189188
std::string purpose;
190189

191-
CAddressBookData() : name(m_label), purpose("unknown") {}
190+
CAddressBookData() : purpose("unknown") {}
192191

193192
typedef std::map<std::string, std::string> StringMap;
194193
StringMap destdata;
195194

196195
bool IsChange() const { return m_change; }
196+
const std::string& GetLabel() const { return m_label; }
197197
void SetLabel(const std::string& label) {
198198
m_change = false;
199199
m_label = label;

0 commit comments

Comments
 (0)