|
|
|
@ -9,26 +9,26 @@ namespace xmreg
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rpccalls::rpccalls(
|
|
|
|
|
string _deamon_url,
|
|
|
|
|
string _daemon_url,
|
|
|
|
|
login_opt login,
|
|
|
|
|
uint64_t _timeout)
|
|
|
|
|
: deamon_url {_deamon_url},
|
|
|
|
|
: daemon_url {_daemon_url},
|
|
|
|
|
timeout_time {_timeout}
|
|
|
|
|
{
|
|
|
|
|
epee::net_utils::parse_url(deamon_url, url);
|
|
|
|
|
epee::net_utils::parse_url(daemon_url, url);
|
|
|
|
|
|
|
|
|
|
port = std::to_string(url.port);
|
|
|
|
|
|
|
|
|
|
timeout_time_ms = std::chrono::milliseconds {timeout_time};
|
|
|
|
|
|
|
|
|
|
m_http_client.set_server(
|
|
|
|
|
deamon_url,
|
|
|
|
|
daemon_url,
|
|
|
|
|
login,
|
|
|
|
|
epee::net_utils::ssl_support_t::e_ssl_support_disabled);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
rpccalls::connect_to_monero_deamon()
|
|
|
|
|
rpccalls::connect_to_monero_daemon()
|
|
|
|
|
{
|
|
|
|
|
//std::lock_guard<std::mutex> guard(m_daemon_rpc_mutex);
|
|
|
|
|
|
|
|
|
@ -48,9 +48,9 @@ rpccalls::get_current_height()
|
|
|
|
|
|
|
|
|
|
std::lock_guard<std::mutex> guard(m_daemon_rpc_mutex);
|
|
|
|
|
|
|
|
|
|
if (!connect_to_monero_deamon())
|
|
|
|
|
if (!connect_to_monero_daemon())
|
|
|
|
|
{
|
|
|
|
|
cerr << "get_current_height: not connected to deamon" << endl;
|
|
|
|
|
cerr << "get_current_height: not connected to daemon" << endl;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -60,8 +60,8 @@ rpccalls::get_current_height()
|
|
|
|
|
|
|
|
|
|
if (!r)
|
|
|
|
|
{
|
|
|
|
|
cerr << "Error connecting to Monero deamon at "
|
|
|
|
|
<< deamon_url << endl;
|
|
|
|
|
cerr << "Error connecting to Monero daemon at "
|
|
|
|
|
<< daemon_url << endl;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -80,9 +80,9 @@ rpccalls::get_mempool(vector<tx_info>& mempool_txs)
|
|
|
|
|
{
|
|
|
|
|
std::lock_guard<std::mutex> guard(m_daemon_rpc_mutex);
|
|
|
|
|
|
|
|
|
|
if (!connect_to_monero_deamon())
|
|
|
|
|
if (!connect_to_monero_daemon())
|
|
|
|
|
{
|
|
|
|
|
cerr << "get_mempool: not connected to deamon" << endl;
|
|
|
|
|
cerr << "get_mempool: not connected to daemon" << endl;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -93,8 +93,8 @@ rpccalls::get_mempool(vector<tx_info>& mempool_txs)
|
|
|
|
|
|
|
|
|
|
if (!r || res.status != CORE_RPC_STATUS_OK)
|
|
|
|
|
{
|
|
|
|
|
cerr << "Error connecting to Monero deamon at "
|
|
|
|
|
<< deamon_url << endl;
|
|
|
|
|
cerr << "Error connecting to Monero daemon at "
|
|
|
|
|
<< daemon_url << endl;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -127,9 +127,9 @@ rpccalls::commit_tx(tools::wallet2::pending_tx& ptx, string& error_msg)
|
|
|
|
|
|
|
|
|
|
std::lock_guard<std::mutex> guard(m_daemon_rpc_mutex);
|
|
|
|
|
|
|
|
|
|
if (!connect_to_monero_deamon())
|
|
|
|
|
if (!connect_to_monero_daemon())
|
|
|
|
|
{
|
|
|
|
|
cerr << "commit_tx: not connected to deamon" << endl;
|
|
|
|
|
cerr << "commit_tx: not connected to daemon" << endl;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -166,9 +166,9 @@ rpccalls::get_network_info(COMMAND_RPC_GET_INFO::response& response)
|
|
|
|
|
{
|
|
|
|
|
std::lock_guard<std::mutex> guard(m_daemon_rpc_mutex);
|
|
|
|
|
|
|
|
|
|
if (!connect_to_monero_deamon())
|
|
|
|
|
if (!connect_to_monero_daemon())
|
|
|
|
|
{
|
|
|
|
|
cerr << "get_network_info: not connected to deamon" << endl;
|
|
|
|
|
cerr << "get_network_info: not connected to daemon" << endl;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -192,15 +192,15 @@ rpccalls::get_network_info(COMMAND_RPC_GET_INFO::response& response)
|
|
|
|
|
|
|
|
|
|
if (!err.empty())
|
|
|
|
|
{
|
|
|
|
|
cerr << "Error connecting to Monero deamon due to "
|
|
|
|
|
cerr << "Error connecting to Monero daemon due to "
|
|
|
|
|
<< err << endl;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
cerr << "Error connecting to Monero deamon at "
|
|
|
|
|
<< deamon_url << endl;
|
|
|
|
|
cerr << "Error connecting to Monero daemon at "
|
|
|
|
|
<< daemon_url << endl;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -226,9 +226,9 @@ rpccalls::get_hardfork_info(COMMAND_RPC_HARD_FORK_INFO::response& response)
|
|
|
|
|
{
|
|
|
|
|
std::lock_guard<std::mutex> guard(m_daemon_rpc_mutex);
|
|
|
|
|
|
|
|
|
|
if (!connect_to_monero_deamon())
|
|
|
|
|
if (!connect_to_monero_daemon())
|
|
|
|
|
{
|
|
|
|
|
cerr << "get_hardfork_info: not connected to deamon" << endl;
|
|
|
|
|
cerr << "get_hardfork_info: not connected to daemon" << endl;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -253,15 +253,15 @@ rpccalls::get_hardfork_info(COMMAND_RPC_HARD_FORK_INFO::response& response)
|
|
|
|
|
|
|
|
|
|
if (!err.empty())
|
|
|
|
|
{
|
|
|
|
|
cerr << "Error connecting to Monero deamon due to "
|
|
|
|
|
cerr << "Error connecting to Monero daemon due to "
|
|
|
|
|
<< err << endl;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
cerr << "Error connecting to Monero deamon at "
|
|
|
|
|
<< deamon_url << endl;
|
|
|
|
|
cerr << "Error connecting to Monero daemon at "
|
|
|
|
|
<< daemon_url << endl;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -294,9 +294,9 @@ rpccalls::get_dynamic_per_kb_fee_estimate(
|
|
|
|
|
{
|
|
|
|
|
std::lock_guard<std::mutex> guard(m_daemon_rpc_mutex);
|
|
|
|
|
|
|
|
|
|
if (!connect_to_monero_deamon())
|
|
|
|
|
if (!connect_to_monero_daemon())
|
|
|
|
|
{
|
|
|
|
|
cerr << "get_dynamic_per_kb_fee_estimate: not connected to deamon" << endl;
|
|
|
|
|
cerr << "get_dynamic_per_kb_fee_estimate: not connected to daemon" << endl;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -321,15 +321,15 @@ rpccalls::get_dynamic_per_kb_fee_estimate(
|
|
|
|
|
|
|
|
|
|
if (!err.empty())
|
|
|
|
|
{
|
|
|
|
|
cerr << "Error connecting to Monero deamon due to "
|
|
|
|
|
cerr << "Error connecting to Monero daemon due to "
|
|
|
|
|
<< err << endl;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
cerr << "Error connecting to Monero deamon at "
|
|
|
|
|
<< deamon_url << endl;
|
|
|
|
|
cerr << "Error connecting to Monero daemon at "
|
|
|
|
|
<< daemon_url << endl;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -357,9 +357,9 @@ rpccalls::get_block(string const& blk_hash, block& blk, string& error_msg)
|
|
|
|
|
{
|
|
|
|
|
std::lock_guard<std::mutex> guard(m_daemon_rpc_mutex);
|
|
|
|
|
|
|
|
|
|
if (!connect_to_monero_deamon())
|
|
|
|
|
if (!connect_to_monero_daemon())
|
|
|
|
|
{
|
|
|
|
|
cerr << "get_block: not connected to deamon" << endl;
|
|
|
|
|
cerr << "get_block: not connected to daemon" << endl;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -384,15 +384,15 @@ rpccalls::get_block(string const& blk_hash, block& blk, string& error_msg)
|
|
|
|
|
|
|
|
|
|
if (!err.empty())
|
|
|
|
|
{
|
|
|
|
|
cerr << "Error connecting to Monero deamon due to "
|
|
|
|
|
cerr << "Error connecting to Monero daemon due to "
|
|
|
|
|
<< err << endl;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
cerr << "get_block: error connecting to Monero deamon at "
|
|
|
|
|
<< deamon_url << endl;
|
|
|
|
|
cerr << "get_block: error connecting to Monero daemon at "
|
|
|
|
|
<< daemon_url << endl;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|