qbit-rpc
    Preparing search index...

    Interface QbitRpcClientOptions

    The options of a QbitRpcClient, checked at construction: a bad one is a TypeError or a RangeError.

    interface QbitRpcClientOptions {
        allowUnsupportedNodeVersion?: boolean;
        auth: RpcAuth;
        capabilities?: readonly Capability[];
        chainCheckMaxAgeMs?: number;
        connect?: RpcConnect;
        directNode?: boolean;
        expectedChain: QbitChain;
        expectedGenesisHash?: string;
        expectedSignetChallenge?: string;
        extraMethods?: Readonly<Record<string, ExtraMethodPolicy>>;
        maxConcurrentRequests?: number;
        maxResponseBytes?: number;
        readRetries?: number;
        retryDelayMs?: number;
        timeoutMs?: number;
        tls?: RpcTlsOptions;
        url: string;
        wallet?: string;
    }
    Index
    allowUnsupportedNodeVersion?: boolean

    Let wallet-write, broadcast, mining and wallet-admin calls go to a node of a qbit Core version this package does not support. Every chain check also reads the node's version (getnetworkinfo); by default one outside qbit Core 1.0.x releases refuses them, as another chain does, with RpcChainGuardError (reason: 'unsupported_version') until confirmChain() finds a supported one. Set it to accept the risk: such a node may read an argument differently, or answer in a shape this package does not validate. nodeVersion still shows the version, and a version that does not parse still fails the check. Default false.

    auth: RpcAuth

    The node's credentials: a user name and password, or qbitd's cookie file. See RpcAuth.

    capabilities?: readonly Capability[]

    Capabilities beyond chain reads. Default none: read-only.

    chainCheckMaxAgeMs?: number

    How long a chain confirmation stays fresh. A wallet-write, broadcast, mining or wallet-admin call made later first re-runs the chain check, under the call's own deadline; if that check fails, the call is not sent and rejects with RpcChainGuardError (reason: 'check_failed', the failure as cause). A connection error, an HTTP 401 or a changed cookie (a qbitd restart) makes the confirmation stale at once. 0 re-checks before every such call. Default 10,000 ms.

    connect?: RpcConnect

    Opens the stream for each connection to an https url, such as a tunnel through a proxy; the client runs TLS over it, with every check. Not with cookie authentication. Default: connect to the URL's host directly.

    directNode?: boolean

    Set when url reaches qbitd itself, with no proxy in between. qbitd's HTTP 503 Work queue depth exceeded is then a definite failure, since qbitd answers it without running the request: a plain RpcTransportError, even for a side-effecting call. It is opt-in because a proxy in between can answer 503 after forwarding the request, so by default every 5xx stays an unknown outcome for side-effecting calls. Default false.

    expectedChain: QbitChain

    The chain this client must talk to. confirmChain() checks it; wallet-write, broadcast, mining and wallet-admin calls wait for that check.

    expectedGenesisHash?: string

    The genesis block hash the node must report (getblockhash 0) on every chain check: 64 hex characters, in either case (compared in lowercase). Default: expectedChain's genesis block in qbit Core v1.0.0, which the Chain guard lists. Set it for a node built with other chain parameters.

    expectedSignetChallenge?: string

    The challenge (block script) a signet node must report as signet_challenge on every chain check: non-empty hex of whole bytes, in either case (compared in lowercase). Only with expectedChain: 'signet'. Default 51, OP_TRUE, the default signet's open challenge, which anyone can mine a separate signet with.

    extraMethods?: Readonly<Record<string, ExtraMethodPolicy>>

    Methods to allow beyond the package's allowlist, for this client, untyped, through call() and requests.raw(). Each entry is the method's policy: capability, read or one in capabilities, and sideEffects, which has no default; one with side effects needs wallet-write, broadcast, mining, wallet-admin or node-admin. The client treats the method as an allowlisted one with that policy: wallet-write, broadcast, mining, wallet-admin and node-admin wait for the chain guard, and a method with side effects is never retried or batched, uses a fresh connection, and is an RpcUnknownOutcomeError when it may have run. A node-admin call needs the chain's identity only: an unsupported qbit Core version does not refuse it, and it is never batched; node administration (stop, setban, addnode, ...) is reachable only this way, under node-admin. A method qbit Core v1.0.0's help lists may not be declared below what it does: a wallet method needs a wallet capability, and one that changes state needs sideEffects: true under its kind's capability. A method help does not list keeps the policy given. An allowlisted method may be restated with its own policy, which then applies. Anything else is a TypeError: a policy below the method's, another policy for an allowlisted method, a capability the client does not enable, an option or entry that is not a plain object or is malformed, and sendmany, sendtoaddress, send, sendall and bumpfee, which sign and broadcast in one step. toJSON() lists them. Default none.

    maxConcurrentRequests?: number

    Most requests this client has open at once, on pooled and fresh connections alike, from 1 to 1,024. A batch counts once, and a chain re-check (with any pause before checking again) runs in its call's slot. Further attempts wait in FIFO order under their operation's deadline; one that times out or is aborted while waiting was never sent, so it is a plain RpcTimeoutError or RpcAbortedError, never an unknown outcome. Keep the total over all clients of a node at or below its -rpcworkqueue (see the work queue). Default 8.

    maxResponseBytes?: number

    Largest response body read before the call fails. Default 16 MiB.

    readRetries?: number

    Extra attempts for methods without side effects after a connection error (reason: 'network'; a TLS or loopback refusal would only repeat), an HTTP 5xx, a credentials failure, an HTTP 401 under cookie auth, or (single calls and the chain check) RPC error -28, node warming up. Default 0: no retries. Methods with side effects are never retried. Apart from these, even at 0, a request without side effects that is reset on a reused keep-alive connection just after it was written, before any reply byte (qbitd closed it for idleness), gets one more attempt at once, as does a chain re-check before a call with side effects; the reset still makes the chain stale.

    retryDelayMs?: number

    Delay before the first retry; it doubles for each further one, up to 10 s. Default 250 ms.

    timeoutMs?: number

    Deadline for one operation (a call or a batch, with every retry, any wait for a request slot and the cookie read). Default 30,000 ms. For walletpassphrase and walletlock it is at least 120,000 ms (see QbitRpcClient.walletPassphrase), and so for keypoolrefill, importdescriptors, rescanblockchain, loadwallet and unloadwallet (see Wallet administration): a shorter client timeoutMs does not shorten it, nor a long poll's, at least its wait plus 10 s (see QbitRpcClient.waitForNewBlock). A call's own timeoutMs overrides all of these. With connect, it also bounds a pooled connection still opening after its read gave up.

    TLS settings for an https url: a private CA, a client certificate, the name to check, and key pins. Default: the system's CAs, no client certificate, the URL's host, no pin. See Remote nodes.

    url: string

    The node's JSON-RPC endpoint, such as http://127.0.0.1:48352/ for testnet4. Plain http is only accepted for a loopback host: an address in 127.0.0.0/8 or ::1, or localhost, which every connection resolves and refuses (RpcTransportError, reason: 'not_loopback') unless all its addresses are loopback. The path may already name a wallet (/wallet/<name>); otherwise pass wallet.

    wallet?: string

    Send every call to /wallet/<name>. Required for wallet calls when the node has several wallets loaded.