Repository navigation
Expand file tree
/
Copy pathmonero_rpc_connection.pyi
More file actions
208 lines (164 loc) · 6.55 KB
/
Copy pathmonero_rpc_connection.pyi
File metadata and controls
208 lines (164 loc) · 6.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
import typing
from .serializable_struct import SerializableStruct
class MoneroRpcConnection(SerializableStruct):
"""Models a connection to a daemon."""
priority: int
"""Connection priority."""
proxy_uri: str | None
"""Connection proxy address."""
zmq_uri: str | None
"""ZMQ connection uri."""
timeout_ms: int
"""Connection timeout (milliseconds)."""
ssl_verify: bool
"""Verify the TLS certificate and the hostname of https connections (default true)."""
uri: str | None
"""Connection uri."""
@property
def username(self) -> str | None:
"""Connection authentication username."""
...
@property
def password(self) -> str | None:
"""Connection authentication password."""
...
@property
def response_time(self) -> int | None:
"""Connection response time in milliseconds."""
...
@staticmethod
def compare(p1: int, p2: int) -> bool:
"""
Compare connection priorities.
:param int p1: first priority to check.
:param int p2: second priority to check.
:returns bool: `True` if `p1` comes before `p2`, `False` otherwise.
"""
...
@staticmethod
def deserialize(json: str) -> MoneroRpcConnection:
"""
Deserialize a MoneroRpcConnection from a JSON string.
:param str json: MoneroRpcConnection in JSON format.
:returns MoneroRpcConnection: deserialized instance.
"""
...
@typing.overload
def __init__(
self,
uri: str = '',
username: str = '',
password: str = '',
proxy_uri: str = '',
zmq_uri: str = '',
priority: int = 0,
timeout_ms: int | None = None,
) -> None:
"""
Initialize a RPC connection.
:param str uri: URI string.
:param str username: username used for authentication.
:param str password: password used for authentication.
:param str proxy_uri: proxy uri.
:param str zmq_uri: ZMQ uri.
:param int priority: priorioty of the connection.
:param int|None timeout_ms: connection timeout in milliseconds.
"""
...
@typing.overload
def __init__(self, rpc: MoneroRpcConnection) -> None:
"""
Initialize a RPC connection from other connection.
:param MoneroRpcConnection rpc: RPC connection to copy.
"""
...
def check_connection(self, timeout_ms: int | None = None) -> bool:
"""
Check the connection and update online, authentication, and response time status.
:param int|None timeout_ms: the maximum response time before considered offline.
:returns bool: `True` if there is a change in status, `False` otherwise.
"""
...
def get_attribute(self, key: str) -> str:
"""
Returns RPC connection attribute.
:param str key: attribute key.
:returns str: attribute value.
"""
...
def is_authenticated(self) -> bool | None:
"""
Indicates if the connection is authenticated according to the last call to `check_connection()`.
Note: must call `check_connection()` manually.
:returns bool | None: `True` if authenticated or no authentication required, `False` if not
authenticated, or `None` if `check_connection()` has not been called.
"""
...
def is_connected(self) -> bool | None:
"""
Indicates if the connection is connected according to the last call to `check_connection()`.
Note: must call `check_connection()` manually.
:returns bool | None: `True` or `False` to indicate if connected, or `None` if `check_connection()` has not been called.
"""
...
def is_i2p(self) -> bool:
"""
Indicates if the connection is a I2P connection.
:returns bool: `True` if connection is a I2P connection, `False` otherwise.
"""
...
def is_onion(self) -> bool:
"""
Indicates if the connection is a TOR connection.
:returns bool: `True` if connection is a TOR connection, `False` otherwise.
"""
...
def is_online(self) -> bool | None:
"""
Indicates if the connection is online according to the last call to `check_connection()`.
Note: must call `check_connection()` manually.
:returns bool | None: `True` or `False` to indicate if online, or `None` if `check_connection()` has not been called.
"""
...
def send_json_request(self, method: str, parameters: object | None = None, timeout_ms: int | None = None) -> object | None:
"""
Send a request to the JSON-RPC API.
:param str method: is the method to request.
:param Optional[object] parameters: are the request's input parameters (default `None`).
:param Optional[int] timeout_ms: request timeout in milliseconds.
:returns object | None: the RPC API response as a map.
"""
...
def send_path_request(self, method: str, parameters: object | None = None, timeout_ms: int | None = None) -> object | None:
"""
Send a RPC request to the given path and with the given paramters.
E.g. `/get_transactions` with params.
:param str method: is the url path of the request to invoke.
:param Optional[object] parameters: are request parameters sent in the body.
:param Optional[int] timeout_ms: request timeout in milliseconds.
:returns object | None: the request's deserialized response.
"""
...
def send_binary_request(self, method: str, parameters: object | None = None, timeout_ms: int | None = None) -> bytes | None:
"""
Send a binary RPC request.
:param str method: is the path of the binary RPC method to invoke.
:param Optional[object] parameters: are the request parameters (default `None`).
:param Optional[int] timeout_ms: request timeout in milliseconds.
:returns bytes | None: the request's deserialized binary response.
"""
...
def set_attribute(self, key: str, value: str) -> None:
"""
Set RPC connection attribute.
:param str key: key attribute.
:param str value: value attribute.
"""
...
def set_credentials(self, username: str, password: str) -> None:
"""
Set RPC connection credentials.
:param str username: username used for RPC authentication.
:param str password: passowrd user for RPC authentication.
"""
...