Class MoneroRpcConnection

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

Hierarchy

  • MoneroRpcConnection

Constructors

  • 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

    • uriOrConnection: string | Partial<MoneroRpcConnection>

      MoneroRpcConnection or URI of the RPC endpoint

    • Optional username: string

      username to authenticate with the RPC endpoint (optional)

    • Optional password: string

      password to authenticate with the RPC endpoint (optional)

    Returns MoneroRpcConnection

Properties

attributes: any
checkConnectionMutex: ThreadPool
fakeDisconnected: boolean
isAuthenticated: boolean
isOnline: boolean
password: string
priority: number
proxyToWorker: boolean
proxyUri: string
rejectUnauthorized: boolean
responseTime: number
sendRequestMutex: ThreadPool
timeoutMs: number
uri: string
username: string
zmqUri: string

Methods

  • Check the connection status to update isOnline, isAuthenticated, and response time.

    Parameters

    • timeoutMs: any

      maximum response time before considered offline

    Returns Promise<boolean>

    true if there is a change in status, false otherwise

  • Parameters

    • key: any

    Returns any

  • Returns {
        password: string;
        priority: number;
        proxyToWorker: boolean;
        proxyUri: string;
        rejectUnauthorized: boolean;
        timeoutMs: number;
        uri: string;
        username: string;
        zmqUri: string;
    }

    • password: string
    • priority: number
    • proxyToWorker: boolean
    • proxyUri: string
    • rejectUnauthorized: boolean
    • timeoutMs: number
    • uri: string
    • username: string
    • zmqUri: string
  • Indicates if the connection is authenticated according to the last call to checkConnection().

    Returns boolean

    true if authenticated or no authentication, false if not authenticated, or undefined if checkConnection() has not been called

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

    Returns boolean

    true or false to indicate if online, or undefined if checkConnection() has not been called

  • Returns string

  • Returns number

  • Returns boolean

  • Returns string

  • Returns boolean

  • Get the response time, which is set automatically by calling checkConnection().

    Returns number

    the response time of this connection in milliseconds

  • Returns number

  • Returns string

  • Returns string

  • Returns string

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

    Returns boolean

    true or false to indicate if connected, or undefined if checkConnection() has not been called

  • Type Parameters

    • T

    Parameters

    • asyncFn: (() => Promise<T>)
        • (): Promise<T>
        • Returns Promise<T>

    Returns Promise<T>

  • Type Parameters

    • T

    Parameters

    • asyncFn: (() => Promise<T>)
        • (): Promise<T>
        • Returns Promise<T>

    Returns Promise<T>

  • Send a binary RPC request.

    Parameters

    • path: any

      path of the binary RPC method to invoke

    • Optional params: any

      request parameters

    • Optional timeoutMs: any

      request timeout in milliseconds

    Returns Promise<any>

    the binary response

  • Send a JSON RPC request.

    Parameters

    • method: any

      JSON RPC method to invoke

    • Optional params: any

      request parameters

    • Optional timeoutMs: any

      overrides the request timeout in milliseconds

    Returns Promise<any>

    is the response map

  • Send a RPC request to the given path and with the given paramters.

    E.g. "/get_transactions" with params

    Parameters

    • path: any

      JSON RPC path to invoke

    • Optional params: any

      request parameters

    • Optional timeoutMs: any

      overrides the request timeout in milliseconds

    Returns Promise<any>

    is the response map

  • Set the connection's authenticated status.

    Parameters

    • isAuthenticated: any

      sets if the connection is authenticated

    Returns MoneroRpcConnection

    this connection

  • Parameters

    • fakeDisconnected: any

    Returns void

  • 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

    • Optional priority: any

      the connection priority (default 0)

    Returns MoneroRpcConnection

    this connection

  • Set the connection's response time.

    Parameters

    • responseTimeMs: any

      response time in milliseconds

    Returns MoneroRpcConnection

    this connection

  • Set the RPC request timeout in milliseconds.

    Parameters

    • timeoutMs: number

      is the timeout in milliseconds, 0 to disable timeout, or undefined to use default

    Returns MoneroRpcConnection

    this connection

  • Returns string

  • Parameters

    • resp: any
    • method: any
    • params: any

    Returns void

  • Parameters

    • resp: any

    Returns void

Generated using TypeDoc