From 12e14f15a0972a866975b8c089a5169d36f877d1 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 1 Oct 2018 22:13:35 +0800 Subject: [PATCH 01/18] add some prints to see where values are --- src/wallet/rpcwallet.cpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 055352973..e5433d4ff 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -398,7 +398,7 @@ static void SendMoney(const CTxDestination &address, CAmount nValue, bool fSubtr // Parse Zcash address CScript scriptPubKey = GetScriptForDestination(address); - + // Create and send the transaction CReserveKey reservekey(pwalletMain); CAmount nFeeRequired; @@ -4133,7 +4133,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) strDisabledMsg = "\nWARNING: z_mergetoaddress is DISABLED but can be enabled as an experimental feature.\n"; } - if (fHelp || params.size() < 2 || params.size() > 6) + if (fHelp || params.size() < 2 || params.size() > 7) throw runtime_error( "z_mergetoaddress [\"fromaddress\", ... ] \"toaddress\" ( fee ) ( transparent_limit ) ( shielded_limit ) ( memo )\n" + strDisabledMsg + @@ -4165,6 +4165,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) "4. shielded_limit (numeric, optional, default=" + strprintf("%d", MERGE_TO_ADDRESS_DEFAULT_SHIELDED_LIMIT) + ") Limit on the maximum number of notes to merge. Set to 0 to merge as many as will fit in the transaction.\n" "5. \"memo\" (string, optional) Encoded as hex. When toaddress is a z-addr, this will be stored in the memo field of the new note.\n" + "6. maximum_utxo_size (int, optional) eg, 10000 anything under 10000 satoshies will be merged.\n" "\nResult:\n" "{\n" " \"remainingUTXOs\": xxx (numeric) Number of UTXOs still available for merging.\n" @@ -4295,6 +4296,16 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) } } + if (params.size() > 6) { + maximum_utxo_size = params[6].get_int() + printf("maximum utxo size = %d\n", maximum_utxo_size); + if (maximum_utxo_size < 10) { + throw JSONRPCError(RPC_INVALID_PARAMETER, "Maximum size must be bigger than 10 satoshies."); + } + } else { + maximum_utxo_size = 0; + } + MergeToAddressRecipient recipient(destaddress, memo); // Prepare to get UTXOs and notes @@ -4343,6 +4354,11 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) utxoCounter++; CAmount nValue = out.tx->vout[out.i].nValue; + if (maximum_utxo_size != 0) { + printf("maximum utxo size = %d \n", maximum_utxo_size); + printf("nValue = %s\n", nValue); + } + if (!maxedOutUTXOsFlag) { CBitcoinAddress ba(address); size_t increase = (ba.IsScript()) ? CTXIN_SPEND_P2SH_SIZE : CTXIN_SPEND_DUST_SIZE; @@ -5669,7 +5685,7 @@ UniValue oraclessubscribe(const UniValue& params, bool fHelp) UniValue oraclessamples(const UniValue& params, bool fHelp) { - UniValue result(UniValue::VOBJ); uint256 txid,batontxid; int32_t num; + UniValue result(UniValue::VOBJ); uint256 txid,batontxid; int32_t num; if ( fHelp || params.size() != 3 ) throw runtime_error("oraclessamples oracletxid batonutxo num\n"); if ( ensure_CCrequirements() < 0 ) From d411178c7e0fa3df85e47776e1c0b63112a0207f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 1 Oct 2018 22:18:05 +0800 Subject: [PATCH 02/18] syntax --- src/wallet/rpcwallet.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index e5433d4ff..b1261c695 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4296,6 +4296,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) } } + std::int maximum_utxo_size if (params.size() > 6) { maximum_utxo_size = params[6].get_int() printf("maximum utxo size = %d\n", maximum_utxo_size); @@ -4356,7 +4357,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) if (maximum_utxo_size != 0) { printf("maximum utxo size = %d \n", maximum_utxo_size); - printf("nValue = %s\n", nValue); + printf("nValue = %lld\n", nValue); } if (!maxedOutUTXOsFlag) { From 4f1650383a88438d961d4847101ad3ef90f3ccb4 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 1 Oct 2018 22:21:49 +0800 Subject: [PATCH 03/18] test --- src/wallet/rpcwallet.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index b1261c695..e005eec5b 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4296,10 +4296,10 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) } } - std::int maximum_utxo_size + CAmount maximum_utxo_size if (params.size() > 6) { maximum_utxo_size = params[6].get_int() - printf("maximum utxo size = %d\n", maximum_utxo_size); + printf("maximum utxo size = %ld\n", maximum_utxo_size); if (maximum_utxo_size < 10) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Maximum size must be bigger than 10 satoshies."); } @@ -4357,7 +4357,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) if (maximum_utxo_size != 0) { printf("maximum utxo size = %d \n", maximum_utxo_size); - printf("nValue = %lld\n", nValue); + printf("nValue = %ld\n", nValue); } if (!maxedOutUTXOsFlag) { From 57d237b5bc68a88e25c0078b373194dca63152f5 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 1 Oct 2018 22:24:04 +0800 Subject: [PATCH 04/18] ; --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index e005eec5b..81383d992 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4296,7 +4296,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) } } - CAmount maximum_utxo_size + CAmount maximum_utxo_size; if (params.size() > 6) { maximum_utxo_size = params[6].get_int() printf("maximum utxo size = %ld\n", maximum_utxo_size); From 2499a4fef8fa8f846b8fd89edaaf2843917ee115 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 1 Oct 2018 22:25:17 +0800 Subject: [PATCH 05/18] ld --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 81383d992..1cd38bca2 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4356,7 +4356,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) CAmount nValue = out.tx->vout[out.i].nValue; if (maximum_utxo_size != 0) { - printf("maximum utxo size = %d \n", maximum_utxo_size); + printf("maximum utxo size = %ld \n", maximum_utxo_size); printf("nValue = %ld\n", nValue); } From 2b81045e2ba5193127a582e629c808ff49e28f66 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 1 Oct 2018 22:27:58 +0800 Subject: [PATCH 06/18] ; --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 1cd38bca2..f407710c7 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4298,7 +4298,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) CAmount maximum_utxo_size; if (params.size() > 6) { - maximum_utxo_size = params[6].get_int() + maximum_utxo_size = params[6].get_int(); printf("maximum utxo size = %ld\n", maximum_utxo_size); if (maximum_utxo_size < 10) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Maximum size must be bigger than 10 satoshies."); From 93253d38ea755bca797d8acff08646ba880675db Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 1 Oct 2018 22:43:03 +0800 Subject: [PATCH 07/18] make memo last feild again --- src/wallet/rpcwallet.cpp | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index f407710c7..01dabc4cc 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4164,8 +4164,9 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) + strprintf("%d", MERGE_TO_ADDRESS_DEFAULT_TRANSPARENT_LIMIT) + ") Limit on the maximum number of UTXOs to merge. Set to 0 to use node option -mempooltxinputlimit.\n" "4. shielded_limit (numeric, optional, default=" + strprintf("%d", MERGE_TO_ADDRESS_DEFAULT_SHIELDED_LIMIT) + ") Limit on the maximum number of notes to merge. Set to 0 to merge as many as will fit in the transaction.\n" - "5. \"memo\" (string, optional) Encoded as hex. When toaddress is a z-addr, this will be stored in the memo field of the new note.\n" - "6. maximum_utxo_size (int, optional) eg, 10000 anything under 10000 satoshies will be merged.\n" + "5. maximum_utxo_size (int, optional) eg, 10000 anything under 10000 satoshies will be merged.\n" + "6. \"memo\" (string, optional) Encoded as hex. When toaddress is a z-addr, this will be stored in the memo field of the new note.\n" + "\nResult:\n" "{\n" " \"remainingUTXOs\": xxx (numeric) Number of UTXOs still available for merging.\n" @@ -4283,9 +4284,20 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) } } - std::string memo; + CAmount maximum_utxo_size; if (params.size() > 5) { - memo = params[5].get_str(); + maximum_utxo_size = params[5].get_int(); + printf("maximum utxo size = %ld\n", maximum_utxo_size); + if (maximum_utxo_size < 10) { + throw JSONRPCError(RPC_INVALID_PARAMETER, "Maximum size must be bigger than 10 satoshies."); + } + } else { + maximum_utxo_size = 0; + } + + std::string memo; + if (params.size() > 6) { + memo = params[6].get_str(); if (!isToZaddr) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Memo can not be used with a taddr. It can only be used with a zaddr."); } else if (!IsHex(memo)) { @@ -4296,17 +4308,6 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) } } - CAmount maximum_utxo_size; - if (params.size() > 6) { - maximum_utxo_size = params[6].get_int(); - printf("maximum utxo size = %ld\n", maximum_utxo_size); - if (maximum_utxo_size < 10) { - throw JSONRPCError(RPC_INVALID_PARAMETER, "Maximum size must be bigger than 10 satoshies."); - } - } else { - maximum_utxo_size = 0; - } - MergeToAddressRecipient recipient(destaddress, memo); // Prepare to get UTXOs and notes From a0c1d43977433cfabf79292d5f12acbc9bc23053 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 1 Oct 2018 22:48:24 +0800 Subject: [PATCH 08/18] long --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 01dabc4cc..f69e9eb4b 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4286,7 +4286,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) CAmount maximum_utxo_size; if (params.size() > 5) { - maximum_utxo_size = params[5].get_int(); + maximum_utxo_size = params[5].get_real(); printf("maximum utxo size = %ld\n", maximum_utxo_size); if (maximum_utxo_size < 10) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Maximum size must be bigger than 10 satoshies."); From 4bdd7e26cd5ed9e64c87118bf4eb9992eeab210d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 1 Oct 2018 22:58:42 +0800 Subject: [PATCH 09/18] try --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index f69e9eb4b..b147d4307 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4286,7 +4286,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) CAmount maximum_utxo_size; if (params.size() > 5) { - maximum_utxo_size = params[5].get_real(); + maximum_utxo_size = AmountFromValue( params[5] ); printf("maximum utxo size = %ld\n", maximum_utxo_size); if (maximum_utxo_size < 10) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Maximum size must be bigger than 10 satoshies."); From dfba8357f375f599bf641c09dea73af64f75d04c Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 1 Oct 2018 23:09:36 +0800 Subject: [PATCH 10/18] fingers crossed --- src/wallet/rpcwallet.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index b147d4307..e0efa9cb4 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4164,7 +4164,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) + strprintf("%d", MERGE_TO_ADDRESS_DEFAULT_TRANSPARENT_LIMIT) + ") Limit on the maximum number of UTXOs to merge. Set to 0 to use node option -mempooltxinputlimit.\n" "4. shielded_limit (numeric, optional, default=" + strprintf("%d", MERGE_TO_ADDRESS_DEFAULT_SHIELDED_LIMIT) + ") Limit on the maximum number of notes to merge. Set to 0 to merge as many as will fit in the transaction.\n" - "5. maximum_utxo_size (int, optional) eg, 10000 anything under 10000 satoshies will be merged.\n" + "5. maximum_utxo_size (numeric, optional) eg, 0.0001 anything under 10000 satoshies will be merged.\n" "6. \"memo\" (string, optional) Encoded as hex. When toaddress is a z-addr, this will be stored in the memo field of the new note.\n" "\nResult:\n" @@ -4289,7 +4289,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) maximum_utxo_size = AmountFromValue( params[5] ); printf("maximum utxo size = %ld\n", maximum_utxo_size); if (maximum_utxo_size < 10) { - throw JSONRPCError(RPC_INVALID_PARAMETER, "Maximum size must be bigger than 10 satoshies."); + throw JSONRPCError(RPC_INVALID_PARAMETER, "Maximum size must be bigger than 0.00000010."); } } else { maximum_utxo_size = 0; @@ -4358,7 +4358,12 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) if (maximum_utxo_size != 0) { printf("maximum utxo size = %ld \n", maximum_utxo_size); - printf("nValue = %ld\n", nValue); + if (nValue > maximum_utxo_size) { + printf("nValue = %ld which is over maximum size so we will ignore it!\n", nValue); + continue; + } else { + printf("utxo found under maximum size so we will add it!\n", ); + } } if (!maxedOutUTXOsFlag) { From 743131799fb25db2145a450aa59d1bfb52e224e8 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 1 Oct 2018 23:10:53 +0800 Subject: [PATCH 11/18] , --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index e0efa9cb4..cb81244ae 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4362,7 +4362,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) printf("nValue = %ld which is over maximum size so we will ignore it!\n", nValue); continue; } else { - printf("utxo found under maximum size so we will add it!\n", ); + printf("utxo found under maximum size so we will add it!\n"); } } From cd6fbe09777fbef8a5b6f9a130c3bb71a4f334a9 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 1 Oct 2018 23:25:24 +0800 Subject: [PATCH 12/18] add exeption for iguana utxo --- src/wallet/rpcwallet.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index cb81244ae..a05aed988 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4362,7 +4362,11 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) printf("nValue = %ld which is over maximum size so we will ignore it!\n", nValue); continue; } else { - printf("utxo found under maximum size so we will add it!\n"); + if (out.tx->vout[out.i].scriptPubKey.size() != 35) { + printf("utxo is an iguana utxo so we will ingore it!\n"); + continue; + } + printf("utxo found under maximum size that is not p2pk so we will add it!\n"); } } From 41fddfc0bf860d178a9b5328a4c8c69924cfa91d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 1 Oct 2018 23:31:05 +0800 Subject: [PATCH 13/18] fix --- src/wallet/rpcwallet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index a05aed988..def79e51d 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4357,12 +4357,12 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) CAmount nValue = out.tx->vout[out.i].nValue; if (maximum_utxo_size != 0) { - printf("maximum utxo size = %ld \n", maximum_utxo_size); + //printf("maximum utxo size = %ld \n", maximum_utxo_size); if (nValue > maximum_utxo_size) { printf("nValue = %ld which is over maximum size so we will ignore it!\n", nValue); continue; } else { - if (out.tx->vout[out.i].scriptPubKey.size() != 35) { + if (out.tx->vout[out.i].scriptPubKey.size() = 35) { printf("utxo is an iguana utxo so we will ingore it!\n"); continue; } From 30c320d1f66032ca1e02a505982a0940f362a94e Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 1 Oct 2018 23:32:21 +0800 Subject: [PATCH 14/18] = --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index def79e51d..e766e6bf6 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4362,7 +4362,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) printf("nValue = %ld which is over maximum size so we will ignore it!\n", nValue); continue; } else { - if (out.tx->vout[out.i].scriptPubKey.size() = 35) { + if (out.tx->vout[out.i].scriptPubKey.size() == 35) { printf("utxo is an iguana utxo so we will ingore it!\n"); continue; } From 5d8a1637ae63b3aa38e60e1ac18ac42298462683 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 1 Oct 2018 23:43:20 +0800 Subject: [PATCH 15/18] remove prints to speed it up --- src/wallet/rpcwallet.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index e766e6bf6..a429b81ac 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4164,7 +4164,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) + strprintf("%d", MERGE_TO_ADDRESS_DEFAULT_TRANSPARENT_LIMIT) + ") Limit on the maximum number of UTXOs to merge. Set to 0 to use node option -mempooltxinputlimit.\n" "4. shielded_limit (numeric, optional, default=" + strprintf("%d", MERGE_TO_ADDRESS_DEFAULT_SHIELDED_LIMIT) + ") Limit on the maximum number of notes to merge. Set to 0 to merge as many as will fit in the transaction.\n" - "5. maximum_utxo_size (numeric, optional) eg, 0.0001 anything under 10000 satoshies will be merged.\n" + "5. maximum_utxo_size (numeric, optional) eg, 0.0001 anything under 10000 satoshies will be merged, ignores p2pk utxo!\n" "6. \"memo\" (string, optional) Encoded as hex. When toaddress is a z-addr, this will be stored in the memo field of the new note.\n" "\nResult:\n" @@ -4287,7 +4287,6 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) CAmount maximum_utxo_size; if (params.size() > 5) { maximum_utxo_size = AmountFromValue( params[5] ); - printf("maximum utxo size = %ld\n", maximum_utxo_size); if (maximum_utxo_size < 10) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Maximum size must be bigger than 0.00000010."); } @@ -4366,7 +4365,6 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) printf("utxo is an iguana utxo so we will ingore it!\n"); continue; } - printf("utxo found under maximum size that is not p2pk so we will add it!\n"); } } From f882623570959e3566ae0dca500272d4ebdf5de4 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 2 Oct 2018 00:42:14 +0800 Subject: [PATCH 16/18] remove prints and fix utxo counter in wrong place --- src/wallet/rpcwallet.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index a429b81ac..641a42f04 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4352,22 +4352,20 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) continue; } - utxoCounter++; CAmount nValue = out.tx->vout[out.i].nValue; if (maximum_utxo_size != 0) { - //printf("maximum utxo size = %ld \n", maximum_utxo_size); if (nValue > maximum_utxo_size) { - printf("nValue = %ld which is over maximum size so we will ignore it!\n", nValue); continue; } else { if (out.tx->vout[out.i].scriptPubKey.size() == 35) { - printf("utxo is an iguana utxo so we will ingore it!\n"); continue; } } } + utxoCounter++; + if (!maxedOutUTXOsFlag) { CBitcoinAddress ba(address); size_t increase = (ba.IsScript()) ? CTXIN_SPEND_P2SH_SIZE : CTXIN_SPEND_DUST_SIZE; From 478370fd6c3322dc6a2e65960d2ac8ed27d08450 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 2 Oct 2018 00:52:12 +0800 Subject: [PATCH 17/18] numutxos < 2 instead of 0... cant merge 1 utxo --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 641a42f04..7ef43e5db 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4429,7 +4429,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) #endif - if (numUtxos == 0 && numNotes == 0) { + if (numUtxos > 2 && numNotes == 0) { throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Could not find any funds to merge."); } From 0367b1a6856da6f5176f76ff11f15023d97ca3d8 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 2 Oct 2018 00:53:28 +0800 Subject: [PATCH 18/18] < --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 7ef43e5db..7de29528f 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4429,7 +4429,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) #endif - if (numUtxos > 2 && numNotes == 0) { + if (numUtxos < 2 && numNotes == 0) { throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Could not find any funds to merge."); }