Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore amount=0 zutxos in GetFilteredNotes() by default #104

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/wallet/asyncrpcoperation_saplingconsolidation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,12 @@ bool AsyncRPCOperation_saplingconsolidation::main_impl() {
// We set minDepth to 11 to avoid unconfirmed notes and in anticipation of specifying
// an anchor at height N-10 for each Sprout JoinSplit description
// Consider, should notes be sorted?
pwalletMain->GetFilteredNotes(sproutEntries, saplingEntries, "", 11);
bool ignoreSpent=true;
bool requireSpendingKey=true;
bool ignoreLocked=true;
bool ignoreZeroValue=false;

pwalletMain->GetFilteredNotes(sproutEntries, saplingEntries, "", 11, ignoreSpent, requireSpendingKey, ignoreLocked, ignoreZeroValue);
if (fConsolidationMapUsed) {
const vector<string>& v = mapMultiArgs["-consolidatesaplingaddress"];
for(int i = 0; i < v.size(); i++) {
Expand Down
17 changes: 14 additions & 3 deletions src/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5323,15 +5323,17 @@ void CWallet::GetFilteredNotes(
std::string address,
int minDepth,
bool ignoreSpent,
bool requireSpendingKey)
bool requireSpendingKey,
bool ignoreLocked,
bool ignoreZeroValue)
{
std::set<PaymentAddress> filterAddresses;

if (address.length() > 0) {
filterAddresses.insert(DecodePaymentAddress(address));
}

GetFilteredNotes(sproutEntries, saplingEntries, filterAddresses, minDepth, INT_MAX, ignoreSpent, requireSpendingKey);
GetFilteredNotes(sproutEntries, saplingEntries, filterAddresses, minDepth, INT_MAX, ignoreSpent, requireSpendingKey, ignoreLocked, ignoreZeroValue);
}

/**
Expand All @@ -5347,7 +5349,8 @@ void CWallet::GetFilteredNotes(
int maxDepth,
bool ignoreSpent,
bool requireSpendingKey,
bool ignoreLocked)
bool ignoreLocked,
bool ignoreZeroValue)
{
LOCK2(cs_main, cs_wallet);

Expand Down Expand Up @@ -5417,6 +5420,14 @@ void CWallet::GetFilteredNotes(
continue;
}

// Most code does not want amount=0 zutxos
// except sapling consolidation
if (ignoreZeroValue) {
if (notePt.value() == 0) {
continue;
}
}

auto note = notePt.note(nd.ivk).get();
saplingEntries.push_back(SaplingNoteEntry {
op, pa, note, notePt.memo(), wtx.GetDepthInMainChain() });
Expand Down
7 changes: 5 additions & 2 deletions src/wallet/wallet.h
Original file line number Diff line number Diff line change
Expand Up @@ -1372,7 +1372,9 @@ class CWallet : public CCryptoKeyStore, public CValidationInterface
std::string address,
int minDepth=1,
bool ignoreSpent=true,
bool requireSpendingKey=true);
bool requireSpendingKey=true,
bool ignoreLocked=true,
bool ignoreZeroValue=true);

/* Find notes filtered by payment addresses, min depth, max depth, if they are spent,
if a spending key is required, and if they are locked */
Expand All @@ -1383,7 +1385,8 @@ class CWallet : public CCryptoKeyStore, public CValidationInterface
int maxDepth=INT_MAX,
bool ignoreSpent=true,
bool requireSpendingKey=true,
bool ignoreLocked=true);
bool ignoreLocked=true,
bool ignoreZeroValue=true);

};

Expand Down