|
|
|
@ -61,10 +61,6 @@ rpccalls::get_current_height()
|
|
|
|
|
<< deamon_url << endl;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
cout << "rpc call /getheight OK: " << endl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return res.height;
|
|
|
|
|
}
|
|
|
|
@ -153,8 +149,10 @@ bool
|
|
|
|
|
rpccalls::get_network_info(COMMAND_RPC_GET_INFO::response& response)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
epee::json_rpc::request<cryptonote::COMMAND_RPC_GET_INFO::request> req_t = AUTO_VAL_INIT(req_t);
|
|
|
|
|
epee::json_rpc::response<cryptonote::COMMAND_RPC_GET_INFO::response, std::string> resp_t = AUTO_VAL_INIT(resp_t);
|
|
|
|
|
epee::json_rpc::request<cryptonote::COMMAND_RPC_GET_INFO::request>
|
|
|
|
|
req_t = AUTO_VAL_INIT(req_t);
|
|
|
|
|
epee::json_rpc::response<cryptonote::COMMAND_RPC_GET_INFO::response, std::string>
|
|
|
|
|
resp_t = AUTO_VAL_INIT(resp_t);
|
|
|
|
|
|
|
|
|
|
bool r {false};
|
|
|
|
|
|
|
|
|
@ -167,7 +165,7 @@ rpccalls::get_network_info(COMMAND_RPC_GET_INFO::response& response)
|
|
|
|
|
|
|
|
|
|
if (!connect_to_monero_deamon())
|
|
|
|
|
{
|
|
|
|
|
cerr << "get_mempool: not connected to deamon" << endl;
|
|
|
|
|
cerr << "get_network_info: not connected to deamon" << endl;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -228,12 +226,12 @@ rpccalls::get_dynamic_per_kb_fee_estimate(
|
|
|
|
|
|
|
|
|
|
bool r {false};
|
|
|
|
|
|
|
|
|
|
std::lock_guard<std::mutex> guard(m_daemon_rpc_mutex);
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
std::lock_guard<std::mutex> guard(m_daemon_rpc_mutex);
|
|
|
|
|
|
|
|
|
|
if (!connect_to_monero_deamon())
|
|
|
|
|
{
|
|
|
|
|
cerr << "get_current_height: not connected to deamon" << endl;
|
|
|
|
|
cerr << "get_dynamic_per_kb_fee_estimate: not connected to deamon" << endl;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -273,6 +271,74 @@ rpccalls::get_dynamic_per_kb_fee_estimate(
|
|
|
|
|
fee = resp_t.result.fee;
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
rpccalls::get_block(string const& blk_hash, block& blk, string& error_msg)
|
|
|
|
|
{
|
|
|
|
|
epee::json_rpc::request<COMMAND_RPC_GET_BLOCK::request> req_t;
|
|
|
|
|
epee::json_rpc::response<COMMAND_RPC_GET_BLOCK::response, std::string> resp_t;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
req_t.jsonrpc = "2.0";
|
|
|
|
|
req_t.id = epee::serialization::storage_entry(0);
|
|
|
|
|
req_t.method = "getblock";
|
|
|
|
|
req_t.params.hash = blk_hash;
|
|
|
|
|
|
|
|
|
|
bool r {false};
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
std::lock_guard<std::mutex> guard(m_daemon_rpc_mutex);
|
|
|
|
|
|
|
|
|
|
if (!connect_to_monero_deamon())
|
|
|
|
|
{
|
|
|
|
|
cerr << "get_block: not connected to deamon" << endl;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
r = epee::net_utils::invoke_http_json("/json_rpc",
|
|
|
|
|
req_t, resp_t,
|
|
|
|
|
m_http_client);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string err;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (r)
|
|
|
|
|
{
|
|
|
|
|
if (resp_t.result.status == CORE_RPC_STATUS_BUSY)
|
|
|
|
|
{
|
|
|
|
|
err = "daemon is busy. Please try again later.";
|
|
|
|
|
}
|
|
|
|
|
else if (resp_t.result.status != CORE_RPC_STATUS_OK)
|
|
|
|
|
{
|
|
|
|
|
err = resp_t.result.status;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!err.empty())
|
|
|
|
|
{
|
|
|
|
|
cerr << "Error connecting to Monero deamon due to "
|
|
|
|
|
<< err << endl;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
cerr << "get_block: error connecting to Monero deamon at "
|
|
|
|
|
<< deamon_url << endl;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string block_bin_blob;
|
|
|
|
|
|
|
|
|
|
if(!epee::string_tools::parse_hexstr_to_binbuff(resp_t.result.blob, block_bin_blob))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return parse_and_validate_block_from_blob(block_bin_blob, blk);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|