#include <monero_rpc_connection.h>
|
| | monero_rpc_connection (const std::string &uri="", const std::string &username="", const std::string &password="", const std::string &proxy_uri="", const std::string &zmq_uri="", int priority=0, const boost::optional< uint32_t > &timeout_ms=boost::none) |
| |
| | monero_rpc_connection (const monero_rpc_connection &rpc) |
| |
| bool | is_onion () const |
| |
| bool | is_i2p () const |
| |
| void | set_credentials (const std::string &username, const std::string &password) |
| |
| void | set_attribute (const std::string &key, const std::string &val) |
| |
| std::string | get_attribute (const std::string &key) const |
| |
| boost::optional< bool > | is_online () const |
| |
| boost::optional< bool > | is_authenticated () const |
| |
| boost::optional< bool > | is_connected () const |
| |
| bool | check_connection (const boost::optional< uint32_t > &timeout_ms=boost::none) |
| |
| boost::property_tree::ptree | send_json_request (const std::string &path, const std::shared_ptr< serializable_struct > ¶ms=nullptr, const boost::optional< uint32_t > &timeout_ms=boost::none) const |
| |
| monero_rpc_response | send_json_request (const monero_rpc_request &request, const boost::optional< uint32_t > &timeout_ms=boost::none) const |
| |
| boost::property_tree::ptree | send_path_request (const std::string &path, const std::shared_ptr< serializable_struct > ¶ms=nullptr, const boost::optional< uint32_t > &timeout_ms=boost::none) const |
| |
| monero_rpc_response | send_path_request (const monero_rpc_request &request, const boost::optional< uint32_t > &timeout_ms=boost::none) const |
| |
| monero_rpc_response | send_binary_request (const monero_rpc_request &request, const boost::optional< uint32_t > &timeout_ms=boost::none) const |
| |
| rapidjson::Value | to_rapidjson_val (rapidjson::Document::AllocatorType &allocator) const override |
| |
| std::string | serialize () const |
| |
|
|
static std::shared_ptr< monero_rpc_connection > | from_property_tree (const boost::property_tree::ptree &node) |
| |
| static bool | compare (int p1, int p2) |
| |
|
|
boost::optional< std::string > | m_uri |
| |
|
boost::optional< std::string > | m_username |
| |
|
boost::optional< std::string > | m_password |
| |
|
boost::optional< std::string > | m_proxy_uri |
| |
|
boost::optional< std::string > | m_zmq_uri |
| |
|
boost::optional< uint32_t > | m_timeout_ms |
| |
|
boost::optional< uint64_t > | m_response_time |
| |
|
int | m_priority |
| |
|
|
void | ensure_configured () const |
| |
|
std::string | invoke_post (const boost::string_ref uri, const std::string &body, const boost::optional< uint32_t > &timeout_ms=boost::none) const |
| |
|
void | send_rpc_request (const boost::string_ref uri, const monero_rpc_request &request, monero_rpc_response &response, const boost::optional< uint32_t > &timeout_ms=boost::none, bool binary=false) const |
| |
|
|
boost::recursive_mutex | m_mutex |
| |
|
boost::optional< bool > | m_is_online |
| |
|
boost::optional< bool > | m_is_authenticated |
| |
|
std::unique_ptr< epee::net_utils::http::abstract_http_client > | m_http_client |
| |
|
std::unordered_map< std::string, std::string > | m_attributes |
| |
|
std::tuple< std::string, std::string, std::string, std::string > | m_applied |
| |
Maintains a connection and sends requests to a Monero RPC API.
◆ monero_rpc_connection() [1/2]
| monero::monero_rpc_connection::monero_rpc_connection |
( |
const std::string & | uri = "", |
|
|
const std::string & | username = "", |
|
|
const std::string & | password = "", |
|
|
const std::string & | proxy_uri = "", |
|
|
const std::string & | zmq_uri = "", |
|
|
int | priority = 0, |
|
|
const boost::optional< uint32_t > & | timeout_ms = boost::none ) |
Initialize a new RPC connection.
- Parameters
-
| uri | RPC connection uri |
| username | RPC connection authentication username |
| password | RPC connection authentication password |
| proxy_uri | RPC connection proxy uri |
| zmq_uri | RPC connection zmq uri |
| priority | RPC connection priority |
| timeout_ms | RPC connection timeout in milliseconds |
◆ monero_rpc_connection() [2/2]
Copy a RPC connection.
- Parameters
-
| rpc | RPC connection to copy |
◆ check_connection()
| bool monero::monero_rpc_connection::check_connection |
( |
const boost::optional< uint32_t > & | timeout_ms = boost::none | ) |
|
Check the connection and update online, authentication, and response time status.
- Parameters
-
| timeout_ms | the maximum response time before considered offline |
- Returns
◆ compare()
| bool monero::monero_rpc_connection::compare |
( |
int | p1, |
|
|
int | p2 ) |
|
static |
Checks RPC connection priority order.
- Parameters
-
| c1 | first priority to compare |
| c2 | second priority to compare |
◆ get_attribute()
| std::string monero::monero_rpc_connection::get_attribute |
( |
const std::string & | key | ) |
const |
Get connection attribute.
- Parameters
-
| key | is the attribute to get the value of |
- Returns
- key's value if set
◆ is_authenticated()
| boost::optional< bool > monero::monero_rpc_connection::is_authenticated |
( |
| ) |
const |
Indicates if the connection is authenticated, which is set automatically by calling check_connection().
- Returns
- true if authenticated or no authentication, false if not authenticated, or null if not set
◆ is_connected()
| boost::optional< bool > monero::monero_rpc_connection::is_connected |
( |
| ) |
const |
Indicates if the connection is connected, which is set automatically by calling check_connection().
- Returns
- true or false to indicate if connected, or null if check_connection() has not been called
◆ is_i2p()
| bool monero::monero_rpc_connection::is_i2p |
( |
| ) |
const |
Indicates if the connection uri is a I2P server.
- Returns
- true or false to indicate if connection uri is a I2P server
◆ is_onion()
| bool monero::monero_rpc_connection::is_onion |
( |
| ) |
const |
Indicates if the connection uri is a TOR server.
- Returns
- true or false to indicate if connection uri is a TOR server
◆ is_online()
| boost::optional< bool > monero::monero_rpc_connection::is_online |
( |
| ) |
const |
Indicates if the connection is online, which is set automatically by calling check_connection().
- Returns
- true or false to indicate if online, or null if check_connection() has not been called
◆ send_binary_request()
Send a binary RPC request.
- Parameters
-
| request | specifies the method to request with paramesters |
| timeout | request timeout in milliseconds |
- Returns
- the request's deserialized response
◆ send_json_request() [1/2]
Send a request to the RPC API.
- Parameters
-
| request | specifies the method to request with parameters |
| timeout | request timeout in milliseconds |
- Returns
- the RPC API response as a map
◆ send_json_request() [2/2]
| boost::property_tree::ptree monero::monero_rpc_connection::send_json_request |
( |
const std::string & | path, |
|
|
const std::shared_ptr< serializable_struct > & | params = nullptr, |
|
|
const boost::optional< uint32_t > & | timeout_ms = boost::none ) const |
Send a request to the RPC API.
- Parameters
-
| path | specifies the method to request |
| params | are the request's input parameters |
- Returns
- the RPC API response as a map
◆ send_path_request() [1/2]
Send a RPC request to the given path and with the given paramters.
- Parameters
-
| request | specifies the method to request with parameters |
| timeout | request timeout in milliseconds |
- Returns
- the request's deserialized response
◆ send_path_request() [2/2]
| boost::property_tree::ptree monero::monero_rpc_connection::send_path_request |
( |
const std::string & | path, |
|
|
const std::shared_ptr< serializable_struct > & | params = nullptr, |
|
|
const boost::optional< uint32_t > & | timeout_ms = boost::none ) const |
Send a RPC request to the given path and with the given paramters.
E.g. "/get_transactions" with params
- Parameters
-
| path | is the url path of the request to invoke |
| params | are request parameters sent in the body |
- Returns
- the RPC API response as a map
◆ set_attribute()
| void monero::monero_rpc_connection::set_attribute |
( |
const std::string & | key, |
|
|
const std::string & | val ) |
Set connection attribute.
- Parameters
-
| key | is the attribute key |
| val | is the attribute value |
◆ set_credentials()
| void monero::monero_rpc_connection::set_credentials |
( |
const std::string & | username, |
|
|
const std::string & | password ) |
Set connection credentials.
- Parameters
-
| username | username to use in RPC authentication |
| password | password to use in RPC authentication |
◆ to_rapidjson_val()
| rapidjson::Value monero::monero_rpc_connection::to_rapidjson_val |
( |
rapidjson::Document::AllocatorType & | allocator | ) |
const |
|
overridevirtual |
Converts the struct to a rapidjson Value.
- Parameters
-
| allocator | is the rapidjson document allocator |
- Returns
- the struct as a rapidjson Value
Implements monero::serializable_struct.
The documentation for this class was generated from the following files: