Rename GetUnspentNotes to GetFilteredNotes

Added parameter to ignore spent notes, which is true by default.
This commit is contained in:
Simon 2016-09-07 16:07:26 -07:00
parent 6d2d045c6b
commit 1b141933e5
5 changed files with 10 additions and 10 deletions

View File

@ -739,7 +739,7 @@ bool AsyncRPCOperation_sendmany::find_unspent_notes() {
std::vector<CNotePlaintextEntry> entries;
{
LOCK2(cs_main, pwalletMain->cs_wallet);
pwalletMain->GetUnspentNotes(entries, fromaddress_, mindepth_);
pwalletMain->GetFilteredNotes(entries, fromaddress_, mindepth_);
}
for (CNotePlaintextEntry & entry : entries) {

View File

@ -199,7 +199,7 @@ TEST(wallet_tests, find_unspent_notes) {
// two notes, one is spent but wallet doesn't see it as spent yet until mined
std::vector<CNotePlaintextEntry> entries;
wallet.GetUnspentNotes(entries, "", 0);
wallet.GetFilteredNotes(entries, "", 0);
EXPECT_EQ(2, entries.size());
// Create new payment address, add new note, and filter
@ -215,10 +215,10 @@ TEST(wallet_tests, find_unspent_notes) {
// 4 notes in wallet, 1 spent (not seen), 1 is the new payment address
entries.clear();
wallet.GetUnspentNotes(entries, "", 0);
wallet.GetFilteredNotes(entries, "", 0);
EXPECT_EQ(4, entries.size());
entries.clear();
wallet.GetUnspentNotes(entries, user2_payment_address, 0);
wallet.GetFilteredNotes(entries, user2_payment_address, 0);
EXPECT_EQ(2, entries.size());
// Fake-mine the transaction
@ -240,11 +240,11 @@ TEST(wallet_tests, find_unspent_notes) {
// 4 notes, 1 spent (now seen)
entries.clear();
wallet.GetUnspentNotes(entries, "", 0);
wallet.GetFilteredNotes(entries, "", 0);
EXPECT_EQ(3, entries.size());
entries.clear();
// no change to user2 and their two notes.
wallet.GetUnspentNotes(entries, user2_payment_address, 0);
wallet.GetFilteredNotes(entries, user2_payment_address, 0);
EXPECT_EQ(2, entries.size());
// Tear down

View File

@ -2878,7 +2878,7 @@ CAmount getBalanceZaddr(std::string address, size_t minDepth = 1) {
CAmount balance = 0;
std::vector<CNotePlaintextEntry> entries;
LOCK2(cs_main, pwalletMain->cs_wallet);
pwalletMain->GetUnspentNotes(entries, address, minDepth);
pwalletMain->GetFilteredNotes(entries, address, minDepth);
for (auto & entry : entries) {
balance += CAmount(entry.plaintext.value);
}

View File

@ -3187,7 +3187,7 @@ bool CMerkleTx::AcceptToMemoryPool(bool fLimitFree, bool fRejectAbsurdFee)
return ::AcceptToMemoryPool(mempool, state, *this, fLimitFree, NULL, fRejectAbsurdFee);
}
bool CWallet::GetUnspentNotes(std::vector<CNotePlaintextEntry> & outEntries, std::string address, size_t minDepth = 1)
bool CWallet::GetFilteredNotes(std::vector<CNotePlaintextEntry> & outEntries, std::string address, size_t minDepth = 1, bool ignoreSpent)
{
bool fFilterAddress = false;
libzcash::PaymentAddress filterPaymentAddress;
@ -3223,7 +3223,7 @@ bool CWallet::GetUnspentNotes(std::vector<CNotePlaintextEntry> & outEntries, std
}
// skip note which has been spent
if (IsSpent(nd.nullifier)) {
if (ignoreSpent && IsSpent(nd.nullifier)) {
continue;
}

View File

@ -905,7 +905,7 @@ public:
void SetBroadcastTransactions(bool broadcast) { fBroadcastTransactions = broadcast; }
/* Find unspent notes, filter by payment address, min depth */
bool GetUnspentNotes(std::vector<CNotePlaintextEntry> & outEntries, std::string address, size_t minDepth);
bool GetFilteredNotes(std::vector<CNotePlaintextEntry> & outEntries, std::string address, size_t minDepth, bool ignoreSpent=false);
};