Skip to content

Commit 6d2905f

Browse files
committed
Wallet: Avoid unnecessary/redundant m_address_book lookups
1 parent c751d88 commit 6d2905f

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

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(pwallet->m_address_book.at(dest).name);
69+
strLabel = EncodeDumpString(address_book_entry->name);
7070
fLabelFound = true;
7171
}
7272
}

src/wallet/rpcwallet.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ static UniValue listaddressgroupings(const JSONRPCRequest& request)
507507
{
508508
const auto* address_book_entry = pwallet->FindAddressBookEntry(address);
509509
if (address_book_entry) {
510-
addressInfo.push_back(pwallet->m_address_book.find(address)->second.name);
510+
addressInfo.push_back(address_book_entry->name);
511511
}
512512
}
513513
jsonGrouping.push_back(addressInfo);
@@ -1317,7 +1317,7 @@ static void ListTransactions(interfaces::Chain::Lock& locked_chain, const CWalle
13171317
entry.pushKV("amount", ValueFromAmount(-s.amount));
13181318
const auto* address_book_entry = pwallet->FindAddressBookEntry(s.destination);
13191319
if (address_book_entry) {
1320-
entry.pushKV("label", pwallet->m_address_book.at(s.destination).name);
1320+
entry.pushKV("label", address_book_entry->name);
13211321
}
13221322
entry.pushKV("vout", s.vout);
13231323
entry.pushKV("fee", ValueFromAmount(-nFee));
@@ -1335,7 +1335,7 @@ static void ListTransactions(interfaces::Chain::Lock& locked_chain, const CWalle
13351335
std::string label;
13361336
const auto* address_book_entry = pwallet->FindAddressBookEntry(r.destination);
13371337
if (address_book_entry) {
1338-
label = pwallet->m_address_book.at(r.destination).name;
1338+
label = address_book_entry->name;
13391339
}
13401340
if (filter_label && label != *filter_label) {
13411341
continue;
@@ -3820,7 +3820,7 @@ UniValue getaddressinfo(const JSONRPCRequest& request)
38203820
// value of the name key/value pair in the labels array below.
38213821
const auto* address_book_entry = pwallet->FindAddressBookEntry(dest);
38223822
if (pwallet->chain().rpcEnableDeprecated("label") && address_book_entry) {
3823-
ret.pushKV("label", pwallet->m_address_book.at(dest).name);
3823+
ret.pushKV("label", address_book_entry->name);
38243824
}
38253825

38263826
ret.pushKV("ischange", pwallet->IsChange(scriptPubKey));

0 commit comments

Comments
 (0)