mirror of
https://github.com/oxen-io/oxen-core.git
synced 2023-12-14 02:22:56 +01:00
RELAY_TX
This commit is contained in:
parent
09d4baf63e
commit
7d8189f7bb
|
@ -1409,9 +1409,10 @@ bool rpc_command_executor::print_blockchain_dynamic_stats(uint64_t nblocks)
|
|||
|
||||
bool rpc_command_executor::relay_tx(const std::string &txid)
|
||||
{
|
||||
RELAY_TX::response res{};
|
||||
if (!invoke<RELAY_TX>({{txid}}, res, "Failed to relay tx"))
|
||||
return false;
|
||||
auto maybe_relay = try_running([&] { return invoke<RELAY_TX>(json{{"txid", txid}}); },
|
||||
"Failed to relay tx");
|
||||
if (!maybe_relay)
|
||||
return false;
|
||||
|
||||
tools::success_msg_writer() << "Transaction successfully relayed";
|
||||
return true;
|
||||
|
|
|
@ -2239,20 +2239,18 @@ namespace cryptonote::rpc {
|
|||
pop_blocks.response["status"] = STATUS_OK;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
RELAY_TX::response core_rpc_server::invoke(RELAY_TX::request&& req, rpc_context context)
|
||||
void core_rpc_server::invoke(RELAY_TX& relay_tx, rpc_context context)
|
||||
{
|
||||
RELAY_TX::response res{};
|
||||
|
||||
PERF_TIMER(on_relay_tx);
|
||||
|
||||
res.status = "";
|
||||
for (const auto &str: req.txids)
|
||||
std::string status = "";
|
||||
for (const auto &str: relay_tx.request.txids)
|
||||
{
|
||||
cryptonote::blobdata txid_data;
|
||||
if(!epee::string_tools::parse_hexstr_to_binbuff(str, txid_data))
|
||||
{
|
||||
if (!res.status.empty()) res.status += ", ";
|
||||
res.status += "invalid transaction id: " + str;
|
||||
if (!status.empty()) status += ", ";
|
||||
status += "invalid transaction id: " + str;
|
||||
continue;
|
||||
}
|
||||
crypto::hash txid = *reinterpret_cast<const crypto::hash*>(txid_data.data());
|
||||
|
@ -2269,16 +2267,17 @@ namespace cryptonote::rpc {
|
|||
}
|
||||
else
|
||||
{
|
||||
if (!res.status.empty()) res.status += ", ";
|
||||
res.status += "transaction not found in pool: " + str;
|
||||
if (!status.empty()) status += ", ";
|
||||
status += "transaction not found in pool: " + str;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (res.status.empty())
|
||||
res.status = STATUS_OK;
|
||||
if (status.empty())
|
||||
status = STATUS_OK;
|
||||
|
||||
return res;
|
||||
relay_tx.response["status"] = status;
|
||||
return;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
void core_rpc_server::invoke(SYNC_INFO& sync, rpc_context context)
|
||||
|
|
|
@ -253,6 +253,7 @@ namespace cryptonote::rpc {
|
|||
void invoke(GET_SERVICE_KEYS& get_service_keys, rpc_context context);
|
||||
void invoke(GET_SERVICE_PRIVKEYS& get_service_privkeys, rpc_context context);
|
||||
void invoke(GET_SERVICE_NODE_BLACKLISTED_KEY_IMAGES& get_service_node_blacklisted_key_images, rpc_context context);
|
||||
void invoke(RELAY_TX& relay_tx, rpc_context context);
|
||||
|
||||
// Deprecated Monero NIH binary endpoints:
|
||||
GET_ALT_BLOCKS_HASHES_BIN::response invoke(GET_ALT_BLOCKS_HASHES_BIN::request&& req, rpc_context context);
|
||||
|
@ -273,7 +274,6 @@ namespace cryptonote::rpc {
|
|||
GET_BLOCK::response invoke(GET_BLOCK::request&& req, rpc_context context);
|
||||
GET_OUTPUT_HISTOGRAM::response invoke(GET_OUTPUT_HISTOGRAM::request&& req, rpc_context context);
|
||||
GET_ALTERNATE_CHAINS::response invoke(GET_ALTERNATE_CHAINS::request&& req, rpc_context context);
|
||||
RELAY_TX::response invoke(RELAY_TX::request&& req, rpc_context context);
|
||||
GET_QUORUM_STATE::response invoke(GET_QUORUM_STATE::request&& req, rpc_context context);
|
||||
GET_SERVICE_NODE_REGISTRATION_CMD_RAW::response invoke(GET_SERVICE_NODE_REGISTRATION_CMD_RAW::request&& req, rpc_context context);
|
||||
GET_SERVICE_NODE_REGISTRATION_CMD::response invoke(GET_SERVICE_NODE_REGISTRATION_CMD::request&& req, rpc_context context);
|
||||
|
|
|
@ -196,11 +196,6 @@ KV_SERIALIZE_MAP_CODE_BEGIN(GET_ALTERNATE_CHAINS::response)
|
|||
KV_SERIALIZE_MAP_CODE_END()
|
||||
|
||||
|
||||
KV_SERIALIZE_MAP_CODE_BEGIN(RELAY_TX::request)
|
||||
KV_SERIALIZE(txids)
|
||||
KV_SERIALIZE_MAP_CODE_END()
|
||||
|
||||
|
||||
KV_SERIALIZE_MAP_CODE_BEGIN(GET_OUTPUT_DISTRIBUTION::request)
|
||||
KV_SERIALIZE(amounts)
|
||||
KV_SERIALIZE_OPT(from_height, (uint64_t)0)
|
||||
|
|
|
@ -1465,20 +1465,23 @@ namespace cryptonote::rpc {
|
|||
};
|
||||
};
|
||||
|
||||
OXEN_RPC_DOC_INTROSPECT
|
||||
// Relay a list of transaction IDs.
|
||||
/// Relay a list of transaction IDs.
|
||||
///
|
||||
/// Inputs:
|
||||
///
|
||||
/// - \p txids List of transactions IDs to relay from pool.
|
||||
///
|
||||
/// Output values available from a restricted/admin RPC endpoint:
|
||||
///
|
||||
/// - \p status General RPC status string. `"OK"` means everything looks good.
|
||||
struct RELAY_TX : RPC_COMMAND
|
||||
{
|
||||
static constexpr auto names() { return NAMES("relay_tx"); }
|
||||
|
||||
struct request
|
||||
struct request_parameters
|
||||
{
|
||||
std::vector<std::string> txids; // List of transactions IDs to relay from pool.
|
||||
|
||||
KV_MAP_SERIALIZABLE
|
||||
};
|
||||
|
||||
struct response : STATUS {};
|
||||
} request;
|
||||
};
|
||||
|
||||
/// Get node synchronisation information. This returns information on the node's syncing "spans"
|
||||
|
@ -1490,7 +1493,7 @@ namespace cryptonote::rpc {
|
|||
///
|
||||
/// Inputs: none
|
||||
///
|
||||
/// Output values available from an admin RPC endpoint:
|
||||
/// Output values available from a restricted/admin RPC endpoint:
|
||||
///
|
||||
/// - \p status General RPC status string. `"OK"` means everything looks good.
|
||||
/// - \p height Current block height
|
||||
|
|
Loading…
Reference in a new issue