From da5575a02daa81f491bd0fd13affbb35fb8440d9 Mon Sep 17 00:00:00 2001 From: therealyingtong Date: Wed, 6 Apr 2022 23:28:52 +0800 Subject: [PATCH] IsNoteSaplingChange: Inline internal recipient check. This fixes the usage of IsNoteSaplingChange in z_listreceivedbyaddress. Co-authored-by: Jack Grigg --- src/wallet/rpcwallet.cpp | 1 - src/wallet/wallet.cpp | 7 +++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 677fa538d..c3c653865 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -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); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index e3411c580..cabdcea1d 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -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;