Constructor
new MoneroRpcConnection(uriOrConfigOrConnection, username, password, rejectUnauthorized)
Construct a RPC connection.
Examples:
let connection1 = new MoneroRpcConnection("http://localhost:38081", "daemon_user", "daemon_password_123")
let connection2 = new MoneroRpcConnection({
uri: http://localhost:38081,
username: "daemon_user",
password: "daemon_password_123",
rejectUnauthorized: false, // accept self-signed certificates e.g. for local development
proxyToWorker: true // proxy request to worker (default false)
});
Parameters:
Name | Type | Description | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
uriOrConfigOrConnection |
string | object | MoneroRpcConnection | RPC endpoint URI, MoneroRpcConnection, or equivalent JS object
Properties
|
||||||||||||||||||
username |
string | username to authenticate with the RPC endpoint (optional) | ||||||||||||||||||
password |
string | password to authenticate with the RPC endpoint (optional) | ||||||||||||||||||
rejectUnauthorized |
boolean | reject self-signed certificates if true (default true) |
Members
(static) DEFAULT_CONFIG
Default RPC configuration.
Methods
(async) checkConnection(timeoutInMs) → {Promise.<boolean>}
Check the connection status to update isOnline, isAuthenticated, and response time.
Parameters:
Name | Type | Description |
---|---|---|
timeoutInMs |
int | maximum response time before considered offline |
Returns:
true if there is a change in status, false otherwise
- Type
- Promise.<boolean>
getAttribute()
getConfig()
getPassword()
getPriority()
getProxyToWorker()
getRejectUnauthorized()
getResponseTime()
getUri()
getUsername()
isAuthenticated() → {boolean|undefined}
Indicates if the connection is authenticated according to the last call to checkConnection().
Note: must call checkConnection() manually unless using MoneroConnectionManager.
Note: must call checkConnection() manually unless using MoneroConnectionManager.
Returns:
true if authenticated or no authentication, false if not authenticated, or undefined if checkConnection() has not been called
- Type
- boolean | undefined
isConnected() → {boolean|undefined}
Indicates if the connection is connected according to the last call to checkConnection().
Note: must call checkConnection() manually unless using MoneroConnectionManager.
Note: must call checkConnection() manually unless using MoneroConnectionManager.
Returns:
true or false to indicate if connected, or undefined if checkConnection() has not been called
- Type
- boolean | undefined
isOnline() → {boolean|undefined}
Indicates if the connection is online according to the last call to checkConnection().
Note: must call checkConnection() manually unless using MoneroConnectionManager.
Note: must call checkConnection() manually unless using MoneroConnectionManager.
Returns:
true or false to indicate if online, or undefined if checkConnection() has not been called
- Type
- boolean | undefined
(async) sendBinaryRequest(path, params, timeoutInMs) → {Uint8Array}
Send a binary RPC request.
Parameters:
Name | Type | Description |
---|---|---|
path |
string | path of the binary RPC method to invoke |
params |
object | request parameters |
timeoutInMs |
int | request timeout in milliseconds |
Returns:
the binary response
- Type
- Uint8Array
(async) sendJsonRequest(method, params, timeoutInMs) → {object}
Send a JSON RPC request.
Parameters:
Name | Type | Description |
---|---|---|
method |
string | JSON RPC method to invoke |
params |
object | request parameters |
timeoutInMs |
int | request timeout in milliseconds |
Returns:
is the response map
- Type
- object
(async) sendPathRequest(path, params, timeoutInMs) → {object}
Send a RPC request to the given path and with the given paramters.
E.g. "/get_transactions" with params
Parameters:
Name | Type | Description |
---|---|---|
path |
string | JSON RPC path to invoke |
params |
object | request parameters |
timeoutInMs |
int | request timeout in milliseconds |
Returns:
is the response map
- Type
- object
setAttribute()
setCredentials()
setPriority(priority) → {MoneroRpcConnection}
Set the connection's priority relative to other connections. Priority 1 is highest,
then priority 2, etc. The default priority of 0 is lowest priority.
Parameters:
Name | Type | Description |
---|---|---|
priority |
int | the connection priority (default 0) |
Returns:
this connection
- Type
- MoneroRpcConnection