mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-25 10:43:19 -03:00
rpc: avoid expensive IsMine
calls in GetReceived
tally
This commit is contained in:
parent
a7b65af2a4
commit
f336ff7f21
1 changed files with 5 additions and 2 deletions
|
@ -23,7 +23,10 @@ static CAmount GetReceived(const CWallet& wallet, const UniValue& params, bool b
|
||||||
// Get the set of addresses assigned to label
|
// Get the set of addresses assigned to label
|
||||||
std::string label = LabelFromValue(params[0]);
|
std::string label = LabelFromValue(params[0]);
|
||||||
for (const auto& address : wallet.GetLabelAddresses(label)) {
|
for (const auto& address : wallet.GetLabelAddresses(label)) {
|
||||||
output_scripts.insert(GetScriptForDestination(address));
|
auto output_script{GetScriptForDestination(address)};
|
||||||
|
if (wallet.IsMine(output_script)) {
|
||||||
|
output_scripts.insert(output_script);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Get the address
|
// Get the address
|
||||||
|
@ -67,7 +70,7 @@ static CAmount GetReceived(const CWallet& wallet, const UniValue& params, bool b
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const CTxOut& txout : wtx.tx->vout) {
|
for (const CTxOut& txout : wtx.tx->vout) {
|
||||||
if (wallet.IsMine(txout.scriptPubKey) && output_scripts.count(txout.scriptPubKey) > 0) {
|
if (output_scripts.count(txout.scriptPubKey) > 0) {
|
||||||
amount += txout.nValue;
|
amount += txout.nValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue