Class: MoneroRpcConnection

MoneroRpcConnection(uriOrConfigOrConnection, username, password, rejectUnauthorized)

Maintains a connection and sends requests to a Monero RPC API.

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
Name Type Description
uri string URI of the RPC endpoint
username string username to authenticate with the RPC endpoint (optional)
password string password to authenticate with the RPC endpoint (optional)
rejectUnauthorized boolean rejects self-signed certificates if true (default true)
proxyToWorker boolean proxy requests to worker
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)
Source:

Members

(static) DEFAULT_CONFIG

Default RPC configuration.
Source:

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
Source:
Returns:
true if there is a change in status, false otherwise
Type
Promise.<boolean>

getAttribute()

Source:

getConfig()

Source:

getPassword()

Source:

getPriority()

Source:

getProxyToWorker()

Source:

getRejectUnauthorized()

Source:

getResponseTime()

Source:

getUri()

Source:

getUsername()

Source:

isAuthenticated() → {boolean|undefined}

Indicates if the connection is authenticated according to the last call to checkConnection().

Note: must call checkConnection() manually unless using MoneroConnectionManager.
Source:
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.
Source:
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.
Source:
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
Source:
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
Source:
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
Source:
Returns:
is the response map
Type
object

setAttribute()

Source:

setCredentials()

Source:

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)
Source:
Returns:
this connection
Type
MoneroRpcConnection

setProxyToWorker()

Source:

toString()

Source: