From 3dee3301baa7a3582c09c517c416ec49afc3c689 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Sat, 16 Sep 2017 10:31:49 +0100 Subject: [PATCH 1/3] core_rpc_server: print tx rejection reason at L0 too --- src/rpc/core_rpc_server.cpp | 50 +++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp index a6a61705b..254a3b71d 100644 --- a/src/rpc/core_rpc_server.cpp +++ b/src/rpc/core_rpc_server.cpp @@ -50,6 +50,16 @@ using namespace epee; #define MAX_RESTRICTED_FAKE_OUTS_COUNT 40 #define MAX_RESTRICTED_GLOBAL_FAKE_OUTS_COUNT 500 +namespace +{ + void add_reason(std::string &reasons, const char *reason) + { + if (!reasons.empty()) + reasons += ", "; + reasons += reason; + } +} + namespace cryptonote { @@ -623,31 +633,33 @@ namespace cryptonote tx_verification_context tvc = AUTO_VAL_INIT(tvc); if(!m_core.handle_incoming_tx(tx_blob, tvc, false, false, req.do_not_relay) || tvc.m_verifivation_failed) { + res.status = "Failed"; + res.reason = ""; + if ((res.low_mixin = tvc.m_low_mixin)) + add_reason(res.reason, "ring size too small"); + if ((res.double_spend = tvc.m_double_spend)) + add_reason(res.reason, "double spend"); + if ((res.invalid_input = tvc.m_invalid_input)) + add_reason(res.reason, "invalid input"); + if ((res.invalid_output = tvc.m_invalid_output)) + add_reason(res.reason, "invalid output"); + if ((res.too_big = tvc.m_too_big)) + add_reason(res.reason, "too big"); + if ((res.overspend = tvc.m_overspend)) + add_reason(res.reason, "overspend"); + if ((res.fee_too_low = tvc.m_fee_too_low)) + add_reason(res.reason, "fee too low"); + if ((res.not_rct = tvc.m_not_rct)) + add_reason(res.reason, "tx is not ringct"); + const std::string punctuation = res.reason.empty() ? "" : ": "; if (tvc.m_verifivation_failed) { - LOG_PRINT_L0("[on_send_raw_tx]: tx verification failed"); + LOG_PRINT_L0("[on_send_raw_tx]: tx verification failed" << punctuation << res.reason); } else { - LOG_PRINT_L0("[on_send_raw_tx]: Failed to process tx"); + LOG_PRINT_L0("[on_send_raw_tx]: Failed to process tx" << punctuation << res.reason); } - res.status = "Failed"; - if ((res.low_mixin = tvc.m_low_mixin)) - res.reason = "ring size too small"; - if ((res.double_spend = tvc.m_double_spend)) - res.reason = "double spend"; - if ((res.invalid_input = tvc.m_invalid_input)) - res.reason = "invalid input"; - if ((res.invalid_output = tvc.m_invalid_output)) - res.reason = "invalid output"; - if ((res.too_big = tvc.m_too_big)) - res.reason = "too big"; - if ((res.overspend = tvc.m_overspend)) - res.reason = "overspend"; - if ((res.fee_too_low = tvc.m_fee_too_low)) - res.reason = "fee too low"; - if ((res.not_rct = tvc.m_not_rct)) - res.reason = "tx is not ringct"; return true; } From 9236823bf477093890335d757627f1c7e9a82dc2 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Sat, 16 Sep 2017 10:32:12 +0100 Subject: [PATCH 2/3] simplewallet: print tx rejection reason where it was missing --- src/simplewallet/simplewallet.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index 857e2af6e..fea97adc3 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -3474,6 +3474,9 @@ bool simple_wallet::submit_transfer(const std::vector &args_) catch (const tools::error::tx_rejected& e) { fail_msg_writer() << (boost::format(tr("transaction %s was rejected by daemon with status: ")) % get_transaction_hash(e.tx())) << e.status(); + std::string reason = e.reason(); + if (!reason.empty()) + fail_msg_writer() << tr("Reason: ") << reason; } catch (const tools::error::tx_sum_overflow& e) { From 0aaaca29a26b2910ff33dd7b9f5d1c26ca5cdc7f Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Sat, 16 Sep 2017 11:27:26 +0100 Subject: [PATCH 3/3] tx_pool: set the "invalid input" bit when check_tx_inputs fails --- src/cryptonote_core/tx_pool.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cryptonote_core/tx_pool.cpp b/src/cryptonote_core/tx_pool.cpp index e61d95ac3..8d4d90d37 100644 --- a/src/cryptonote_core/tx_pool.cpp +++ b/src/cryptonote_core/tx_pool.cpp @@ -246,6 +246,7 @@ namespace cryptonote { LOG_PRINT_L1("tx used wrong inputs, rejected"); tvc.m_verifivation_failed = true; + tvc.m_invalid_input = true; return false; } }else