Skip to content

Commit

Permalink
[Wallet] IsSaplingSpent back port.
Browse files Browse the repository at this point in the history
  • Loading branch information
furszy committed Oct 14, 2020
1 parent 46f4f92 commit 6156b15
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/sapling/saplingscriptpubkeyman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,21 @@ void SaplingScriptPubKeyMan::AddToSaplingSpends(const uint256& nullifier, const
wallet->SyncMetaDataN(range);
}

bool SaplingScriptPubKeyMan::IsSaplingSpent(const uint256& nullifier) const {
LOCK(cs_main);
std::pair<TxNullifiers::const_iterator, TxNullifiers::const_iterator> range;
range = mapTxSaplingNullifiers.equal_range(nullifier);

for (TxNullifiers::const_iterator it = range.first; it != range.second; ++it) {
const uint256& wtxid = it->second;
std::map<uint256, CWalletTx>::const_iterator mit = wallet->mapWallet.find(wtxid);
if (mit != wallet->mapWallet.end() && mit->second.GetDepthInMainChain() >= 0) {
return true; // Spent
}
}
return false;
}

void SaplingScriptPubKeyMan::UpdateSaplingNullifierNoteMapForBlock(const CBlock *pblock) {
LOCK(wallet->cs_wallet);

Expand Down
1 change: 1 addition & 0 deletions src/sapling/saplingscriptpubkeyman.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ class SaplingScriptPubKeyMan {
* Keep track of the used nullifier.
*/
void AddToSaplingSpends(const uint256& nullifier, const uint256& wtxid);
bool IsSaplingSpent(const uint256& nullifier) const;

/**
* pindex is the new tip being connected.
Expand Down

0 comments on commit 6156b15

Please sign in to comment.