rpc: always send raw txes through P2P (don't use bootstrap daemon)
It turns out that some remote (bootstrap) nodes silently drop / don't broadcast client's transactions.
This commit is contained in:
parent
c108c5e2f0
commit
728ba38b11
@ -1119,11 +1119,23 @@ namespace cryptonote
|
||||
bool core_rpc_server::on_send_raw_tx(const COMMAND_RPC_SEND_RAW_TX::request& req, COMMAND_RPC_SEND_RAW_TX::response& res, const connection_context *ctx)
|
||||
{
|
||||
RPC_TRACKER(send_raw_tx);
|
||||
bool ok;
|
||||
if (use_bootstrap_daemon_if_necessary<COMMAND_RPC_SEND_RAW_TX>(invoke_http_mode::JON, "/sendrawtransaction", req, res, ok))
|
||||
return ok;
|
||||
|
||||
CHECK_CORE_READY();
|
||||
const bool restricted = m_restricted && ctx;
|
||||
|
||||
bool skip_validation = false;
|
||||
if (!restricted)
|
||||
{
|
||||
boost::shared_lock<boost::shared_mutex> lock(m_bootstrap_daemon_mutex);
|
||||
if (m_bootstrap_daemon.get() != nullptr)
|
||||
{
|
||||
skip_validation = !check_core_ready();
|
||||
}
|
||||
else
|
||||
{
|
||||
CHECK_CORE_READY();
|
||||
}
|
||||
}
|
||||
|
||||
CHECK_PAYMENT_MIN1(req, res, COST_PER_TX_RELAY, false);
|
||||
|
||||
std::string tx_blob;
|
||||
@ -1143,48 +1155,49 @@ namespace cryptonote
|
||||
}
|
||||
res.sanity_check_failed = false;
|
||||
|
||||
const bool restricted = m_restricted && ctx;
|
||||
|
||||
tx_verification_context tvc{};
|
||||
if(!m_core.handle_incoming_tx({tx_blob, crypto::null_hash}, tvc, (req.do_not_relay ? relay_method::none : relay_method::local), false) || tvc.m_verifivation_failed)
|
||||
if (!skip_validation)
|
||||
{
|
||||
res.status = "Failed";
|
||||
std::string reason = "";
|
||||
if ((res.low_mixin = tvc.m_low_mixin))
|
||||
add_reason(reason, "bad ring size");
|
||||
if ((res.double_spend = tvc.m_double_spend))
|
||||
add_reason(reason, "double spend");
|
||||
if ((res.invalid_input = tvc.m_invalid_input))
|
||||
add_reason(reason, "invalid input");
|
||||
if ((res.invalid_output = tvc.m_invalid_output))
|
||||
add_reason(reason, "invalid output");
|
||||
if ((res.too_big = tvc.m_too_big))
|
||||
add_reason(reason, "too big");
|
||||
if ((res.overspend = tvc.m_overspend))
|
||||
add_reason(reason, "overspend");
|
||||
if ((res.fee_too_low = tvc.m_fee_too_low))
|
||||
add_reason(reason, "fee too low");
|
||||
if ((res.too_few_outputs = tvc.m_too_few_outputs))
|
||||
add_reason(reason, "too few outputs");
|
||||
const std::string punctuation = reason.empty() ? "" : ": ";
|
||||
if (tvc.m_verifivation_failed)
|
||||
tx_verification_context tvc{};
|
||||
if(!m_core.handle_incoming_tx({tx_blob, crypto::null_hash}, tvc, (req.do_not_relay ? relay_method::none : relay_method::local), false) || tvc.m_verifivation_failed)
|
||||
{
|
||||
LOG_PRINT_L0("[on_send_raw_tx]: tx verification failed" << punctuation << reason);
|
||||
res.status = "Failed";
|
||||
std::string reason = "";
|
||||
if ((res.low_mixin = tvc.m_low_mixin))
|
||||
add_reason(reason, "bad ring size");
|
||||
if ((res.double_spend = tvc.m_double_spend))
|
||||
add_reason(reason, "double spend");
|
||||
if ((res.invalid_input = tvc.m_invalid_input))
|
||||
add_reason(reason, "invalid input");
|
||||
if ((res.invalid_output = tvc.m_invalid_output))
|
||||
add_reason(reason, "invalid output");
|
||||
if ((res.too_big = tvc.m_too_big))
|
||||
add_reason(reason, "too big");
|
||||
if ((res.overspend = tvc.m_overspend))
|
||||
add_reason(reason, "overspend");
|
||||
if ((res.fee_too_low = tvc.m_fee_too_low))
|
||||
add_reason(reason, "fee too low");
|
||||
if ((res.too_few_outputs = tvc.m_too_few_outputs))
|
||||
add_reason(reason, "too few outputs");
|
||||
const std::string punctuation = reason.empty() ? "" : ": ";
|
||||
if (tvc.m_verifivation_failed)
|
||||
{
|
||||
LOG_PRINT_L0("[on_send_raw_tx]: tx verification failed" << punctuation << reason);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_PRINT_L0("[on_send_raw_tx]: Failed to process tx" << punctuation << reason);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_PRINT_L0("[on_send_raw_tx]: Failed to process tx" << punctuation << reason);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if(tvc.m_relay == relay_method::none)
|
||||
{
|
||||
LOG_PRINT_L0("[on_send_raw_tx]: tx accepted, but not relayed");
|
||||
res.reason = "Not relayed";
|
||||
res.not_relayed = true;
|
||||
res.status = CORE_RPC_STATUS_OK;
|
||||
return true;
|
||||
if(tvc.m_relay == relay_method::none)
|
||||
{
|
||||
LOG_PRINT_L0("[on_send_raw_tx]: tx accepted, but not relayed");
|
||||
res.reason = "Not relayed";
|
||||
res.not_relayed = true;
|
||||
res.status = CORE_RPC_STATUS_OK;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
NOTIFY_NEW_TRANSACTIONS::request r;
|
||||
|
Loading…
Reference in New Issue
Block a user