Browse Source

Ignore amount=0 zutxos in GetFilteredNotes() by default

getfilterednotes
Duke Leto 4 years ago
parent
commit
005206051d
  1. 7
      src/wallet/asyncrpcoperation_saplingconsolidation.cpp
  2. 17
      src/wallet/wallet.cpp
  3. 7
      src/wallet/wallet.h

7
src/wallet/asyncrpcoperation_saplingconsolidation.cpp

@ -95,7 +95,12 @@ bool AsyncRPCOperation_saplingconsolidation::main_impl() {
// We set minDepth to 11 to avoid unconfirmed notes and in anticipation of specifying // 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 // an anchor at height N-10 for each Sprout JoinSplit description
// Consider, should notes be sorted? // 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) { if (fConsolidationMapUsed) {
const vector<string>& v = mapMultiArgs["-consolidatesaplingaddress"]; const vector<string>& v = mapMultiArgs["-consolidatesaplingaddress"];
for(int i = 0; i < v.size(); i++) { for(int i = 0; i < v.size(); i++) {

17
src/wallet/wallet.cpp

@ -5323,7 +5323,9 @@ void CWallet::GetFilteredNotes(
std::string address, std::string address,
int minDepth, int minDepth,
bool ignoreSpent, bool ignoreSpent,
bool requireSpendingKey) bool requireSpendingKey,
bool ignoreLocked,
bool ignoreZeroValue)
{ {
std::set<PaymentAddress> filterAddresses; std::set<PaymentAddress> filterAddresses;
@ -5331,7 +5333,7 @@ void CWallet::GetFilteredNotes(
filterAddresses.insert(DecodePaymentAddress(address)); filterAddresses.insert(DecodePaymentAddress(address));
} }
GetFilteredNotes(sproutEntries, saplingEntries, filterAddresses, minDepth, INT_MAX, ignoreSpent, requireSpendingKey); GetFilteredNotes(sproutEntries, saplingEntries, filterAddresses, minDepth, INT_MAX, ignoreSpent, requireSpendingKey, ignoreLocked, ignoreZeroValue);
} }
/** /**
@ -5347,7 +5349,8 @@ void CWallet::GetFilteredNotes(
int maxDepth, int maxDepth,
bool ignoreSpent, bool ignoreSpent,
bool requireSpendingKey, bool requireSpendingKey,
bool ignoreLocked) bool ignoreLocked,
bool ignoreZeroValue)
{ {
LOCK2(cs_main, cs_wallet); LOCK2(cs_main, cs_wallet);
@ -5417,6 +5420,14 @@ void CWallet::GetFilteredNotes(
continue; 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(); auto note = notePt.note(nd.ivk).get();
saplingEntries.push_back(SaplingNoteEntry { saplingEntries.push_back(SaplingNoteEntry {
op, pa, note, notePt.memo(), wtx.GetDepthInMainChain() }); op, pa, note, notePt.memo(), wtx.GetDepthInMainChain() });

7
src/wallet/wallet.h

@ -1372,7 +1372,9 @@ public:
std::string address, std::string address,
int minDepth=1, int minDepth=1,
bool ignoreSpent=true, 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, /* 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 */ if a spending key is required, and if they are locked */
@ -1383,7 +1385,8 @@ public:
int maxDepth=INT_MAX, int maxDepth=INT_MAX,
bool ignoreSpent=true, bool ignoreSpent=true,
bool requireSpendingKey=true, bool requireSpendingKey=true,
bool ignoreLocked=true); bool ignoreLocked=true,
bool ignoreZeroValue=true);
}; };

Loading…
Cancel
Save