Skip to main content

Class: WsEndpoint_InNode

WebSocket connection to Chronik.

Constructors

constructor

new WsEndpoint_InNode(proxyInterface, config): WsEndpoint_InNode

Parameters

NameType
proxyInterfaceFailoverProxy
configWsConfig_InNode

Returns

WsEndpoint_InNode

Defined in

src/ChronikClientNode.ts:387

Properties

autoReconnect

autoReconnect: boolean

Whether to automatically reconnect on disconnect, default true.

Defined in

src/ChronikClientNode.ts:380


connected

connected: undefined | Promise<Event>

Defined in

src/ChronikClientNode.ts:383


manuallyClosed

manuallyClosed: boolean

Defined in

src/ChronikClientNode.ts:384


onConnect

Optional onConnect: (e: Event) => void

Fired when a connection has been (re)established.

Type declaration

▸ (e): void

Parameters
NameType
eEvent
Returns

void

Defined in

src/ChronikClientNode.ts:362


onEnd

Optional onEnd: (e: Event) => void

Fired after a connection has been manually closed, or if autoReconnect is false, if the WebSocket disconnects for any reason.

Type declaration

▸ (e): void

Parameters
NameType
eEvent
Returns

void

Defined in

src/ChronikClientNode.ts:377


onError

Optional onError: (e: ErrorEvent) => void

Fired when an error with the WebSocket occurs.

Type declaration

▸ (e): void

Parameters
NameType
eErrorEvent
Returns

void

Defined in

src/ChronikClientNode.ts:371


onMessage

Optional onMessage: (msg: WsMsgClient) => void

Fired when a message is sent from the WebSocket.

Type declaration

▸ (msg): void

Parameters
NameType
msgWsMsgClient
Returns

void

Defined in

src/ChronikClientNode.ts:359


onReconnect

Optional onReconnect: (e: Event) => void

Fired after a connection has been unexpectedly closed, and before a reconnection attempt is made. Only fired if autoReconnect is true.

Type declaration

▸ (e): void

Parameters
NameType
eEvent
Returns

void

Defined in

src/ChronikClientNode.ts:368


subs

subs: WsSubscriptions

Defined in

src/ChronikClientNode.ts:385


ws

ws: undefined | WebSocket

Defined in

src/ChronikClientNode.ts:382

Methods

close

close(): void

Close the WebSocket connection and prevent any future reconnection attempts.

Returns

void

Defined in

src/ChronikClientNode.ts:502


handleMsg

handleMsg(wsMsg): Promise<void>

Parameters

NameType
wsMsgMessageEvent

Returns

Promise<void>

Defined in

src/ChronikClientNode.ts:537


subscribeToAddress

subscribeToAddress(address): void

Subscribe to an address Method can be used for p2pkh or p2sh addresses

Parameters

NameType
addressstring

Returns

void

Defined in

src/ChronikClientNode.ts:481


subscribeToBlocks

subscribeToBlocks(): void

Subscribe to block messages

Returns

void

Defined in

src/ChronikClientNode.ts:408


subscribeToScript

subscribeToScript(type, payload): void

Subscribe to the given script type and payload. For "p2pkh", scriptPayload is the 20 byte public key hash.

Parameters

NameType
typeScriptType_InNode
payloadstring

Returns

void

Defined in

src/ChronikClientNode.ts:429


unsubscribeFromAddress

unsubscribeFromAddress(address): void

Unsubscribe from the given address

Parameters

NameType
addressstring

Returns

void

Defined in

src/ChronikClientNode.ts:490


unsubscribeFromBlocks

unsubscribeFromBlocks(): void

Unsubscribe from block messages

Returns

void

Defined in

src/ChronikClientNode.ts:418


unsubscribeFromScript

unsubscribeFromScript(type, payload): void

Unsubscribe from the given script type and payload.

Parameters

NameType
typeScriptType_InNode
payloadstring

Returns

void

Defined in

src/ChronikClientNode.ts:452


waitForOpen

waitForOpen(): Promise<void>

Wait for the WebSocket to be connected.

Returns

Promise<void>

Defined in

src/ChronikClientNode.ts:400