diff --git a/src/wallet/gtest/test_wallet.cpp b/src/wallet/gtest/test_wallet.cpp index 63dd4d891..18bda4a65 100644 --- a/src/wallet/gtest/test_wallet.cpp +++ b/src/wallet/gtest/test_wallet.cpp @@ -179,7 +179,7 @@ TEST(WalletTests, FindUnspentNotes) { wtx.SetSproutNoteData(noteData); wallet.AddToWallet(wtx, true, NULL); - EXPECT_FALSE(wallet.IsSpent(nullifier)); + EXPECT_FALSE(wallet.IsSproutSpent(nullifier)); // We currently have an unspent and unconfirmed note in the wallet (depth of -1) std::vector entries; @@ -204,7 +204,7 @@ TEST(WalletTests, FindUnspentNotes) { wtx.SetMerkleBranch(block); wallet.AddToWallet(wtx, true, NULL); - EXPECT_FALSE(wallet.IsSpent(nullifier)); + EXPECT_FALSE(wallet.IsSproutSpent(nullifier)); // We now have an unspent and confirmed note in the wallet (depth of 1) @@ -222,7 +222,7 @@ TEST(WalletTests, FindUnspentNotes) { // Let's spend the note. auto wtx2 = GetValidSpend(sk, note, 5); wallet.AddToWallet(wtx2, true, NULL); - EXPECT_FALSE(wallet.IsSpent(nullifier)); + EXPECT_FALSE(wallet.IsSproutSpent(nullifier)); // Fake-mine a spend transaction EXPECT_EQ(0, chainActive.Height()); @@ -240,7 +240,7 @@ TEST(WalletTests, FindUnspentNotes) { wtx2.SetMerkleBranch(block2); wallet.AddToWallet(wtx2, true, NULL); - EXPECT_TRUE(wallet.IsSpent(nullifier)); + EXPECT_TRUE(wallet.IsSproutSpent(nullifier)); // The note has been spent. By default, GetFilteredNotes() ignores spent notes. wallet.GetFilteredNotes(entries, "", 0); @@ -274,7 +274,7 @@ TEST(WalletTests, FindUnspentNotes) { wtx.SetSproutNoteData(noteData); wallet.AddToWallet(wtx, true, NULL); - EXPECT_FALSE(wallet.IsSpent(nullifier)); + EXPECT_FALSE(wallet.IsSproutSpent(nullifier)); wtx3 = wtx; } @@ -490,14 +490,14 @@ TEST(WalletTests, NullifierIsSpent) { auto note = GetNote(sk, wtx, 0, 1); auto nullifier = note.nullifier(sk); - EXPECT_FALSE(wallet.IsSpent(nullifier)); + EXPECT_FALSE(wallet.IsSproutSpent(nullifier)); wallet.AddToWallet(wtx, true, NULL); - EXPECT_FALSE(wallet.IsSpent(nullifier)); + EXPECT_FALSE(wallet.IsSproutSpent(nullifier)); auto wtx2 = GetValidSpend(sk, note, 5); wallet.AddToWallet(wtx2, true, NULL); - EXPECT_FALSE(wallet.IsSpent(nullifier)); + EXPECT_FALSE(wallet.IsSproutSpent(nullifier)); // Fake-mine the transaction EXPECT_EQ(-1, chainActive.Height()); @@ -513,7 +513,7 @@ TEST(WalletTests, NullifierIsSpent) { wtx2.SetMerkleBranch(block); wallet.AddToWallet(wtx2, true, NULL); - EXPECT_TRUE(wallet.IsSpent(nullifier)); + EXPECT_TRUE(wallet.IsSproutSpent(nullifier)); // Tear down chainActive.SetTip(NULL); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 6f682cc05..385e40fe8 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -712,8 +712,7 @@ bool CWallet::IsSpent(const uint256& hash, unsigned int n) const * Note is spent if any non-conflicted transaction * spends it: */ -bool CWallet::IsSpent(const uint256& nullifier) const -{ +bool CWallet::IsSproutSpent(const uint256& nullifier) const { pair range; range = mapTxSproutNullifiers.equal_range(nullifier); @@ -724,7 +723,11 @@ bool CWallet::IsSpent(const uint256& nullifier) const return true; // Spent } } + return false; +} +bool CWallet::IsSaplingSpent(const uint256& nullifier) const { + pair range; range = mapTxSaplingNullifiers.equal_range(nullifier); for (TxNullifiers::const_iterator it = range.first; it != range.second; ++it) { @@ -4123,7 +4126,7 @@ void CWallet::GetFilteredNotes( } // skip note which has been spent - if (ignoreSpent && nd.nullifier && IsSpent(*nd.nullifier)) { + if (ignoreSpent && nd.nullifier && IsSproutSpent(*nd.nullifier)) { continue; } @@ -4204,7 +4207,7 @@ void CWallet::GetUnspentFilteredNotes( } // skip note which has been spent - if (nd.nullifier && IsSpent(*nd.nullifier)) { + if (nd.nullifier && IsSproutSpent(*nd.nullifier)) { continue; } diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 00e0af7d9..a43a53b8e 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -936,7 +936,8 @@ public: bool SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int nConfTheirs, std::vector vCoins, std::set >& setCoinsRet, CAmount& nValueRet) const; bool IsSpent(const uint256& hash, unsigned int n) const; - bool IsSpent(const uint256& nullifier) const; + bool IsSproutSpent(const uint256& nullifier) const; + bool IsSaplingSpent(const uint256& nullifier) const; bool IsLockedCoin(uint256 hash, unsigned int n) const; void LockCoin(COutPoint& output);