opnet
Version:
The perfect library for building Bitcoin-based applications.
66 lines (65 loc) • 2.65 kB
TypeScript
import { Network } from '../../node_modules/@btc-vision/bitcoin/build/index.js';
import { AbstractRpcProvider } from './AbstractRpcProvider.js';
import { JsonRpcPayload } from './interfaces/JSONRpc.js';
import { JsonRpcCallResult } from './interfaces/JSONRpcResult.js';
import { BlockNotification, ConnectionState, EpochNotification, EventHandler, SubscriptionHandler, SubscriptionType, WebSocketClientConfig, WebSocketClientEvent } from './websocket/index.js';
export type { BlockNotification, EpochNotification, EventHandler, SubscriptionHandler, WebSocketClientEvent, };
export declare class WebSocketRpcProvider extends AbstractRpcProvider {
private readonly config;
private readonly pendingRequests;
private readonly subscriptions;
private readonly eventHandlers;
private socket;
private state;
private requestId;
private reconnectAttempt;
private pingTimeout;
private sessionId;
private userRequestedDisconnect;
private protoRoot;
private protoTypes;
constructor(url: string, network: Network, config?: Partial<Omit<WebSocketClientConfig, 'url'>>);
getState(): ConnectionState;
isReady(): boolean;
connect(): Promise<void>;
disconnect(): void;
on<T>(event: WebSocketClientEvent, handler: EventHandler<T>): void;
off<T>(event: WebSocketClientEvent, handler: EventHandler<T>): void;
subscribeBlocks(handler: SubscriptionHandler<BlockNotification>): Promise<void>;
subscribeEpochs(handler: SubscriptionHandler<EpochNotification>): Promise<void>;
unsubscribe(subscriptionType: SubscriptionType): Promise<void>;
clearCache(): void;
_send(payload: JsonRpcPayload | JsonRpcPayload[]): Promise<JsonRpcCallResult>;
protected providerUrl(url: string): string;
private sendJsonRpcRequest;
private translateJsonRpcParamsToFieldIds;
private convertOPNetTypeToString;
private convertTransaction;
private convertBlockResponse;
private translateProtoResponse;
private connectWebSocket;
private buildWebSocketUrl;
private performHandshake;
private buildMessageByFieldId;
private getFieldById;
private getFieldNameById;
private getNestedType;
private getType;
private nextRequestId;
private buildMessage;
private sendRequest;
private send;
private handleMessage;
private handleErrorResponse;
private handleBlockNotification;
private handleEpochNotification;
private handleClose;
private reconnect;
private resubscribe;
private cleanupPendingRequests;
private schedulePing;
private cancelPing;
private ping;
private emit;
private sleep;
}