diff --git a/src/sapling/saplingscriptpubkeyman.cpp b/src/sapling/saplingscriptpubkeyman.cpp index 2e2f8f8bb0b76..6498affc4e3d2 100644 --- a/src/sapling/saplingscriptpubkeyman.cpp +++ b/src/sapling/saplingscriptpubkeyman.cpp @@ -671,6 +671,9 @@ isminetype SaplingScriptPubKeyMan::IsMine(const CWalletTx& wtx, const SaplingOut CAmount SaplingScriptPubKeyMan::GetCredit(const CWalletTx& tx, const isminefilter& filter, const bool fUnspent) const { + if (!tx.IsShieldedTx() || tx.sapData->vShieldedOutput.empty()) { + return 0; + } CAmount nCredit = 0; for (int i = 0; i < (int) tx.sapData->vShieldedOutput.size(); ++i) { SaplingOutPoint op(tx.GetHash(), i); @@ -697,6 +700,9 @@ CAmount SaplingScriptPubKeyMan::GetCredit(const CWalletTx& tx, const isminefilte CAmount SaplingScriptPubKeyMan::GetDebit(const CTransaction& tx, const isminefilter& filter) const { + if (!tx.IsShieldedTx() || tx.sapData->vShieldedSpend.empty()) { + return 0; + } CAmount nDebit = 0; for (const SpendDescription& spend : tx.sapData->vShieldedSpend) { const auto &it = mapSaplingNullifiersToNotes.find(spend.nullifier); @@ -720,7 +726,7 @@ CAmount SaplingScriptPubKeyMan::GetDebit(const CTransaction& tx, const isminefil CAmount SaplingScriptPubKeyMan::GetShieldedChange(const CWalletTx& wtx) const { - if (!wtx.isSaplingVersion() || wtx.sapData->vShieldedOutput.empty()) { + if (!wtx.IsShieldedTx() || wtx.sapData->vShieldedOutput.empty()) { return 0; } const uint256& txHash = wtx.GetHash();