Skip to content

Commit f336ff7

Browse files
committed
rpc: avoid expensive IsMine calls in GetReceived tally
1 parent a7b65af commit f336ff7

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/wallet/rpc/coins.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ static CAmount GetReceived(const CWallet& wallet, const UniValue& params, bool b
2323
// Get the set of addresses assigned to label
2424
std::string label = LabelFromValue(params[0]);
2525
for (const auto& address : wallet.GetLabelAddresses(label)) {
26-
output_scripts.insert(GetScriptForDestination(address));
26+
auto output_script{GetScriptForDestination(address)};
27+
if (wallet.IsMine(output_script)) {
28+
output_scripts.insert(output_script);
29+
}
2730
}
2831
} else {
2932
// Get the address
@@ -67,7 +70,7 @@ static CAmount GetReceived(const CWallet& wallet, const UniValue& params, bool b
6770
}
6871

6972
for (const CTxOut& txout : wtx.tx->vout) {
70-
if (wallet.IsMine(txout.scriptPubKey) && output_scripts.count(txout.scriptPubKey) > 0) {
73+
if (output_scripts.count(txout.scriptPubKey) > 0) {
7174
amount += txout.nValue;
7275
}
7376
}

0 commit comments

Comments
 (0)