From 9c72f4c2f5b9a442e6e3c1acda91c603770f3670 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 6 Mar 2020 14:40:24 -0500 Subject: [PATCH] Change consolidation fee to be the default instead of zero and require zinput arity to be inside [3,8] --- .../asyncrpcoperation_saplingconsolidation.cpp | 13 +++++++++---- src/wallet/asyncrpcoperation_saplingconsolidation.h | 11 ++++++++--- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/wallet/asyncrpcoperation_saplingconsolidation.cpp b/src/wallet/asyncrpcoperation_saplingconsolidation.cpp index 0d1599916..32601e0fd 100644 --- a/src/wallet/asyncrpcoperation_saplingconsolidation.cpp +++ b/src/wallet/asyncrpcoperation_saplingconsolidation.cpp @@ -120,7 +120,10 @@ bool AsyncRPCOperation_saplingconsolidation::main_impl() { std::vector fromNotes; 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) { libzcash::SaplingIncomingViewingKey ivk; @@ -132,14 +135,16 @@ bool AsyncRPCOperation_saplingconsolidation::main_impl() { 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) break; } - //random minimum 2 - 12 required - int minQuantity = rand() % 10 + 2; + // minimum required + // 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) continue; diff --git a/src/wallet/asyncrpcoperation_saplingconsolidation.h b/src/wallet/asyncrpcoperation_saplingconsolidation.h index 8e38204c7..9a80ff7c7 100644 --- a/src/wallet/asyncrpcoperation_saplingconsolidation.h +++ b/src/wallet/asyncrpcoperation_saplingconsolidation.h @@ -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 "asyncrpcoperation.h" #include "univalue.h" #include "zcash/Address.hpp" #include "zcash/zip32.h" -//Default fee used for consolidation transactions -static const CAmount DEFAULT_CONSOLIDATION_FEE = 0; +//Default fee used for consolidation transactions, in puposhis +static const CAmount DEFAULT_CONSOLIDATION_FEE = 10000; extern CAmount fConsolidationTxFee; extern bool fConsolidationMapUsed; @@ -34,4 +39,4 @@ private: void setConsolidationResult(int numTxCreated, const CAmount& amountConsolidated, const std::vector& consolidationTxIds); -}; \ No newline at end of file +};