IsNoteSaplingChange: Inline internal recipient check.

This fixes the usage of IsNoteSaplingChange in z_listreceivedbyaddress.

Co-authored-by: Jack Grigg <jack@electriccoin.co>
This commit is contained in:
therealyingtong 2022-04-06 23:28:52 +08:00
parent 37c5bca411
commit da5575a02d
2 changed files with 5 additions and 3 deletions

View File

@ -2587,7 +2587,6 @@ UniValue z_listunspent(const UniValue& params, bool fHelp)
if (hasSaplingSpendingKey) {
obj.pushKV(
"change",
pwalletMain->IsInternalRecipient(entry.address) ||
pwalletMain->IsNoteSaplingChange(saplingNullifiers, entry.address, entry.op));
}
results.push_back(obj);

View File

@ -1599,6 +1599,11 @@ bool CWallet::IsNoteSaplingChange(
const libzcash::SaplingPaymentAddress& address,
const SaplingOutPoint & op)
{
// Check against the wallet's change address for the associated unified account.
if (this->IsInternalRecipient(address)) {
return true;
}
// A Note is marked as "change" if the address that received it
// also spent Notes in the same transaction. This will catch,
// for instance:
@ -1607,8 +1612,6 @@ bool CWallet::IsNoteSaplingChange(
// - Notes created by consolidation transactions (e.g. using
// z_mergetoaddress).
// - Notes sent from one address to itself.
// FIXME: This also needs to check against the wallet's change address
// for the associated unified account when we add UA support
for (const SpendDescription &spend : mapWallet[op.hash].vShieldedSpend) {
if (nullifierSet.count(std::make_pair(address, spend.nullifier))) {
return true;