Skip to content

Commit b86cd15

Browse files
committed
scripted-diff: Wallet: Rename mapAddressBook to m_address_book
Previous versions assumed absence of an entry in mapAddressBook indicated change. This no longer holds true (due to bugs) and will shortly be made intentional. Renaming the field helps ensure that old code using mapAddressBook directly gets checked for necessary rebasing. -BEGIN VERIFY SCRIPT- sed -i -e 's/mapAddressBook/m_address_book/g' $(git grep -l 'mapAddressBook' ./src) -END VERIFY SCRIPT-
1 parent 41fa292 commit b86cd15

File tree

9 files changed

+47
-47
lines changed

9 files changed

+47
-47
lines changed

src/interfaces/wallet.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ class WalletImpl : public Wallet
151151
std::string* purpose) override
152152
{
153153
LOCK(m_wallet->cs_wallet);
154-
auto it = m_wallet->mapAddressBook.find(dest);
155-
if (it == m_wallet->mapAddressBook.end()) {
154+
auto it = m_wallet->m_address_book.find(dest);
155+
if (it == m_wallet->m_address_book.end()) {
156156
return false;
157157
}
158158
if (name) {
@@ -170,7 +170,7 @@ class WalletImpl : public Wallet
170170
{
171171
LOCK(m_wallet->cs_wallet);
172172
std::vector<WalletAddress> result;
173-
for (const auto& item : m_wallet->mapAddressBook) {
173+
for (const auto& item : m_wallet->m_address_book) {
174174
result.emplace_back(item.first, m_wallet->IsMine(item.first), item.second.name, item.second.purpose);
175175
}
176176
return result;

src/qt/addresstablemodel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ struct AddressTableEntryLessThan
5555
static AddressTableEntry::Type translateTransactionType(const QString &strPurpose, bool isMine)
5656
{
5757
AddressTableEntry::Type addressType = AddressTableEntry::Hidden;
58-
// "refund" addresses aren't shown, and change addresses aren't in mapAddressBook at all.
58+
// "refund" addresses aren't shown, and change addresses aren't in m_address_book at all.
5959
if (strPurpose == "send")
6060
addressType = AddressTableEntry::Sending;
6161
else if (strPurpose == "receive")

src/qt/test/addressbooktests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ void TestAddAddressesToSendBook(interfaces::Node& node)
9797

9898
auto check_addbook_size = [&wallet](int expected_size) {
9999
LOCK(wallet->cs_wallet);
100-
QCOMPARE(static_cast<int>(wallet->mapAddressBook.size()), expected_size);
100+
QCOMPARE(static_cast<int>(wallet->m_address_book.size()), expected_size);
101101
};
102102

103103
// We should start with the two addresses we added earlier and nothing else.

src/wallet/rpcdump.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ static bool GetWalletAddressesForKey(LegacyScriptPubKeyMan* spk_man, const CWall
6060
CKey key;
6161
spk_man->GetKey(keyid, key);
6262
for (const auto& dest : GetAllDestinationsForKey(key.GetPubKey())) {
63-
if (pwallet->mapAddressBook.count(dest)) {
63+
if (pwallet->m_address_book.count(dest)) {
6464
if (!strAddr.empty()) {
6565
strAddr += ",";
6666
}
6767
strAddr += EncodeDestination(dest);
68-
strLabel = EncodeDumpString(pwallet->mapAddressBook.at(dest).name);
68+
strLabel = EncodeDumpString(pwallet->m_address_book.at(dest).name);
6969
fLabelFound = true;
7070
}
7171
}
@@ -168,7 +168,7 @@ UniValue importprivkey(const JSONRPCRequest& request)
168168
// label all new addresses, and label existing addresses if a
169169
// label was passed.
170170
for (const auto& dest : GetAllDestinationsForKey(pubkey)) {
171-
if (!request.params[1].isNull() || pwallet->mapAddressBook.count(dest) == 0) {
171+
if (!request.params[1].isNull() || pwallet->m_address_book.count(dest) == 0) {
172172
pwallet->SetAddressBook(dest, strLabel, "receive");
173173
}
174174
}

src/wallet/rpcwallet.cpp

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -505,8 +505,8 @@ static UniValue listaddressgroupings(const JSONRPCRequest& request)
505505
addressInfo.push_back(EncodeDestination(address));
506506
addressInfo.push_back(ValueFromAmount(balances[address]));
507507
{
508-
if (pwallet->mapAddressBook.find(address) != pwallet->mapAddressBook.end()) {
509-
addressInfo.push_back(pwallet->mapAddressBook.find(address)->second.name);
508+
if (pwallet->m_address_book.find(address) != pwallet->m_address_book.end()) {
509+
addressInfo.push_back(pwallet->m_address_book.find(address)->second.name);
510510
}
511511
}
512512
jsonGrouping.push_back(addressInfo);
@@ -1098,13 +1098,13 @@ static UniValue ListReceived(interfaces::Chain::Lock& locked_chain, const CWalle
10981098
UniValue ret(UniValue::VARR);
10991099
std::map<std::string, tallyitem> label_tally;
11001100

1101-
// Create mapAddressBook iterator
1101+
// Create m_address_book iterator
11021102
// If we aren't filtering, go from begin() to end()
1103-
auto start = pwallet->mapAddressBook.begin();
1104-
auto end = pwallet->mapAddressBook.end();
1103+
auto start = pwallet->m_address_book.begin();
1104+
auto end = pwallet->m_address_book.end();
11051105
// If we are filtering, find() the applicable entry
11061106
if (has_filtered_address) {
1107-
start = pwallet->mapAddressBook.find(filtered_address);
1107+
start = pwallet->m_address_book.find(filtered_address);
11081108
if (start != end) {
11091109
end = std::next(start);
11101110
}
@@ -1313,8 +1313,8 @@ static void ListTransactions(interfaces::Chain::Lock& locked_chain, const CWalle
13131313
MaybePushAddress(entry, s.destination);
13141314
entry.pushKV("category", "send");
13151315
entry.pushKV("amount", ValueFromAmount(-s.amount));
1316-
if (pwallet->mapAddressBook.count(s.destination)) {
1317-
entry.pushKV("label", pwallet->mapAddressBook.at(s.destination).name);
1316+
if (pwallet->m_address_book.count(s.destination)) {
1317+
entry.pushKV("label", pwallet->m_address_book.at(s.destination).name);
13181318
}
13191319
entry.pushKV("vout", s.vout);
13201320
entry.pushKV("fee", ValueFromAmount(-nFee));
@@ -1330,8 +1330,8 @@ static void ListTransactions(interfaces::Chain::Lock& locked_chain, const CWalle
13301330
for (const COutputEntry& r : listReceived)
13311331
{
13321332
std::string label;
1333-
if (pwallet->mapAddressBook.count(r.destination)) {
1334-
label = pwallet->mapAddressBook.at(r.destination).name;
1333+
if (pwallet->m_address_book.count(r.destination)) {
1334+
label = pwallet->m_address_book.at(r.destination).name;
13351335
}
13361336
if (filter_label && label != *filter_label) {
13371337
continue;
@@ -1355,7 +1355,7 @@ static void ListTransactions(interfaces::Chain::Lock& locked_chain, const CWalle
13551355
entry.pushKV("category", "receive");
13561356
}
13571357
entry.pushKV("amount", ValueFromAmount(r.amount));
1358-
if (pwallet->mapAddressBook.count(r.destination)) {
1358+
if (pwallet->m_address_book.count(r.destination)) {
13591359
entry.pushKV("label", label);
13601360
}
13611361
entry.pushKV("vout", r.vout);
@@ -2955,8 +2955,8 @@ static UniValue listunspent(const JSONRPCRequest& request)
29552955
if (fValidAddress) {
29562956
entry.pushKV("address", EncodeDestination(address));
29572957

2958-
auto i = pwallet->mapAddressBook.find(address);
2959-
if (i != pwallet->mapAddressBook.end()) {
2958+
auto i = pwallet->m_address_book.find(address);
2959+
if (i != pwallet->m_address_book.end()) {
29602960
entry.pushKV("label", i->second.name);
29612961
}
29622962

@@ -3814,8 +3814,8 @@ UniValue getaddressinfo(const JSONRPCRequest& request)
38143814
// DEPRECATED: Return label field if existing. Currently only one label can
38153815
// be associated with an address, so the label should be equivalent to the
38163816
// value of the name key/value pair in the labels array below.
3817-
if ((pwallet->chain().rpcEnableDeprecated("label")) && (pwallet->mapAddressBook.count(dest))) {
3818-
ret.pushKV("label", pwallet->mapAddressBook.at(dest).name);
3817+
if ((pwallet->chain().rpcEnableDeprecated("label")) && (pwallet->m_address_book.count(dest))) {
3818+
ret.pushKV("label", pwallet->m_address_book.at(dest).name);
38193819
}
38203820

38213821
ret.pushKV("ischange", pwallet->IsChange(scriptPubKey));
@@ -3838,8 +3838,8 @@ UniValue getaddressinfo(const JSONRPCRequest& request)
38383838
// stable if we allow multiple labels to be associated with an address in
38393839
// the future.
38403840
UniValue labels(UniValue::VARR);
3841-
std::map<CTxDestination, CAddressBookData>::const_iterator mi = pwallet->mapAddressBook.find(dest);
3842-
if (mi != pwallet->mapAddressBook.end()) {
3841+
std::map<CTxDestination, CAddressBookData>::const_iterator mi = pwallet->m_address_book.find(dest);
3842+
if (mi != pwallet->m_address_book.end()) {
38433843
// DEPRECATED: The previous behavior of returning an array containing a
38443844
// JSON object of `name` and `purpose` key/value pairs is deprecated.
38453845
if (pwallet->chain().rpcEnableDeprecated("labelspurpose")) {
@@ -3889,10 +3889,10 @@ static UniValue getaddressesbylabel(const JSONRPCRequest& request)
38893889
// Find all addresses that have the given label
38903890
UniValue ret(UniValue::VOBJ);
38913891
std::set<std::string> addresses;
3892-
for (const std::pair<const CTxDestination, CAddressBookData>& item : pwallet->mapAddressBook) {
3892+
for (const std::pair<const CTxDestination, CAddressBookData>& item : pwallet->m_address_book) {
38933893
if (item.second.name == label) {
38943894
std::string address = EncodeDestination(item.first);
3895-
// CWallet::mapAddressBook is not expected to contain duplicate
3895+
// CWallet::m_address_book is not expected to contain duplicate
38963896
// address strings, but build a separate set as a precaution just in
38973897
// case it does.
38983898
bool unique = addresses.emplace(address).second;
@@ -3953,7 +3953,7 @@ static UniValue listlabels(const JSONRPCRequest& request)
39533953

39543954
// Add to a set to sort by label name, then insert into Univalue array
39553955
std::set<std::string> label_set;
3956-
for (const std::pair<const CTxDestination, CAddressBookData>& entry : pwallet->mapAddressBook) {
3956+
for (const std::pair<const CTxDestination, CAddressBookData>& entry : pwallet->m_address_book) {
39573957
if (purpose.empty() || entry.second.purpose == purpose) {
39583958
label_set.insert(entry.second.name);
39593959
}

src/wallet/wallet.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,7 +1237,7 @@ bool CWallet::IsChange(const CScript& script) const
12371237
return true;
12381238

12391239
LOCK(cs_wallet);
1240-
if (!mapAddressBook.count(address))
1240+
if (!m_address_book.count(address))
12411241
return true;
12421242
}
12431243
return false;
@@ -3191,11 +3191,11 @@ bool CWallet::SetAddressBookWithDB(WalletBatch& batch, const CTxDestination& add
31913191
bool fUpdated = false;
31923192
{
31933193
LOCK(cs_wallet);
3194-
std::map<CTxDestination, CAddressBookData>::iterator mi = mapAddressBook.find(address);
3195-
fUpdated = mi != mapAddressBook.end();
3196-
mapAddressBook[address].name = strName;
3194+
std::map<CTxDestination, CAddressBookData>::iterator mi = m_address_book.find(address);
3195+
fUpdated = mi != m_address_book.end();
3196+
m_address_book[address].name = strName;
31973197
if (!strPurpose.empty()) /* update purpose only if requested */
3198-
mapAddressBook[address].purpose = strPurpose;
3198+
m_address_book[address].purpose = strPurpose;
31993199
}
32003200
NotifyAddressBookChanged(this, address, strName, IsMine(address) != ISMINE_NO,
32013201
strPurpose, (fUpdated ? CT_UPDATED : CT_NEW) );
@@ -3217,11 +3217,11 @@ bool CWallet::DelAddressBook(const CTxDestination& address)
32173217

32183218
// Delete destdata tuples associated with address
32193219
std::string strAddress = EncodeDestination(address);
3220-
for (const std::pair<const std::string, std::string> &item : mapAddressBook[address].destdata)
3220+
for (const std::pair<const std::string, std::string> &item : m_address_book[address].destdata)
32213221
{
32223222
WalletBatch(*database).EraseDestData(strAddress, item.first);
32233223
}
3224-
mapAddressBook.erase(address);
3224+
m_address_book.erase(address);
32253225
}
32263226

32273227
NotifyAddressBookChanged(this, address, "", IsMine(address) != ISMINE_NO, "", CT_DELETED);
@@ -3457,7 +3457,7 @@ std::set<CTxDestination> CWallet::GetLabelAddresses(const std::string& label) co
34573457
{
34583458
LOCK(cs_wallet);
34593459
std::set<CTxDestination> result;
3460-
for (const std::pair<const CTxDestination, CAddressBookData>& item : mapAddressBook)
3460+
for (const std::pair<const CTxDestination, CAddressBookData>& item : m_address_book)
34613461
{
34623462
const CTxDestination& address = item.first;
34633463
const std::string& strName = item.second.name;
@@ -3661,26 +3661,26 @@ bool CWallet::AddDestData(WalletBatch& batch, const CTxDestination &dest, const
36613661
if (boost::get<CNoDestination>(&dest))
36623662
return false;
36633663

3664-
mapAddressBook[dest].destdata.insert(std::make_pair(key, value));
3664+
m_address_book[dest].destdata.insert(std::make_pair(key, value));
36653665
return batch.WriteDestData(EncodeDestination(dest), key, value);
36663666
}
36673667

36683668
bool CWallet::EraseDestData(WalletBatch& batch, const CTxDestination &dest, const std::string &key)
36693669
{
3670-
if (!mapAddressBook[dest].destdata.erase(key))
3670+
if (!m_address_book[dest].destdata.erase(key))
36713671
return false;
36723672
return batch.EraseDestData(EncodeDestination(dest), key);
36733673
}
36743674

36753675
void CWallet::LoadDestData(const CTxDestination &dest, const std::string &key, const std::string &value)
36763676
{
3677-
mapAddressBook[dest].destdata.insert(std::make_pair(key, value));
3677+
m_address_book[dest].destdata.insert(std::make_pair(key, value));
36783678
}
36793679

36803680
bool CWallet::GetDestData(const CTxDestination &dest, const std::string &key, std::string *value) const
36813681
{
3682-
std::map<CTxDestination, CAddressBookData>::const_iterator i = mapAddressBook.find(dest);
3683-
if(i != mapAddressBook.end())
3682+
std::map<CTxDestination, CAddressBookData>::const_iterator i = m_address_book.find(dest);
3683+
if(i != m_address_book.end())
36843684
{
36853685
CAddressBookData::StringMap::const_iterator j = i->second.destdata.find(key);
36863686
if(j != i->second.destdata.end())
@@ -3696,7 +3696,7 @@ bool CWallet::GetDestData(const CTxDestination &dest, const std::string &key, st
36963696
std::vector<std::string> CWallet::GetDestValues(const std::string& prefix) const
36973697
{
36983698
std::vector<std::string> values;
3699-
for (const auto& address : mapAddressBook) {
3699+
for (const auto& address : m_address_book) {
37003700
for (const auto& data : address.second.destdata) {
37013701
if (!data.first.compare(0, prefix.size(), prefix)) {
37023702
values.emplace_back(data.second);
@@ -4098,7 +4098,7 @@ std::shared_ptr<CWallet> CWallet::CreateWalletFromFile(interfaces::Chain& chain,
40984098
{
40994099
walletInstance->WalletLogPrintf("setKeyPool.size() = %u\n", walletInstance->GetKeyPoolSize());
41004100
walletInstance->WalletLogPrintf("mapWallet.size() = %u\n", walletInstance->mapWallet.size());
4101-
walletInstance->WalletLogPrintf("mapAddressBook.size() = %u\n", walletInstance->mapAddressBook.size());
4101+
walletInstance->WalletLogPrintf("m_address_book.size() = %u\n", walletInstance->m_address_book.size());
41024102
}
41034103

41044104
return walletInstance;

src/wallet/wallet.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ class CWallet final : public WalletStorage, public interfaces::Chain::Notificati
775775
int64_t nOrderPosNext GUARDED_BY(cs_wallet) = 0;
776776
uint64_t nAccountingEntryNumber = 0;
777777

778-
std::map<CTxDestination, CAddressBookData> mapAddressBook GUARDED_BY(cs_wallet);
778+
std::map<CTxDestination, CAddressBookData> m_address_book GUARDED_BY(cs_wallet);
779779

780780
std::set<COutPoint> setLockedCoins GUARDED_BY(cs_wallet);
781781

src/wallet/walletdb.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,11 +206,11 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue,
206206
if (strType == DBKeys::NAME) {
207207
std::string strAddress;
208208
ssKey >> strAddress;
209-
ssValue >> pwallet->mapAddressBook[DecodeDestination(strAddress)].name;
209+
ssValue >> pwallet->m_address_book[DecodeDestination(strAddress)].name;
210210
} else if (strType == DBKeys::PURPOSE) {
211211
std::string strAddress;
212212
ssKey >> strAddress;
213-
ssValue >> pwallet->mapAddressBook[DecodeDestination(strAddress)].purpose;
213+
ssValue >> pwallet->m_address_book[DecodeDestination(strAddress)].purpose;
214214
} else if (strType == DBKeys::TX) {
215215
uint256 hash;
216216
ssKey >> hash;

src/wallet/wallettool.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ static void WalletShowInfo(CWallet* wallet_instance)
9999
tfm::format(std::cout, "HD (hd seed available): %s\n", wallet_instance->IsHDEnabled() ? "yes" : "no");
100100
tfm::format(std::cout, "Keypool Size: %u\n", wallet_instance->GetKeyPoolSize());
101101
tfm::format(std::cout, "Transactions: %zu\n", wallet_instance->mapWallet.size());
102-
tfm::format(std::cout, "Address Book: %zu\n", wallet_instance->mapAddressBook.size());
102+
tfm::format(std::cout, "Address Book: %zu\n", wallet_instance->m_address_book.size());
103103
}
104104

105105
bool ExecuteWalletToolFunc(const std::string& command, const std::string& name)

0 commit comments

Comments
 (0)