From 99a43793f40309595f5a970dacb451308a5cd2e3 Mon Sep 17 00:00:00 2001 From: random-zebra Date: Tue, 15 Dec 2020 15:17:35 +0100 Subject: [PATCH] BUG: SSPKM, guard GetDebit/GetCredit for non-shield v2 txes --- src/sapling/saplingscriptpubkeyman.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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();