From 3307124a2b8ec22e4544bad94ddb60279fed07bf Mon Sep 17 00:00:00 2001 From: Simon Date: Mon, 6 Feb 2017 23:29:07 -0800 Subject: [PATCH 1/2] Add parameter interaction, where zrpcunsafe implies zrpc --- src/init.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/init.cpp b/src/init.cpp index 55bf6655d..7d5ffe9e6 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -378,7 +378,7 @@ std::string HelpMessage(HelpMessageMode mode) strUsage += HelpMessageOpt("-stopafterblockimport", strprintf("Stop running after importing blocks from disk (default: %u)", 0)); } string debugCategories = "addrman, alert, bench, coindb, db, estimatefee, lock, mempool, net, partitioncheck, pow, proxy, prune, " - "rand, reindex, rpc, selectcoins, zrpc, zrpcunsafe"; // Don't translate these and qt below + "rand, reindex, rpc, selectcoins, zrpc, zrpcunsafe (implies zrpc)"; // Don't translate these and qt below if (mode == HMM_BITCOIN_QT) debugCategories += ", qt"; strUsage += HelpMessageOpt("-debug=", strprintf(_("Output debugging information (default: %u, supplying is optional)"), 0) + ". " + @@ -802,6 +802,15 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) if (GetBoolArg("-nodebug", false) || find(categories.begin(), categories.end(), string("0")) != categories.end()) fDebug = false; + // Special case: if debug=zrpcunsafe, implies debug=zrpc, so add it to debug categories + if (find(categories.begin(), categories.end(), string("zrpcunsafe")) != categories.end()) { + if (find(categories.begin(), categories.end(), string("zrpc")) == categories.end()) { + LogPrintf("%s: parameter interaction: -debug=zrpcunsafe -> -debug=zrpc\n", __func__); + vector& v = mapMultiArgs["-debug"]; + v.push_back("zrpc"); + } + } + // Check for -debugnet if (GetBoolArg("-debugnet", false)) InitWarning(_("Warning: Unsupported argument -debugnet ignored, use -debug=net.")); From 43b6753782962261898f6a1c3934640dfa6af640 Mon Sep 17 00:00:00 2001 From: Simon Date: Tue, 7 Feb 2017 00:02:02 -0800 Subject: [PATCH 2/2] Update zrpc vs zrpcunsafe logging in z_sendmany operation --- src/init.cpp | 2 +- src/wallet/asyncrpcoperation_sendmany.cpp | 50 +++++++++-------------- 2 files changed, 21 insertions(+), 31 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index 7d5ffe9e6..cf09fe06f 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -805,7 +805,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) // Special case: if debug=zrpcunsafe, implies debug=zrpc, so add it to debug categories if (find(categories.begin(), categories.end(), string("zrpcunsafe")) != categories.end()) { if (find(categories.begin(), categories.end(), string("zrpc")) == categories.end()) { - LogPrintf("%s: parameter interaction: -debug=zrpcunsafe -> -debug=zrpc\n", __func__); + LogPrintf("%s: parameter interaction: setting -debug=zrpcunsafe -> -debug=zrpc\n", __func__); vector& v = mapMultiArgs["-debug"]; v.push_back("zrpc"); } diff --git a/src/wallet/asyncrpcoperation_sendmany.cpp b/src/wallet/asyncrpcoperation_sendmany.cpp index f0600c7f0..e03cd58ae 100644 --- a/src/wallet/asyncrpcoperation_sendmany.cpp +++ b/src/wallet/asyncrpcoperation_sendmany.cpp @@ -276,13 +276,13 @@ bool AsyncRPCOperation_sendmany::main_impl() { tx_ = CTransaction(rawTx); } - LogPrint("zrpc", "%s: spending %s to send %s with fee %s\n", + LogPrint((isfromtaddr_) ? "zrpc" : "zrpcunsafe", "%s: spending %s to send %s with fee %s\n", getId(), FormatMoney(targetAmount, false), FormatMoney(sendAmount, false), FormatMoney(minersFee, false)); - LogPrint("zrpc", "%s: - transparent input: %s (to choose from)\n", getId(), FormatMoney(t_inputs_total, false)); - LogPrint("zrpc", "%s: - private input: %s (to choose from)\n", getId(), FormatMoney(z_inputs_total, false)); - LogPrint("zrpc", "%s: - transparent output: %s\n", getId(), FormatMoney(t_outputs_total, false)); - LogPrint("zrpc", "%s: - private output: %s\n", getId(), FormatMoney(z_outputs_total, false)); - LogPrint("zrpc", "%s: - fee: %s\n", getId(), FormatMoney(minersFee, false)); + LogPrint("zrpc", "%s: transparent input: %s (to choose from)\n", getId(), FormatMoney(t_inputs_total, false)); + LogPrint("zrpcunsafe", "%s: private input: %s (to choose from)\n", getId(), FormatMoney(z_inputs_total, false)); + LogPrint("zrpc", "%s: transparent output: %s\n", getId(), FormatMoney(t_outputs_total, false)); + LogPrint("zrpcunsafe", "%s: private output: %s\n", getId(), FormatMoney(z_outputs_total, false)); + LogPrint("zrpc", "%s: fee: %s\n", getId(), FormatMoney(minersFee, false)); /** * SCENARIO #1 @@ -467,7 +467,7 @@ bool AsyncRPCOperation_sendmany::main_impl() { wtxHeight = mapBlockIndex[wtx.hashBlock]->nHeight; wtxDepth = wtx.GetDepthInMainChain(); } - LogPrint("zrpc", "%s: spending note (txid=%s, vjoinsplit=%d, ciphertext=%d, amount=%s, height=%d, confirmations=%d)\n", + LogPrint("zrpcunsafe", "%s: spending note (txid=%s, vjoinsplit=%d, ciphertext=%d, amount=%s, height=%d, confirmations=%d)\n", getId(), outPoint.hash.ToString().substr(0, 10), outPoint.js, @@ -496,7 +496,7 @@ bool AsyncRPCOperation_sendmany::main_impl() { info.vjsout.push_back(JSOutput()); info.vjsout.push_back(JSOutput(frompaymentaddress_, jsChange)); - LogPrint("zrpc", "%s: generating note for change (amount=%s)\n", + LogPrint("zrpcunsafe", "%s: generating note for change (amount=%s)\n", getId(), FormatMoney(jsChange, false) ); @@ -592,7 +592,7 @@ bool AsyncRPCOperation_sendmany::main_impl() { jsInputValue += plaintext.value; - LogPrint("zrpc", "%s: spending change (amount=%s)\n", + LogPrint("zrpcunsafe", "%s: spending change (amount=%s)\n", getId(), FormatMoney(plaintext.value, false) ); @@ -639,7 +639,7 @@ bool AsyncRPCOperation_sendmany::main_impl() { wtxHeight = mapBlockIndex[wtx.hashBlock]->nHeight; wtxDepth = wtx.GetDepthInMainChain(); } - LogPrint("zrpc", "%s: spending note (txid=%s, vjoinsplit=%d, ciphertext=%d, amount=%s, height=%d, confirmations=%d)\n", + LogPrint("zrpcunsafe", "%s: spending note (txid=%s, vjoinsplit=%d, ciphertext=%d, amount=%s, height=%d, confirmations=%d)\n", getId(), jso.hash.ToString().substr(0, 10), jso.js, @@ -734,7 +734,7 @@ bool AsyncRPCOperation_sendmany::main_impl() { if (jsChange>0) { info.vjsout.push_back(JSOutput(frompaymentaddress_, jsChange)); - LogPrint("zrpc", "%s: generating note for change (amount=%s)\n", + LogPrint("zrpcunsafe", "%s: generating note for change (amount=%s)\n", getId(), FormatMoney(jsChange, false) ); @@ -869,24 +869,14 @@ bool AsyncRPCOperation_sendmany::find_unspent_notes() { for (CNotePlaintextEntry & entry : entries) { z_inputs_.push_back(SendManyInputJSOP(entry.jsop, entry.plaintext.note(frompaymentaddress_), CAmount(entry.plaintext.value))); std::string data(entry.plaintext.memo.begin(), entry.plaintext.memo.end()); - if (LogAcceptCategory("zrpcunsafe")) { - LogPrint("zrpcunsafe", "%s: found unspent note (txid=%s, vjoinsplit=%d, ciphertext=%d, amount=%s, memo=%s)\n", - getId(), - entry.jsop.hash.ToString().substr(0, 10), - entry.jsop.js, - int(entry.jsop.n), // uint8_t - FormatMoney(entry.plaintext.value, false), - HexStr(data).substr(0, 10) - ); - } else { - LogPrint("zrpc", "%s: found unspent note (txid=%s, vjoinsplit=%d, ciphertext=%d, amount=%s)\n", - getId(), - entry.jsop.hash.ToString().substr(0, 10), - entry.jsop.js, - int(entry.jsop.n), // uint8_t - FormatMoney(entry.plaintext.value, false) - ); - } + LogPrint("zrpcunsafe", "%s: found unspent note (txid=%s, vjoinsplit=%d, ciphertext=%d, amount=%s, memo=%s)\n", + getId(), + entry.jsop.hash.ToString().substr(0, 10), + entry.jsop.js, + int(entry.jsop.n), // uint8_t + FormatMoney(entry.plaintext.value, false), + HexStr(data).substr(0, 10) + ); } if (z_inputs_.size() == 0) { @@ -957,7 +947,7 @@ Object AsyncRPCOperation_sendmany::perform_joinsplit( CMutableTransaction mtx(tx_); - LogPrint("zrpc", "%s: creating joinsplit at index %d (vpub_old=%s, vpub_new=%s, in[0]=%s, in[1]=%s, out[0]=%s, out[1]=%s)\n", + LogPrint("zrpcunsafe", "%s: creating joinsplit at index %d (vpub_old=%s, vpub_new=%s, in[0]=%s, in[1]=%s, out[0]=%s, out[1]=%s)\n", getId(), tx_.vjoinsplit.size(), FormatMoney(info.vpub_old, false), FormatMoney(info.vpub_new, false),