Skip to content

Commit

Permalink
BUG: SSPKM, guard GetDebit/GetCredit for non-shield v2 txes
Browse files Browse the repository at this point in the history
  • Loading branch information
random-zebra committed Dec 15, 2020
1 parent 9e2d825 commit 99a4379
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/sapling/saplingscriptpubkeyman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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();
Expand Down

0 comments on commit 99a4379

Please sign in to comment.