diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 385e40fe8..0d127ccbd 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -474,11 +474,10 @@ void CWallet::ChainTip(const CBlockIndex *pindex, { if (added) { IncrementNoteWitnesses(pindex, pblock, sproutTree, saplingTree); - UpdateSaplingNullifierNoteMapForBlock(pblock); } else { DecrementNoteWitnesses(pindex); - UpdateSaplingNullifierNoteMapForBlock(pblock); } + UpdateSaplingNullifierNoteMapForBlock(pblock); } void CWallet::SetBestChain(const CBlockLocator& loc) @@ -758,6 +757,15 @@ void CWallet::AddToSproutSpends(const uint256& nullifier, const uint256& wtxid) SyncMetaData(range); } +void CWallet::AddToSaplingSpends(const uint256& nullifier, const uint256& wtxid) +{ + mapTxSaplingNullifiers.insert(make_pair(nullifier, wtxid)); + + pair range; + range = mapTxSaplingNullifiers.equal_range(nullifier); + SyncMetaData(range); +} + void CWallet::AddToSpends(const uint256& wtxid) { assert(mapWallet.count(wtxid)); @@ -778,15 +786,6 @@ void CWallet::AddToSpends(const uint256& wtxid) } } -void CWallet::AddToSaplingSpends(const uint256& nullifier, const uint256& wtxid) -{ - mapTxSaplingNullifiers.insert(make_pair(nullifier, wtxid)); - - pair range; - range = mapTxSaplingNullifiers.equal_range(nullifier); - SyncMetaData(range); -} - void CWallet::ClearNoteWitnessCache() { LOCK(cs_wallet); @@ -1226,14 +1225,14 @@ void CWallet::UpdateSaplingNullifierNoteMapWithTx(CWalletTx& wtx) { SaplingOutPoint op = item.first; SaplingNoteData nd = item.second; - if (nd.witnesses.size() == 0) { + if (nd.witnesses.empty()) { // If there are no witnesses, erase the nullifier and associated mapping. if (item.second.nullifier) { mapSaplingNullifiersToNotes.erase(item.second.nullifier.get()); } item.second.nullifier = boost::none; } - else if (nd.witnesses.size() > 0) { + else { uint64_t position = nd.witnesses.front().position(); SaplingFullViewingKey fvk = mapSaplingFullViewingKeys.at(nd.ivk); OutputDescription output = wtx.vShieldedOutput[op.n]; diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index a43a53b8e..c8aac9181 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -732,8 +732,8 @@ private: void AddToTransparentSpends(const COutPoint& outpoint, const uint256& wtxid); void AddToSproutSpends(const uint256& nullifier, const uint256& wtxid); - void AddToSpends(const uint256& wtxid); void AddToSaplingSpends(const uint256& nullifier, const uint256& wtxid); + void AddToSpends(const uint256& wtxid); public: /*