@electrum-cash/network 3.2.0-r1 → 3.2.0-r2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,605 @@
1
+ import * as net from "net";
2
+ import { WebSocket, MessageEvent, ErrorEvent } from "@monsterbitar/isomorphic-ws";
3
+ import { EventEmitter } from "events";
4
+ import { Mutex } from "async-mutex";
5
+ type RPCParameter = string | number | boolean | null;
6
+ interface RPCBase {
7
+ jsonrpc: string;
8
+ }
9
+ interface RPCNotification extends RPCBase {
10
+ method: string;
11
+ params?: RPCParameter[];
12
+ }
13
+ interface RPCStatement extends RPCBase {
14
+ id: number | null;
15
+ result: string;
16
+ }
17
+ interface RPCError {
18
+ code: number;
19
+ message: string;
20
+ data?: any;
21
+ }
22
+ interface RPCErrorResponse extends RPCBase {
23
+ id: number | null;
24
+ error: RPCError;
25
+ }
26
+ type RPCResponse = RPCErrorResponse | RPCStatement;
27
+ /**
28
+ * Enum that denotes the ordering to use in an ElectrumCluster.
29
+ * @enum {number}
30
+ * @property {0} RANDOM Send requests to randomly selected servers in the cluster.
31
+ * @property {1} PRIORITY Send requests to servers in the cluster in the order they were added.
32
+ */
33
+ export enum ClusterOrder {
34
+ RANDOM = 0,
35
+ PRIORITY = 1
36
+ }
37
+ /**
38
+ * Enum that denotes the distribution setting to use in an ElectrumCluster.
39
+ * @enum {number}
40
+ * @property {0} ALL Send requests to all servers in the cluster.
41
+ */
42
+ export enum ClusterDistribution {
43
+ ALL = 0
44
+ }
45
+ /**
46
+ * Enum that denotes the ready status of an ElectrumCluster.
47
+ * @enum {number}
48
+ * @property {0} DISABLED The cluster is disabled and unusable.
49
+ * @property {1} DEGRADED The cluster is degraded but still usable.
50
+ * @property {2} READY The cluster is healthy and ready for use.
51
+ */
52
+ export enum ClusterStatus {
53
+ DISABLED = 0,
54
+ DEGRADED = 1,
55
+ READY = 2
56
+ }
57
+ /**
58
+ * Enum that denotes the availability of an ElectrumClient.
59
+ * @enum {number}
60
+ * @property {0} UNAVAILABLE The client is currently not available.
61
+ * @property {1} AVAILABLE The client is available for use.
62
+ */
63
+ export enum ClientState {
64
+ UNAVAILABLE = 0,
65
+ AVAILABLE = 1
66
+ }
67
+ /**
68
+ * Enum that denotes the connection status of an ElectrumConnection.
69
+ * @enum {number}
70
+ * @property {0} DISCONNECTED The connection is disconnected.
71
+ * @property {1} AVAILABLE The connection is connected.
72
+ * @property {2} DISCONNECTING The connection is disconnecting.
73
+ * @property {3} CONNECTING The connection is connecting.
74
+ * @property {4} RECONNECTING The connection is restarting.
75
+ */
76
+ export enum ConnectionStatus {
77
+ DISCONNECTED = 0,
78
+ CONNECTED = 1,
79
+ DISCONNECTING = 2,
80
+ CONNECTING = 3,
81
+ RECONNECTING = 4
82
+ }
83
+ export interface ClientConfig {
84
+ state: ClientState;
85
+ connection: ElectrumClient;
86
+ }
87
+ /**
88
+ * A list of possible responses to requests.
89
+ */
90
+ export type RequestResponse = object | string | number | boolean | null | RequestResponse[];
91
+ export type RequestResolver = (error?: Error, data?: string) => void;
92
+ export type ResolveFunction<T> = (value: T | PromiseLike<T>) => void;
93
+ export type RejectFunction = (reason?: any) => void;
94
+ export interface VersionRejected {
95
+ error: RPCError;
96
+ }
97
+ export interface VersionNegotiated {
98
+ software: string;
99
+ protocol: string;
100
+ }
101
+ export const isVersionRejected: (object: any) => object is VersionRejected;
102
+ export const isVersionNegotiated: (object: any) => object is VersionNegotiated;
103
+ /**
104
+ * Possible Transport Schemes for communication with the Electrum server
105
+ */
106
+ export type TransportScheme = 'tcp' | 'tcp_tls' | 'ws' | 'wss';
107
+ export interface ConnectionOptions {
108
+ rejectUnauthorized?: boolean;
109
+ serverName?: string;
110
+ }
111
+ /**
112
+ * Object containing the commonly used ports and schemes for specific Transports.
113
+ * @example const electrum = new ElectrumClient('Electrum client example', '1.4.1', 'bch.imaginary.cash', Transport.WSS.Port, Transport.WSS.Scheme);
114
+ *
115
+ * @property {object} TCP Port and Scheme to use unencrypted TCP sockets.
116
+ * @property {object} TCP_TLS Port and Scheme to use TLS-encrypted TCP sockets.
117
+ * @property {object} WS Port and Scheme to use unencrypted WebSockets.
118
+ * @property {object} WSS Port and Scheme to use TLS-encrypted WebSockets.
119
+ */
120
+ export const ElectrumTransport: {
121
+ TCP: {
122
+ Port: number;
123
+ Scheme: TransportScheme;
124
+ };
125
+ TCP_TLS: {
126
+ Port: number;
127
+ Scheme: TransportScheme;
128
+ };
129
+ WS: {
130
+ Port: number;
131
+ Scheme: TransportScheme;
132
+ };
133
+ WSS: {
134
+ Port: number;
135
+ Scheme: TransportScheme;
136
+ };
137
+ };
138
+ export const DefaultParameters: {
139
+ PORT: number;
140
+ TRANSPORT_SCHEME: TransportScheme;
141
+ RECONNECT: number;
142
+ TIMEOUT: number;
143
+ PING_INTERVAL: number;
144
+ CLUSTER_CONFIDENCE: number;
145
+ CLUSTER_DISTRIBUTION: ClusterDistribution;
146
+ CLUSTER_ORDER: ClusterOrder;
147
+ USE_BIG_INT: boolean;
148
+ };
149
+ /**
150
+ * Isomorphic Socket interface supporting TCP sockets and WebSockets (Node and browser).
151
+ * The interface is a subset of the TLSSocket interface with some slight modifications.
152
+ * It can be expanded when more socket functionality is needed in the rest of the
153
+ * electrum-cash code. Changes from the TLSSocket interface (besides it being a subset):
154
+ * - Event 'close' -> 'disconnect'
155
+ * - New function socket.disconnect()
156
+ *
157
+ * @ignore
158
+ */
159
+ declare class ElectrumSocket extends EventEmitter {
160
+ tcpSocket?: net.Socket;
161
+ webSocket?: WebSocket;
162
+ timers: {
163
+ retryConnection?: number;
164
+ disconnect?: number;
165
+ };
166
+ onConnectHasRun: boolean;
167
+ eventForwarders: {
168
+ disconnect: () => boolean;
169
+ tcpData: (data: string) => boolean;
170
+ wsData: (event: MessageEvent) => boolean;
171
+ tcpError: (err: Error) => boolean;
172
+ wsError: (event: ErrorEvent) => boolean;
173
+ };
174
+ /**
175
+ * Connect to host:port using the specified transport
176
+ *
177
+ * @param {string} host Fully qualified domain name or IP address of the host
178
+ * @param {number} port Network port for the host to connect to
179
+ * @param {TransportScheme} scheme Transport scheme to use
180
+ * @param {number} timeout If no connection is established after `timeout` ms, the connection is terminated
181
+ *
182
+ * @throws {Error} if an incorrect transport scheme is specified
183
+ */
184
+ connect(host: string, port: number, scheme: TransportScheme, timeout: number): void;
185
+ /**
186
+ * Sets up forwarding of events related to the connection.
187
+ *
188
+ * @param {string} connectionType Name of the connection/transport type, used for logging.
189
+ * @param {string} host Fully qualified domain name or IP address of the host
190
+ * @param {number} port Network port for the host to connect to
191
+ */
192
+ onConnect(connectionType: string, host: string, port: number): void;
193
+ /**
194
+ * Forcibly terminate the connection.
195
+ *
196
+ * @throws {Error} if no connection was found
197
+ */
198
+ disconnect(): void;
199
+ /**
200
+ * Write data to the socket
201
+ *
202
+ * @param {Uint8Array | string} data Data to be written to the socket
203
+ * @param {function} callback Callback function to be called when the write has completed
204
+ *
205
+ * @throws {Error} if no connection was found
206
+ * @returns true if the message was fully flushed to the socket, false if part of the message
207
+ * is queued in the user memory
208
+ */
209
+ write(data: Uint8Array | string, callback?: (err?: Error) => void): boolean;
210
+ /**
211
+ * Force a disconnection if no connection is established after `timeout` milliseconds.
212
+ *
213
+ * @param {string} host Host of the connection that timed out
214
+ * @param {number} port Port of the connection that timed out
215
+ * @param {number} timeout Elapsed milliseconds
216
+ */
217
+ disconnectOnTimeout(host: string, port: number, timeout: number): void;
218
+ }
219
+ /**
220
+ * Wrapper around TLS/WSS sockets that gracefully separates a network stream into Electrum protocol messages.
221
+ *
222
+ * @ignore
223
+ */
224
+ declare class ElectrumConnection extends EventEmitter {
225
+ application: string;
226
+ version: string;
227
+ host: string;
228
+ port: number;
229
+ scheme: TransportScheme;
230
+ timeout: number;
231
+ pingInterval: number;
232
+ reconnectInterval: number;
233
+ useBigInt: boolean;
234
+ socket: ElectrumSocket;
235
+ lastReceivedTimestamp: number;
236
+ timers: {
237
+ keepAlive?: number;
238
+ reconnect?: number;
239
+ };
240
+ verifications: Array<number>;
241
+ status: ConnectionStatus;
242
+ messageBuffer: string;
243
+ /**
244
+ * Sets up network configuration for an Electrum client connection.
245
+ *
246
+ * @param {string} application your application name, used to identify to the electrum host.
247
+ * @param {string} version protocol version to use with the host.
248
+ * @param {string} host fully qualified domain name or IP number of the host.
249
+ * @param {number} port the network port of the host.
250
+ * @param {TransportScheme} scheme the transport scheme to use for connection
251
+ * @param {number} timeout how long network delays we will wait for before taking action, in milliseconds.
252
+ * @param {number} pingInterval the time between sending pings to the electrum host, in milliseconds.
253
+ * @param {number} reconnectInterval the time between reconnection attempts to the electrum host, in milliseconds.
254
+ * @param {boolean} useBigInt whether to use bigint for numbers in json response.
255
+ *
256
+ * @throws {Error} if `version` is not a valid version string.
257
+ */
258
+ constructor(application: string, version: string, host: string, port?: number, scheme?: TransportScheme, timeout?: number, pingInterval?: number, reconnectInterval?: number, useBigInt?: boolean);
259
+ /**
260
+ * Returns a string for the host identifier for usage in debug messages.
261
+ */
262
+ get hostIdentifier(): string;
263
+ /**
264
+ * Create and configures a fresh socket and attaches all relevant listeners.
265
+ */
266
+ createSocket(): void;
267
+ /**
268
+ * Shuts down and destroys the current socket.
269
+ */
270
+ destroySocket(): void;
271
+ /**
272
+ * Assembles incoming data into statements and hands them off to the message parser.
273
+ *
274
+ * @param {string} data data to append to the current message buffer, as a string.
275
+ *
276
+ * @throws {SyntaxError} if the passed statement parts are not valid JSON.
277
+ */
278
+ parseMessageChunk(data: string): void;
279
+ /**
280
+ * Sends a keep-alive message to the host.
281
+ *
282
+ * @returns true if the ping message was fully flushed to the socket, false if
283
+ * part of the message is queued in the user memory
284
+ */
285
+ ping(): boolean;
286
+ /**
287
+ * Initiates the network connection negotiates a protocol version. Also emits the 'connect' signal if successful.
288
+ *
289
+ * @throws {Error} if the socket connection fails.
290
+ * @returns a promise resolving when the connection is established
291
+ */
292
+ connect(): Promise<void>;
293
+ /**
294
+ * Restores the network connection.
295
+ */
296
+ reconnect(): Promise<void>;
297
+ /**
298
+ * Removes the current reconnect timer.
299
+ */
300
+ clearReconnectTimer(): void;
301
+ /**
302
+ * Removes the current keep-alive timer.
303
+ */
304
+ clearKeepAliveTimer(): void;
305
+ /**
306
+ * Initializes the keep alive timer loop.
307
+ */
308
+ setupKeepAliveTimer(): void;
309
+ /**
310
+ * Tears down the current connection and removes all event listeners on disconnect.
311
+ *
312
+ * @param {boolean} force disconnect even if the connection has not been fully established yet.
313
+ * @param {boolean} intentional update connection state if disconnect is intentional.
314
+ *
315
+ * @returns true if successfully disconnected, or false if there was no connection.
316
+ */
317
+ disconnect(force?: boolean, intentional?: boolean): Promise<boolean>;
318
+ /**
319
+ * Updates connection state based on application visibility.
320
+ *
321
+ * Some browsers will disconnect network connections when the browser is out of focus,
322
+ * which would normally cause our reconnect-on-timeout routines to trigger, but that
323
+ * results in a poor user experience since the events are not handled consistently
324
+ * and sometimes it can take some time after restoring focus to the browser.
325
+ *
326
+ * By manually disconnecting when this happens we prevent the default reconnection routines
327
+ * and make the behavior consistent across browsers.
328
+ */
329
+ handleVisibilityChange(): Promise<void>;
330
+ /**
331
+ * Sends an arbitrary message to the server.
332
+ *
333
+ * @param {string} message json encoded request object to send to the server, as a string.
334
+ *
335
+ * @returns true if the message was fully flushed to the socket, false if part of the message
336
+ * is queued in the user memory
337
+ */
338
+ send(message: string): boolean;
339
+ /**
340
+ * Marks the connection as timed out and schedules reconnection if we have not
341
+ * received data within the expected time frame.
342
+ */
343
+ verifySend(sentTimestamp: number): void;
344
+ /**
345
+ * Updates the connection status when a connection is confirmed.
346
+ */
347
+ onSocketConnect(): void;
348
+ /**
349
+ * Updates the connection status when a connection is ended.
350
+ */
351
+ onSocketDisconnect(): void;
352
+ /**
353
+ * Notify administrator of any unexpected errors.
354
+ */
355
+ onSocketError(error: any | undefined): void;
356
+ }
357
+ /**
358
+ * Triggers when the underlying connection is established.
359
+ *
360
+ * @event ElectrumClient#connected
361
+ */
362
+ /**
363
+ * Triggers when the underlying connection is lost.
364
+ *
365
+ * @event ElectrumClient#disconnected
366
+ */
367
+ /**
368
+ * Triggers when the remote server sends data that is not a request response.
369
+ *
370
+ * @event ElectrumClient#notification
371
+ */
372
+ /**
373
+ * High-level Electrum client that lets applications send requests and subscribe to notification events from a server.
374
+ */
375
+ export class ElectrumClient extends EventEmitter {
376
+ connection: ElectrumConnection;
377
+ subscriptionMethods: Record<string, Set<string>>;
378
+ requestId: number;
379
+ requestResolvers: {
380
+ [index: number]: RequestResolver;
381
+ };
382
+ connectionLock: Mutex;
383
+ /**
384
+ * Initializes an Electrum client.
385
+ *
386
+ * @param {string} application your application name, used to identify to the electrum host.
387
+ * @param {string} version protocol version to use with the host.
388
+ * @param {string} host fully qualified domain name or IP number of the host.
389
+ * @param {number} port the TCP network port of the host.
390
+ * @param {TransportScheme} scheme the transport scheme to use for connection
391
+ * @param {number} timeout how long network delays we will wait for before taking action, in milliseconds.
392
+ * @param {number} pingInterval the time between sending pings to the electrum host, in milliseconds.
393
+ * @param {number} reconnectInterval the time between reconnection attempts to the electrum host, in milliseconds.
394
+ * @param {boolean} useBigInt whether to use bigint for numbers in json response.
395
+ *
396
+ * @throws {Error} if `version` is not a valid version string.
397
+ */
398
+ constructor(application: string, version: string, host: string, port?: number, scheme?: TransportScheme, timeout?: number, pingInterval?: number, reconnectInterval?: number, useBigInt?: boolean);
399
+ /**
400
+ * Connects to the remote server.
401
+ *
402
+ * @throws {Error} if the socket connection fails.
403
+ * @returns a promise resolving when the connection is established.
404
+ */
405
+ connect(): Promise<void>;
406
+ /**
407
+ * Disconnects from the remote server and removes all event listeners/subscriptions and open requests.
408
+ *
409
+ * @param {boolean} force disconnect even if the connection has not been fully established yet.
410
+ * @param {boolean} retainSubscriptions retain subscription data so they will be restored on reconnection.
411
+ *
412
+ * @returns true if successfully disconnected, or false if there was no connection.
413
+ */
414
+ disconnect(force?: boolean, retainSubscriptions?: boolean): Promise<boolean>;
415
+ /**
416
+ * Calls a method on the remote server with the supplied parameters.
417
+ *
418
+ * @param {string} method name of the method to call.
419
+ * @param {...string} parameters one or more parameters for the method.
420
+ *
421
+ * @throws {Error} if the client is disconnected.
422
+ * @returns a promise that resolves with the result of the method or an Error.
423
+ */
424
+ request(method: string, ...parameters: RPCParameter[]): Promise<Error | RequestResponse>;
425
+ /**
426
+ * Subscribes to the method and payload at the server.
427
+ *
428
+ * @note the response for the subscription request is issued as a notification event.
429
+ *
430
+ * @param {string} method one of the subscribable methods the server supports.
431
+ * @param {...string} parameters one or more parameters for the method.
432
+ *
433
+ * @throws {Error} if the client is disconnected.
434
+ * @returns a promise resolving when the subscription is established.
435
+ */
436
+ subscribe(method: string, ...parameters: RPCParameter[]): Promise<void>;
437
+ /**
438
+ * Unsubscribes to the method at the server and removes any callback functions
439
+ * when there are no more subscriptions for the method.
440
+ *
441
+ * @param {string} method a previously subscribed to method.
442
+ * @param {...string} parameters one or more parameters for the method.
443
+ *
444
+ * @throws {Error} if no subscriptions exist for the combination of the provided `method` and `parameters.
445
+ * @throws {Error} if the client is disconnected.
446
+ * @returns a promise resolving when the subscription is removed.
447
+ */
448
+ unsubscribe(method: string, ...parameters: RPCParameter[]): Promise<void>;
449
+ /**
450
+ * Parser messages from the remote server to resolve request promises and emit subscription events.
451
+ *
452
+ * @param {RPCNotification | RPCResponse} message the response message
453
+ *
454
+ * @throws {Error} if the message ID does not match an existing request.
455
+ * @ignore
456
+ */
457
+ response(message: RPCNotification | RPCResponse): void;
458
+ /**
459
+ * Callback function that is called when connection to the Electrum server is lost.
460
+ * Aborts all active requests with an error message indicating that connection was lost.
461
+ *
462
+ * @ignore
463
+ */
464
+ onConnectionDisconnect(): void;
465
+ }
466
+ /**
467
+ * Triggers when the cluster connects to enough servers to satisfy both the cluster confidence and distribution policies.
468
+ *
469
+ * @event ElectrumCluster#ready
470
+ */
471
+ /**
472
+ * Triggers when the cluster loses a connection and can no longer satisfy the cluster distribution policy.
473
+ *
474
+ * @event ElectrumCluster#degraded
475
+ */
476
+ /**
477
+ * Triggers when the cluster loses a connection and can no longer satisfy the cluster confidence policy.
478
+ *
479
+ * @event ElectrumCluster#disabled
480
+ */
481
+ /**
482
+ * Triggers when the cluster verifies the integrity of remote server sent data that is not a request responses.
483
+ *
484
+ * @event ElectrumCluster#notification
485
+ */
486
+ /**
487
+ * High-level electrum client that provides transparent load balancing, confidence checking and/or low-latency polling.
488
+ */
489
+ export class ElectrumCluster extends EventEmitter {
490
+ application: string;
491
+ version: string;
492
+ confidence: number;
493
+ distribution: number;
494
+ order: ClusterOrder;
495
+ timeout: number;
496
+ pingInterval: number;
497
+ reconnectInterval: number;
498
+ useBigInt: boolean;
499
+ clients: {
500
+ [index: string]: ClientConfig;
501
+ };
502
+ connections: number;
503
+ notifications: Record<string, Set<string>>;
504
+ status: ClusterStatus;
505
+ requestCounter: number;
506
+ requestPromises: {
507
+ [index: number]: Promise<Error | RequestResponse>[];
508
+ };
509
+ requestLock: Mutex;
510
+ responseLock: Mutex;
511
+ /**
512
+ * @param {string} application your application name, used to identify to the electrum hosts.
513
+ * @param {string} version protocol version to use with the hosts.
514
+ * @param {number} confidence wait for this number of hosts to provide identical results.
515
+ * @param {number} distribution request information from this number of hosts.
516
+ * @param {ClusterOrder} order select hosts to communicate with in this order.
517
+ * @param {number} timeout how long network delays we will wait for before taking action, in milliseconds.
518
+ * @param {number} pingInterval the time between sending pings to the electrum host, in milliseconds.
519
+ * @param {number} reconnectInterval the time between reconnection attempts to the electrum host, in milliseconds.
520
+ * @param {boolean} useBigInt whether to use bigint for numbers in json response.
521
+ */
522
+ constructor(application: string, version: string, confidence?: number, distribution?: number, order?: ClusterOrder, timeout?: number, pingInterval?: number, reconnectInterval?: number, useBigInt?: boolean);
523
+ /**
524
+ * Adds a server to the cluster.
525
+ *
526
+ * @param {string} host fully qualified domain name or IP number of the host.
527
+ * @param {number} port the TCP network port of the host.
528
+ * @param {TransportScheme} scheme the transport scheme to use for connection
529
+ * @param {boolean} autoConnect flag indicating whether the server should automatically connect (default true)
530
+ *
531
+ * @throws {Error} if the cluster's version is not a valid version string.
532
+ * @returns a promise that resolves when the connection has been initiated.
533
+ */
534
+ addServer(host: string, port?: number, scheme?: TransportScheme, autoConnect?: boolean): Promise<void>;
535
+ /**
536
+ * Calls a method on the remote server with the supplied parameters.
537
+ *
538
+ * @param {string} method name of the method to call.
539
+ * @param {...string} parameters one or more parameters for the method.
540
+ *
541
+ * @throws {Error} if not enough clients are connected
542
+ * @throws {Error} if no response is received with sufficient integrity
543
+ * @returns a promise that resolves with the result of the method.
544
+ */
545
+ request(method: string, ...parameters: RPCParameter[]): Promise<Error | RequestResponse>;
546
+ /**
547
+ * Subscribes to the method at the cluster and attaches the callback function to the event feed.
548
+ *
549
+ * @note the response for the subscription request is issued as a notification event.
550
+ *
551
+ * @param {string} method one of the subscribable methods the server supports.
552
+ * @param {...string} parameters one or more parameters for the method.
553
+ *
554
+ * @throws {Error} if not enough clients are connected
555
+ * @throws {Error} if no response is received with sufficient integrity for the initial request
556
+ */
557
+ subscribe(method: string, ...parameters: RPCParameter[]): Promise<void>;
558
+ /**
559
+ * Unsubscribes to the method at the cluster and removes any callback functions
560
+ * when there are no more subscriptions for the method.
561
+ *
562
+ * @param {string} method one of the subscribable methods the server supports.
563
+ * @param {...string} parameters one or more parameters for the method.
564
+ *
565
+ * @throws {Error} if, for any of the clients, no subscriptions exist for the combination of the provided `method` and `parameters.
566
+ */
567
+ unsubscribe(method: string, ...parameters: RPCParameter[]): Promise<void>;
568
+ /**
569
+ * Define a callback function to validate server notifications and pass them to the subscribe callback.
570
+ *
571
+ * @ignore
572
+ */
573
+ handleSubscriptionNotifications(clientIdentity: string, data: RPCNotification): Promise<void>;
574
+ /**
575
+ * Forgets/Removes notification data for a specific notification.
576
+ *
577
+ * This is required in order to allow future identical notifications to be properly processed and emitted.
578
+ */
579
+ dismissSubscriptionNotification(responseDataIdentifier: any): Promise<void>;
580
+ /**
581
+ * Provides a method to check or wait for the cluster to become ready.
582
+ *
583
+ * @returns a promise that resolves when the required servers are available.
584
+ */
585
+ ready(): Promise<boolean>;
586
+ /**
587
+ * Connects all servers from the cluster and attaches event listeners and handlers
588
+ * for all underlying clients and connections.
589
+ *
590
+ * @throws {Error} if the cluster's version is not a valid version string.
591
+ */
592
+ startup(): Promise<void[]>;
593
+ /**
594
+ * Disconnects all servers from the cluster. Removes all event listeners and
595
+ * handlers from all underlying clients and connections. This includes all
596
+ * active subscriptions, unless retainSubscriptions is set to true.
597
+ *
598
+ * @param {boolean} retainSubscriptions retain subscription data so they will be restored on reconnection.
599
+ *
600
+ * @returns a list with the disconnection result for every client
601
+ */
602
+ shutdown(retainSubscriptions?: boolean): Promise<boolean[]>;
603
+ }
604
+
605
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;ACCA,oBAA2B,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AAG5D;IAEC,OAAO,EAAE,MAAM,CAAC;CAChB;AAGD,yBAAiC,SAAQ,OAAO;IAE/C,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,YAAY,EAAE,CAAC;CACxB;AAWD,sBAA8B,SAAQ,OAAO;IAE5C,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CACf;AAED;IAEC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,GAAG,CAAC;CACX;AAGD,0BAAkC,SAAQ,OAAO;IAEhD,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAClB,KAAK,EAAE,QAAQ,CAAC;CAChB;AAGD,mBAA0B,gBAAgB,GAAG,YAAY,CAAC;AE3C1D;;;;;GAKG;AACH;IAEC,MAAM,IAAI;IACV,QAAQ,IAAI;CACZ;AAED;;;;GAIG;AACH;IAEC,GAAG,IAAI;CACP;AAED;;;;;;GAMG;AACH;IAEC,QAAQ,IAAI;IACZ,QAAQ,IAAI;IACZ,KAAK,IAAI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AC,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,KAAK,GAAG,eAAe,CAAC;IAuK9F;;;;;;;;;;OAUG;IACG,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAsB7E;;;;;;;;OAQG;IACG,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAmB/E;;;;OAIG;IACG,+BAA+B,CAAC,cAAc,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAiDnG;;;;OAIG;IACG,+BAA+B,CAAC,sBAAsB,KAAA,GAAG,OAAO,CAAC,IAAI,CAAC;IAK5E;;;;OAIG;IACG,KAAK,IAAI,OAAO,CAAC,OAAO,CAAC;IA8C/B;;;;;OAKG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;IAgChC;;;;;;;;OAQG;IACG,QAAQ,CAAC,mBAAmB,GAAE,OAAe,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;CAwBxE","sources":["lib/lib/util.ts","lib/lib/rpc-interfaces.ts","lib/lib/electrum-protocol.ts","lib/lib/enums.ts","lib/lib/interfaces.ts","lib/lib/constants.ts","lib/lib/electrum-socket.ts","lib/lib/electrum-connection.ts","lib/lib/electrum-client.ts","lib/lib/electrum-cluster.ts","lib/lib/index.ts","lib/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,null,null,"export { default as ElectrumClient } from './electrum-client';\nexport { default as ElectrumCluster } from './electrum-cluster';\n\nexport * from './interfaces';\nexport * from './constants';\nexport * from './enums';\n"],"names":[],"version":3,"file":"index.d.ts.map"}