Rename GetUnspentNotes to GetFilteredNotes
Added parameter to ignore spent notes, which is true by default.
This commit is contained in:
parent
6d2d045c6b
commit
1b141933e5
|
@ -739,7 +739,7 @@ bool AsyncRPCOperation_sendmany::find_unspent_notes() {
|
||||||
std::vector<CNotePlaintextEntry> entries;
|
std::vector<CNotePlaintextEntry> entries;
|
||||||
{
|
{
|
||||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||||
pwalletMain->GetUnspentNotes(entries, fromaddress_, mindepth_);
|
pwalletMain->GetFilteredNotes(entries, fromaddress_, mindepth_);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (CNotePlaintextEntry & entry : entries) {
|
for (CNotePlaintextEntry & entry : entries) {
|
||||||
|
|
|
@ -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
|
// two notes, one is spent but wallet doesn't see it as spent yet until mined
|
||||||
std::vector<CNotePlaintextEntry> entries;
|
std::vector<CNotePlaintextEntry> entries;
|
||||||
wallet.GetUnspentNotes(entries, "", 0);
|
wallet.GetFilteredNotes(entries, "", 0);
|
||||||
EXPECT_EQ(2, entries.size());
|
EXPECT_EQ(2, entries.size());
|
||||||
|
|
||||||
// Create new payment address, add new note, and filter
|
// 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
|
// 4 notes in wallet, 1 spent (not seen), 1 is the new payment address
|
||||||
entries.clear();
|
entries.clear();
|
||||||
wallet.GetUnspentNotes(entries, "", 0);
|
wallet.GetFilteredNotes(entries, "", 0);
|
||||||
EXPECT_EQ(4, entries.size());
|
EXPECT_EQ(4, entries.size());
|
||||||
entries.clear();
|
entries.clear();
|
||||||
wallet.GetUnspentNotes(entries, user2_payment_address, 0);
|
wallet.GetFilteredNotes(entries, user2_payment_address, 0);
|
||||||
EXPECT_EQ(2, entries.size());
|
EXPECT_EQ(2, entries.size());
|
||||||
|
|
||||||
// Fake-mine the transaction
|
// Fake-mine the transaction
|
||||||
|
@ -240,11 +240,11 @@ TEST(wallet_tests, find_unspent_notes) {
|
||||||
|
|
||||||
// 4 notes, 1 spent (now seen)
|
// 4 notes, 1 spent (now seen)
|
||||||
entries.clear();
|
entries.clear();
|
||||||
wallet.GetUnspentNotes(entries, "", 0);
|
wallet.GetFilteredNotes(entries, "", 0);
|
||||||
EXPECT_EQ(3, entries.size());
|
EXPECT_EQ(3, entries.size());
|
||||||
entries.clear();
|
entries.clear();
|
||||||
// no change to user2 and their two notes.
|
// 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());
|
EXPECT_EQ(2, entries.size());
|
||||||
|
|
||||||
// Tear down
|
// Tear down
|
||||||
|
|
|
@ -2878,7 +2878,7 @@ CAmount getBalanceZaddr(std::string address, size_t minDepth = 1) {
|
||||||
CAmount balance = 0;
|
CAmount balance = 0;
|
||||||
std::vector<CNotePlaintextEntry> entries;
|
std::vector<CNotePlaintextEntry> entries;
|
||||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||||
pwalletMain->GetUnspentNotes(entries, address, minDepth);
|
pwalletMain->GetFilteredNotes(entries, address, minDepth);
|
||||||
for (auto & entry : entries) {
|
for (auto & entry : entries) {
|
||||||
balance += CAmount(entry.plaintext.value);
|
balance += CAmount(entry.plaintext.value);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3187,7 +3187,7 @@ bool CMerkleTx::AcceptToMemoryPool(bool fLimitFree, bool fRejectAbsurdFee)
|
||||||
return ::AcceptToMemoryPool(mempool, state, *this, fLimitFree, NULL, 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;
|
bool fFilterAddress = false;
|
||||||
libzcash::PaymentAddress filterPaymentAddress;
|
libzcash::PaymentAddress filterPaymentAddress;
|
||||||
|
@ -3223,7 +3223,7 @@ bool CWallet::GetUnspentNotes(std::vector<CNotePlaintextEntry> & outEntries, std
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip note which has been spent
|
// skip note which has been spent
|
||||||
if (IsSpent(nd.nullifier)) {
|
if (ignoreSpent && IsSpent(nd.nullifier)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -905,7 +905,7 @@ public:
|
||||||
void SetBroadcastTransactions(bool broadcast) { fBroadcastTransactions = broadcast; }
|
void SetBroadcastTransactions(bool broadcast) { fBroadcastTransactions = broadcast; }
|
||||||
|
|
||||||
/* Find unspent notes, filter by payment address, min depth */
|
/* 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);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue