Change consolidation fee to be the default instead of zero and require zinput arity to be inside [3,8]

This commit is contained in:
Duke Leto
2020-03-06 14:40:24 -05:00
parent dc7525f12e
commit 9c72f4c2f5
2 changed files with 17 additions and 7 deletions

View File

@@ -120,7 +120,10 @@ bool AsyncRPCOperation_saplingconsolidation::main_impl() {
std::vector<SaplingNoteEntry> fromNotes; std::vector<SaplingNoteEntry> fromNotes;
CAmount amountToSend = 0; CAmount amountToSend = 0;
int maxQuantity = rand() % 35 + 10; // max of 8 zins means the tx cannot reduce the anonset,
// since there will be 8 zins and 8 zouts at worst case
// This also helps reduce ztx creation time
int maxQuantity = rand() % 8 + 1;
for (const SaplingNoteEntry& saplingEntry : saplingEntries) { for (const SaplingNoteEntry& saplingEntry : saplingEntries) {
libzcash::SaplingIncomingViewingKey ivk; libzcash::SaplingIncomingViewingKey ivk;
@@ -132,14 +135,16 @@ bool AsyncRPCOperation_saplingconsolidation::main_impl() {
fromNotes.push_back(saplingEntry); fromNotes.push_back(saplingEntry);
} }
//Only use a randomly determined number of notes between 10 and 45 //Only use a randomly determined number of notes
if (fromNotes.size() >= maxQuantity) if (fromNotes.size() >= maxQuantity)
break; break;
} }
//random minimum 2 - 12 required // minimum required
int minQuantity = rand() % 10 + 2; // We use 3 so that addresses can spent one zutxo and still have another zutxo to use while that
// tx is confirming
int minQuantity = 3;
if (fromNotes.size() < minQuantity) if (fromNotes.size() < minQuantity)
continue; continue;

View File

@@ -1,11 +1,16 @@
// Copyright (c) 2020 The Hush developers
// TODO: Forge should add his preferred copyright line here
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "amount.h" #include "amount.h"
#include "asyncrpcoperation.h" #include "asyncrpcoperation.h"
#include "univalue.h" #include "univalue.h"
#include "zcash/Address.hpp" #include "zcash/Address.hpp"
#include "zcash/zip32.h" #include "zcash/zip32.h"
//Default fee used for consolidation transactions //Default fee used for consolidation transactions, in puposhis
static const CAmount DEFAULT_CONSOLIDATION_FEE = 0; static const CAmount DEFAULT_CONSOLIDATION_FEE = 10000;
extern CAmount fConsolidationTxFee; extern CAmount fConsolidationTxFee;
extern bool fConsolidationMapUsed; extern bool fConsolidationMapUsed;
@@ -34,4 +39,4 @@ private:
void setConsolidationResult(int numTxCreated, const CAmount& amountConsolidated, const std::vector<std::string>& consolidationTxIds); void setConsolidationResult(int numTxCreated, const CAmount& amountConsolidated, const std::vector<std::string>& consolidationTxIds);
}; };