aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2017-09-25 16:53:07 +0200
committerRiccardo Spagni <ric@spagni.net>2017-09-25 16:53:07 +0200
commit0e7477707114e0dc5ec7e4e2683b5410a52afca4 (patch)
tree2e03710da2f12ebc6a160450e7dbe575642b15d9 /src
parentMerge pull request #2424 (diff)
parenttx_pool: set the "invalid input" bit when check_tx_inputs fails (diff)
downloadmonero-0e7477707114e0dc5ec7e4e2683b5410a52afca4.tar.xz
Merge pull request #2452
0aaaca29 tx_pool: set the "invalid input" bit when check_tx_inputs fails (moneromooo-monero) 9236823b simplewallet: print tx rejection reason where it was missing (moneromooo-monero) 3dee3301 core_rpc_server: print tx rejection reason at L0 too (moneromooo-monero)
Diffstat (limited to 'src')
-rw-r--r--src/cryptonote_core/tx_pool.cpp1
-rw-r--r--src/rpc/core_rpc_server.cpp44
-rw-r--r--src/simplewallet/simplewallet.cpp3
3 files changed, 32 insertions, 16 deletions
diff --git a/src/cryptonote_core/tx_pool.cpp b/src/cryptonote_core/tx_pool.cpp
index 0485f731f..9071c330c 100644
--- a/src/cryptonote_core/tx_pool.cpp
+++ b/src/cryptonote_core/tx_pool.cpp
@@ -249,6 +249,7 @@ namespace cryptonote
{
LOG_PRINT_L1("tx used wrong inputs, rejected");
tvc.m_verifivation_failed = true;
+ tvc.m_invalid_input = true;
return false;
}
}else
diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp
index 680d69d79..e814dcc1e 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
{
@@ -632,31 +642,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)
{
- if (tvc.m_verifivation_failed)
- {
- LOG_PRINT_L0("[on_send_raw_tx]: tx verification failed");
- }
- else
- {
- LOG_PRINT_L0("[on_send_raw_tx]: Failed to process tx");
- }
res.status = "Failed";
+ res.reason = "";
if ((res.low_mixin = tvc.m_low_mixin))
- res.reason = "ring size too small";
+ add_reason(res.reason, "ring size too small");
if ((res.double_spend = tvc.m_double_spend))
- res.reason = "double spend";
+ add_reason(res.reason, "double spend");
if ((res.invalid_input = tvc.m_invalid_input))
- res.reason = "invalid input";
+ add_reason(res.reason, "invalid input");
if ((res.invalid_output = tvc.m_invalid_output))
- res.reason = "invalid output";
+ add_reason(res.reason, "invalid output");
if ((res.too_big = tvc.m_too_big))
- res.reason = "too big";
+ add_reason(res.reason, "too big");
if ((res.overspend = tvc.m_overspend))
- res.reason = "overspend";
+ add_reason(res.reason, "overspend");
if ((res.fee_too_low = tvc.m_fee_too_low))
- res.reason = "fee too low";
+ add_reason(res.reason, "fee too low");
if ((res.not_rct = tvc.m_not_rct))
- res.reason = "tx is not ringct";
+ 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" << punctuation << res.reason);
+ }
+ else
+ {
+ LOG_PRINT_L0("[on_send_raw_tx]: Failed to process tx" << punctuation << res.reason);
+ }
return true;
}
diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp
index 575b711d5..d625634c8 100644
--- a/src/simplewallet/simplewallet.cpp
+++ b/src/simplewallet/simplewallet.cpp
@@ -3511,6 +3511,9 @@ bool simple_wallet::submit_transfer(const std::vector<std::string> &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)
{