RPC Connection¶
MoneroRpcConnection ¶
Bases: SerializableStruct
Models a connection to a daemon.
password: str | None property ¶
Connection authentication password.
priority: int instance-attribute ¶
Connection priority.
proxy_uri: str | None instance-attribute ¶
Connection proxy address.
response_time: int | None property ¶
Connection response time in milliseconds.
timeout: int instance-attribute ¶
Connection timeout (milliseconds).
uri: str | None instance-attribute ¶
Connection uri.
username: str | None property ¶
Connection authentication username.
zmq_uri: str | None instance-attribute ¶
ZMQ connection uri.
before(c1, c2, current_connection) staticmethod ¶
Compare RPC connections.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
c1 | MoneroRpcConnection | connection. | required |
c2 | MoneroRpcConnection | other connection. | required |
current_connection | MoneroRpcConnection | current connection. | required |
Returns:
| Type | Description |
|---|---|
bool |
|
check_connection(timeout_ms=20000) ¶
Check the connection and update online, authentication, and response time status.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timeout_ms | int | the maximum response time before considered offline. | 20000 |
Returns:
| Type | Description |
|---|---|
bool |
|
get_attribute(key) ¶
Returns RPC connection attribute.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key | str | attribute key. | required |
Returns:
| Type | Description |
|---|---|
str | attribute value. |
is_authenticated() ¶
Indicates if the connection is authenticated according to the last call to check_connection().
Note: must call check_connection() manually.
Returns:
| Type | Description |
|---|---|
bool | None |
|
is_connected() ¶
Indicates if the connection is connected according to the last call to check_connection().
Note: must call check_connection() manually.
Returns:
| Type | Description |
|---|---|
bool | None |
|
is_i2p() ¶
Indicates if the connection is a I2P connection.
Returns:
| Type | Description |
|---|---|
bool |
|
is_onion() ¶
Indicates if the connection is a TOR connection.
Returns:
| Type | Description |
|---|---|
bool |
|
is_online() ¶
Indicates if the connection is online according to the last call to check_connection().
Note: must call check_connection() manually.
Returns:
| Type | Description |
|---|---|
bool | None |
|
send_binary_request(method, parameters=None) ¶
Send a binary RPC request.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
method | str | is the path of the binary RPC method to invoke. | required |
parameters | Optional[object] | are the request parameters (default | None |
Returns:
| Type | Description |
|---|---|
str | None | the request's deserialized binary response. |
send_json_request(method, parameters=None) ¶
Send a request to the JSON-RPC API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
method | str | is the method to request. | required |
parameters | Optional[object] | are the request's input parameters (default | None |
Returns:
| Type | Description |
|---|---|
object | None | the RPC API response as a map. |
send_path_request(method, parameters=None) ¶
Send a RPC request to the given path and with the given paramters.
E.g. /get_transactions with params.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
method | str | is the url path of the request to invoke. | required |
parameters | Optional[object] | are request parameters sent in the body. | None |
Returns:
| Type | Description |
|---|---|
object | None | the request's deserialized response. |
set_attribute(key, value) ¶
Set RPC connection attribute.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key | str | key attribute. | required |
value | str | value attribute. | required |
set_credentials(username, password) ¶
Set RPC connection credentials.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
username | str | username used for RPC authentication. | required |
password | str | passowrd user for RPC authentication. | required |