@electrum-cash/network 4.0.0-development.6391574314 → 4.0.0-development.6393041663

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.
package/dist/index.mjs CHANGED
@@ -1,10 +1,10 @@
1
- import {EventEmitter as $4QiMX$EventEmitter} from "events";
2
- import {Mutex as $4QiMX$Mutex} from "async-mutex";
3
- import $4QiMX$debug from "debug";
4
- import {parse as $4QiMX$parse, parseNumberAndBigInt as $4QiMX$parseNumberAndBigInt} from "lossless-json";
5
- import {connect as $4QiMX$connect, TLSSocket as $4QiMX$TLSSocket} from "tls";
6
- import {isIP as $4QiMX$isIP, connect as $4QiMX$connect1} from "net";
7
- import {WebSocket as $4QiMX$WebSocket} from "@monsterbitar/isomorphic-ws";
1
+ import {EventEmitter as $dvphU$EventEmitter} from "events";
2
+ import {Mutex as $dvphU$Mutex} from "async-mutex";
3
+ import $dvphU$debug from "debug";
4
+ import {parse as $dvphU$parse, parseNumberAndBigInt as $dvphU$parseNumberAndBigInt} from "lossless-json";
5
+ import {connect as $dvphU$connect, TLSSocket as $dvphU$TLSSocket} from "tls";
6
+ import {isIP as $dvphU$isIP, connect as $dvphU$connect1} from "net";
7
+ import {WebSocket as $dvphU$WebSocket} from "@monsterbitar/isomorphic-ws";
8
8
 
9
9
 
10
10
  function $parcel$export(e, n, v, s) {
@@ -12,23 +12,21 @@ function $parcel$export(e, n, v, s) {
12
12
  }
13
13
 
14
14
  // Create the debug logs.
15
- const $ef5ba40c8abe5a13$var$debug = {
16
- client: (0, $4QiMX$debug)("electrum-cash:client "),
17
- cluster: (0, $4QiMX$debug)("electrum-cash:cluster"),
18
- errors: (0, $4QiMX$debug)("electrum-cash:error "),
19
- warning: (0, $4QiMX$debug)("electrum-cash:warning"),
20
- network: (0, $4QiMX$debug)("electrum-cash:network"),
21
- ping: (0, $4QiMX$debug)("electrum-cash:pulses ")
15
+ const $623a31cc1663a627$var$debug = {
16
+ client: (0, $dvphU$debug)("electrum-cash:client "),
17
+ errors: (0, $dvphU$debug)("electrum-cash:error "),
18
+ warning: (0, $dvphU$debug)("electrum-cash:warning"),
19
+ network: (0, $dvphU$debug)("electrum-cash:network"),
20
+ ping: (0, $dvphU$debug)("electrum-cash:pulses ")
22
21
  };
23
22
  // Set log colors.
24
- $ef5ba40c8abe5a13$var$debug.client.color = "2";
25
- $ef5ba40c8abe5a13$var$debug.cluster.color = "3";
26
- $ef5ba40c8abe5a13$var$debug.errors.color = "9";
27
- $ef5ba40c8abe5a13$var$debug.warning.color = "13";
28
- $ef5ba40c8abe5a13$var$debug.network.color = "4";
29
- $ef5ba40c8abe5a13$var$debug.ping.color = "8";
23
+ $623a31cc1663a627$var$debug.client.color = "2";
24
+ $623a31cc1663a627$var$debug.errors.color = "9";
25
+ $623a31cc1663a627$var$debug.warning.color = "13";
26
+ $623a31cc1663a627$var$debug.network.color = "4";
27
+ $623a31cc1663a627$var$debug.ping.color = "8";
30
28
  var // Export the logs.
31
- $ef5ba40c8abe5a13$export$2e2bcd8739ae039 = $ef5ba40c8abe5a13$var$debug;
29
+ $623a31cc1663a627$export$2e2bcd8739ae039 = $623a31cc1663a627$var$debug;
32
30
 
33
31
 
34
32
 
@@ -36,7 +34,7 @@ $ef5ba40c8abe5a13$export$2e2bcd8739ae039 = $ef5ba40c8abe5a13$var$debug;
36
34
  * Grouping of utilities that simplifies implementation of the Electrum protocol.
37
35
  *
38
36
  * @ignore
39
- */ class $c78f59d21170b7a6$var$ElectrumProtocol {
37
+ */ class $24139611f53a54b8$var$ElectrumProtocol {
40
38
  /**
41
39
  * Helper function that builds an Electrum request object.
42
40
  *
@@ -72,69 +70,26 @@ $ef5ba40c8abe5a13$export$2e2bcd8739ae039 = $ef5ba40c8abe5a13$var$debug;
72
70
  }
73
71
  }
74
72
  var // export the protocol.
75
- $c78f59d21170b7a6$export$2e2bcd8739ae039 = $c78f59d21170b7a6$var$ElectrumProtocol;
73
+ $24139611f53a54b8$export$2e2bcd8739ae039 = $24139611f53a54b8$var$ElectrumProtocol;
76
74
 
77
75
 
78
- var $a192ea5a4eec42d4$exports = {};
76
+ var $e83d2e7688025acd$exports = {};
79
77
 
80
- $parcel$export($a192ea5a4eec42d4$exports, "isVersionRejected", () => $a192ea5a4eec42d4$export$e1f38ab2b4ebdde6);
81
- $parcel$export($a192ea5a4eec42d4$exports, "isVersionNegotiated", () => $a192ea5a4eec42d4$export$9598f0c76aa41d73);
82
- const $a192ea5a4eec42d4$export$e1f38ab2b4ebdde6 = function(object) {
78
+ $parcel$export($e83d2e7688025acd$exports, "isVersionRejected", () => $e83d2e7688025acd$export$e1f38ab2b4ebdde6);
79
+ $parcel$export($e83d2e7688025acd$exports, "isVersionNegotiated", () => $e83d2e7688025acd$export$9598f0c76aa41d73);
80
+ const $e83d2e7688025acd$export$e1f38ab2b4ebdde6 = function(object) {
83
81
  return "error" in object;
84
82
  };
85
- const $a192ea5a4eec42d4$export$9598f0c76aa41d73 = function(object) {
83
+ const $e83d2e7688025acd$export$9598f0c76aa41d73 = function(object) {
86
84
  return "software" in object && "protocol" in object;
87
85
  };
88
86
 
89
87
 
90
- var $5abc8fb342687c03$exports = {};
88
+ var $d801b1f9b7fc3074$exports = {};
91
89
 
92
- $parcel$export($5abc8fb342687c03$exports, "ElectrumTransport", () => $5abc8fb342687c03$export$d048df559e6d3842);
93
- $parcel$export($5abc8fb342687c03$exports, "DefaultParameters", () => $5abc8fb342687c03$export$f019be48b3aacb1a);
94
- var $a58372b18a18806e$exports = {};
95
-
96
- $parcel$export($a58372b18a18806e$exports, "ClusterOrder", () => $a58372b18a18806e$export$161fe3707f756bf9);
97
- $parcel$export($a58372b18a18806e$exports, "ClusterDistribution", () => $a58372b18a18806e$export$436a960acc41e848);
98
- $parcel$export($a58372b18a18806e$exports, "ClusterStatus", () => $a58372b18a18806e$export$c66b56bc0ff967ca);
99
- $parcel$export($a58372b18a18806e$exports, "ClientState", () => $a58372b18a18806e$export$c4f81c6d30ca200f);
100
- $parcel$export($a58372b18a18806e$exports, "ConnectionStatus", () => $a58372b18a18806e$export$7516420eb880ab68);
101
- // Disable indent rule for this file because it is broken (https://github.com/typescript-eslint/typescript-eslint/issues/1824)
102
- /* eslint-disable @typescript-eslint/indent */ /**
103
- * Enum that denotes the ordering to use in an ElectrumCluster.
104
- * @enum {number}
105
- * @property {0} RANDOM Send requests to randomly selected servers in the cluster.
106
- * @property {1} PRIORITY Send requests to servers in the cluster in the order they were added.
107
- */ var $a58372b18a18806e$export$161fe3707f756bf9;
108
- (function(ClusterOrder) {
109
- ClusterOrder[ClusterOrder["RANDOM"] = 0] = "RANDOM";
110
- ClusterOrder[ClusterOrder["PRIORITY"] = 1] = "PRIORITY";
111
- })($a58372b18a18806e$export$161fe3707f756bf9 || ($a58372b18a18806e$export$161fe3707f756bf9 = {}));
112
- var $a58372b18a18806e$export$436a960acc41e848;
113
- (function(ClusterDistribution) {
114
- ClusterDistribution[ClusterDistribution["ALL"] = 0] = "ALL";
115
- })($a58372b18a18806e$export$436a960acc41e848 || ($a58372b18a18806e$export$436a960acc41e848 = {}));
116
- var $a58372b18a18806e$export$c66b56bc0ff967ca;
117
- (function(ClusterStatus) {
118
- ClusterStatus[ClusterStatus["DISABLED"] = 0] = "DISABLED";
119
- ClusterStatus[ClusterStatus["DEGRADED"] = 1] = "DEGRADED";
120
- ClusterStatus[ClusterStatus["READY"] = 2] = "READY";
121
- })($a58372b18a18806e$export$c66b56bc0ff967ca || ($a58372b18a18806e$export$c66b56bc0ff967ca = {}));
122
- var $a58372b18a18806e$export$c4f81c6d30ca200f;
123
- (function(ClientState) {
124
- ClientState[ClientState["UNAVAILABLE"] = 0] = "UNAVAILABLE";
125
- ClientState[ClientState["AVAILABLE"] = 1] = "AVAILABLE";
126
- })($a58372b18a18806e$export$c4f81c6d30ca200f || ($a58372b18a18806e$export$c4f81c6d30ca200f = {}));
127
- var $a58372b18a18806e$export$7516420eb880ab68;
128
- (function(ConnectionStatus) {
129
- ConnectionStatus[ConnectionStatus["DISCONNECTED"] = 0] = "DISCONNECTED";
130
- ConnectionStatus[ConnectionStatus["CONNECTED"] = 1] = "CONNECTED";
131
- ConnectionStatus[ConnectionStatus["DISCONNECTING"] = 2] = "DISCONNECTING";
132
- ConnectionStatus[ConnectionStatus["CONNECTING"] = 3] = "CONNECTING";
133
- ConnectionStatus[ConnectionStatus["RECONNECTING"] = 4] = "RECONNECTING";
134
- })($a58372b18a18806e$export$7516420eb880ab68 || ($a58372b18a18806e$export$7516420eb880ab68 = {}));
135
-
136
-
137
- const $5abc8fb342687c03$export$d048df559e6d3842 = {
90
+ $parcel$export($d801b1f9b7fc3074$exports, "ElectrumTransport", () => $d801b1f9b7fc3074$export$d048df559e6d3842);
91
+ $parcel$export($d801b1f9b7fc3074$exports, "DefaultParameters", () => $d801b1f9b7fc3074$export$f019be48b3aacb1a);
92
+ const $d801b1f9b7fc3074$export$d048df559e6d3842 = {
138
93
  TCP: {
139
94
  Port: 50001,
140
95
  Scheme: "tcp"
@@ -152,11 +107,11 @@ const $5abc8fb342687c03$export$d048df559e6d3842 = {
152
107
  Scheme: "wss"
153
108
  }
154
109
  };
155
- const $5abc8fb342687c03$export$f019be48b3aacb1a = {
110
+ const $d801b1f9b7fc3074$export$f019be48b3aacb1a = {
156
111
  // Port number for TCP TLS connections
157
- PORT: $5abc8fb342687c03$export$d048df559e6d3842.TCP_TLS.Port,
112
+ PORT: $d801b1f9b7fc3074$export$d048df559e6d3842.TCP_TLS.Port,
158
113
  // Transport to connect to the Electrum server
159
- TRANSPORT_SCHEME: $5abc8fb342687c03$export$d048df559e6d3842.TCP_TLS.Scheme,
114
+ TRANSPORT_SCHEME: $d801b1f9b7fc3074$export$d048df559e6d3842.TCP_TLS.Scheme,
160
115
  // How long to wait before attempting to reconnect, in milliseconds.
161
116
  RECONNECT: 5000,
162
117
  // How long to wait for network operations before following up, in milliseconds.
@@ -164,12 +119,6 @@ const $5abc8fb342687c03$export$f019be48b3aacb1a = {
164
119
  // Time between ping messages, in milliseconds. Pinging keeps the connection alive.
165
120
  // The reason for pinging this frequently is to detect connection problems early.
166
121
  PING_INTERVAL: 1000,
167
- // How many servers are required before we trust information provided.
168
- CLUSTER_CONFIDENCE: 1,
169
- // How many servers we send requests to.
170
- CLUSTER_DISTRIBUTION: (0, $a58372b18a18806e$export$436a960acc41e848).ALL,
171
- // What order we select servers to send requests to.
172
- CLUSTER_ORDER: (0, $a58372b18a18806e$export$161fe3707f756bf9).RANDOM,
173
122
  // If we use BigInt for numbers in json when parsing and returning json response from the server.
174
123
  USE_BIG_INT: false
175
124
  };
@@ -182,7 +131,7 @@ const $5abc8fb342687c03$export$f019be48b3aacb1a = {
182
131
 
183
132
 
184
133
 
185
- class $ea64e414b68fe23b$export$22c0ca2c816c3e08 extends (0, $4QiMX$EventEmitter) {
134
+ class $0a4cf22b9d6c493c$export$22c0ca2c816c3e08 extends (0, $dvphU$EventEmitter) {
186
135
  /**
187
136
  * Connect to host:port using the specified transport
188
137
  *
@@ -201,39 +150,39 @@ class $ea64e414b68fe23b$export$22c0ca2c816c3e08 extends (0, $4QiMX$EventEmitter)
201
150
  this.once("connect", this.clearDisconnectTimerOnTimeout);
202
151
  // Define how to refer to the connection scheme in debug output.
203
152
  const socketTypes = {
204
- [(0, $5abc8fb342687c03$export$d048df559e6d3842).TCP.Scheme]: "a TCP Socket",
205
- [(0, $5abc8fb342687c03$export$d048df559e6d3842).TCP_TLS.Scheme]: "an encrypted TCP socket"
153
+ [(0, $d801b1f9b7fc3074$export$d048df559e6d3842).TCP.Scheme]: "a TCP Socket",
154
+ [(0, $d801b1f9b7fc3074$export$d048df559e6d3842).TCP_TLS.Scheme]: "an encrypted TCP socket"
206
155
  };
207
156
  // Log that we are trying to establish a connection.
208
- (0, $ef5ba40c8abe5a13$export$2e2bcd8739ae039).network(`Initiating ${socketTypes[scheme]} connection to '${host}:${port}'.`);
209
- if (scheme !== (0, $5abc8fb342687c03$export$d048df559e6d3842).TCP.Scheme && scheme !== (0, $5abc8fb342687c03$export$d048df559e6d3842).TCP_TLS.Scheme) // Throw an error if an incorrect transport is specified
157
+ (0, $623a31cc1663a627$export$2e2bcd8739ae039).network(`Initiating ${socketTypes[scheme]} connection to '${host}:${port}'.`);
158
+ if (scheme !== (0, $d801b1f9b7fc3074$export$d048df559e6d3842).TCP.Scheme && scheme !== (0, $d801b1f9b7fc3074$export$d048df559e6d3842).TCP_TLS.Scheme) // Throw an error if an incorrect transport is specified
210
159
  throw new Error("Incorrect transport specified");
211
- if (scheme === (0, $5abc8fb342687c03$export$d048df559e6d3842).TCP_TLS.Scheme) {
160
+ if (scheme === (0, $d801b1f9b7fc3074$export$d048df559e6d3842).TCP_TLS.Scheme) {
212
161
  // Initialize connection options.
213
162
  const connectionOptions = {
214
163
  rejectUnauthorized: false
215
164
  };
216
165
  // If the hostname is not an IP address..
217
- if (!$4QiMX$isIP(host)) // Set the servername option which enables support for SNI.
166
+ if (!$dvphU$isIP(host)) // Set the servername option which enables support for SNI.
218
167
  // NOTE: SNI enables a server that hosts multiple domains to provide the appropriate TLS certificate.
219
168
  connectionOptions.serverName = host;
220
169
  // Initialize the socket (allowing self-signed certificates).
221
- this.tcpSocket = $4QiMX$connect(port, host, connectionOptions);
170
+ this.tcpSocket = $dvphU$connect(port, host, connectionOptions);
222
171
  // Add a 'secureConnect' listener that checks the authorization status of
223
172
  // the socket, and logs a warning when it uses a self signed certificate.
224
173
  this.tcpSocket.once("secureConnect", ()=>{
225
174
  // Cannot happen, since this event callback *only* exists on TLSSocket
226
- if (!(this.tcpSocket instanceof $4QiMX$TLSSocket)) return;
175
+ if (!(this.tcpSocket instanceof $dvphU$TLSSocket)) return;
227
176
  // Force cast authorizationError from Error to string (through unknown)
228
177
  // because it is incorrectly typed as an Error
229
178
  const authorizationError = this.tcpSocket.authorizationError;
230
- if (authorizationError === "DEPTH_ZERO_SELF_SIGNED_CERT") (0, $ef5ba40c8abe5a13$export$2e2bcd8739ae039).warning(`Connection to ${host}:${port} uses a self-signed certificate`);
179
+ if (authorizationError === "DEPTH_ZERO_SELF_SIGNED_CERT") (0, $623a31cc1663a627$export$2e2bcd8739ae039).warning(`Connection to ${host}:${port} uses a self-signed certificate`);
231
180
  });
232
181
  // Trigger successful connection events.
233
182
  this.tcpSocket.on("secureConnect", this.onConnect.bind(this, socketTypes[scheme], host, port));
234
183
  } else {
235
184
  // Initialize the socket.
236
- this.tcpSocket = $4QiMX$connect1({
185
+ this.tcpSocket = $dvphU$connect1({
237
186
  host: host,
238
187
  port: port
239
188
  });
@@ -259,7 +208,7 @@ class $ea64e414b68fe23b$export$22c0ca2c816c3e08 extends (0, $4QiMX$EventEmitter)
259
208
  // If the onConnect function has already run, do not execute it again.
260
209
  if (this.onConnectHasRun) return;
261
210
  // Log that the connection has been established.
262
- (0, $ef5ba40c8abe5a13$export$2e2bcd8739ae039).network(`Established ${connectionType} connection with '${host}:${port}'.`);
211
+ (0, $623a31cc1663a627$export$2e2bcd8739ae039).network(`Established ${connectionType} connection with '${host}:${port}'.`);
263
212
  // Forward the socket events
264
213
  this.tcpSocket.addListener("close", this.eventForwarders.disconnect);
265
214
  this.tcpSocket.addListener("data", this.eventForwarders.tcpData);
@@ -343,7 +292,7 @@ class $ea64e414b68fe23b$export$22c0ca2c816c3e08 extends (0, $4QiMX$EventEmitter)
343
292
  };
344
293
  }
345
294
  }
346
- class $ea64e414b68fe23b$export$25b4633f61498e1 extends (0, $4QiMX$EventEmitter) {
295
+ class $0a4cf22b9d6c493c$export$25b4633f61498e1 extends (0, $dvphU$EventEmitter) {
347
296
  /**
348
297
  * Connect to host:port using the specified transport
349
298
  *
@@ -362,18 +311,18 @@ class $ea64e414b68fe23b$export$25b4633f61498e1 extends (0, $4QiMX$EventEmitter)
362
311
  this.once("connect", this.clearDisconnectTimerOnTimeout);
363
312
  // Define how to refer to the connection scheme in debug output.
364
313
  const socketTypes = {
365
- [(0, $5abc8fb342687c03$export$d048df559e6d3842).WS.Scheme]: "a WebSocket",
366
- [(0, $5abc8fb342687c03$export$d048df559e6d3842).WSS.Scheme]: "an encrypted WebSocket"
314
+ [(0, $d801b1f9b7fc3074$export$d048df559e6d3842).WS.Scheme]: "a WebSocket",
315
+ [(0, $d801b1f9b7fc3074$export$d048df559e6d3842).WSS.Scheme]: "an encrypted WebSocket"
367
316
  };
368
317
  // Log that we are trying to establish a connection.
369
- (0, $ef5ba40c8abe5a13$export$2e2bcd8739ae039).network(`Initiating ${socketTypes[scheme]} connection to '${host}:${port}'.`);
370
- if (scheme !== (0, $5abc8fb342687c03$export$d048df559e6d3842).WS.Scheme && scheme !== (0, $5abc8fb342687c03$export$d048df559e6d3842).WSS.Scheme) // Throw an error if an incorrect transport is specified
318
+ (0, $623a31cc1663a627$export$2e2bcd8739ae039).network(`Initiating ${socketTypes[scheme]} connection to '${host}:${port}'.`);
319
+ if (scheme !== (0, $d801b1f9b7fc3074$export$d048df559e6d3842).WS.Scheme && scheme !== (0, $d801b1f9b7fc3074$export$d048df559e6d3842).WSS.Scheme) // Throw an error if an incorrect transport is specified
371
320
  throw new Error("Incorrect transport specified");
372
- if (scheme === (0, $5abc8fb342687c03$export$d048df559e6d3842).WSS.Scheme) // Initialize this.webSocket (rejecting self-signed certificates).
321
+ if (scheme === (0, $d801b1f9b7fc3074$export$d048df559e6d3842).WSS.Scheme) // Initialize this.webSocket (rejecting self-signed certificates).
373
322
  // We reject self-signed certificates to match functionality of browsers.
374
- this.webSocket = new (0, $4QiMX$WebSocket)(`wss://${host}:${port}`);
323
+ this.webSocket = new (0, $dvphU$WebSocket)(`wss://${host}:${port}`);
375
324
  else // Initialize this.webSocket.
376
- this.webSocket = new (0, $4QiMX$WebSocket)(`ws://${host}:${port}`);
325
+ this.webSocket = new (0, $dvphU$WebSocket)(`ws://${host}:${port}`);
377
326
  // Trigger successful connection events.
378
327
  this.webSocket.addEventListener("open", this.onConnect.bind(this, socketTypes[scheme], host, port));
379
328
  // Forward the encountered errors.
@@ -389,7 +338,7 @@ class $ea64e414b68fe23b$export$25b4633f61498e1 extends (0, $4QiMX$EventEmitter)
389
338
  // If the onConnect function has already run, do not execute it again.
390
339
  if (this.onConnectHasRun) return;
391
340
  // Log that the connection has been established.
392
- (0, $ef5ba40c8abe5a13$export$2e2bcd8739ae039).network(`Established ${connectionType} connection with '${host}:${port}'.`);
341
+ (0, $623a31cc1663a627$export$2e2bcd8739ae039).network(`Established ${connectionType} connection with '${host}:${port}'.`);
393
342
  // Forward the socket events
394
343
  this.webSocket.addEventListener("close", this.eventForwarders.disconnect);
395
344
  this.webSocket.addEventListener("message", this.eventForwarders.wsData);
@@ -482,13 +431,37 @@ class $ea64e414b68fe23b$export$25b4633f61498e1 extends (0, $4QiMX$EventEmitter)
482
431
  }
483
432
 
484
433
 
434
+ var $db7c797e63383364$exports = {};
435
+
436
+ $parcel$export($db7c797e63383364$exports, "ClientState", () => $db7c797e63383364$export$c4f81c6d30ca200f);
437
+ $parcel$export($db7c797e63383364$exports, "ConnectionStatus", () => $db7c797e63383364$export$7516420eb880ab68);
438
+ // Disable indent rule for this file because it is broken (https://github.com/typescript-eslint/typescript-eslint/issues/1824)
439
+ /* eslint-disable @typescript-eslint/indent */ /**
440
+ * Enum that denotes the availability of an ElectrumClient.
441
+ * @enum {number}
442
+ * @property {0} UNAVAILABLE The client is currently not available.
443
+ * @property {1} AVAILABLE The client is available for use.
444
+ */ var $db7c797e63383364$export$c4f81c6d30ca200f;
445
+ (function(ClientState) {
446
+ ClientState[ClientState["UNAVAILABLE"] = 0] = "UNAVAILABLE";
447
+ ClientState[ClientState["AVAILABLE"] = 1] = "AVAILABLE";
448
+ })($db7c797e63383364$export$c4f81c6d30ca200f || ($db7c797e63383364$export$c4f81c6d30ca200f = {}));
449
+ var $db7c797e63383364$export$7516420eb880ab68;
450
+ (function(ConnectionStatus) {
451
+ ConnectionStatus[ConnectionStatus["DISCONNECTED"] = 0] = "DISCONNECTED";
452
+ ConnectionStatus[ConnectionStatus["CONNECTED"] = 1] = "CONNECTED";
453
+ ConnectionStatus[ConnectionStatus["DISCONNECTING"] = 2] = "DISCONNECTING";
454
+ ConnectionStatus[ConnectionStatus["CONNECTING"] = 3] = "CONNECTING";
455
+ ConnectionStatus[ConnectionStatus["RECONNECTING"] = 4] = "RECONNECTING";
456
+ })($db7c797e63383364$export$7516420eb880ab68 || ($db7c797e63383364$export$7516420eb880ab68 = {}));
457
+
485
458
 
486
459
 
487
460
  /**
488
461
  * Wrapper around TLS/WSS sockets that gracefully separates a network stream into Electrum protocol messages.
489
462
  *
490
463
  * @ignore
491
- */ class $1326c18f93f95fee$var$ElectrumConnection extends (0, $4QiMX$EventEmitter) {
464
+ */ class $ff134c9a9e1f7361$var$ElectrumConnection extends (0, $dvphU$EventEmitter) {
492
465
  /**
493
466
  * Sets up network configuration for an Electrum client connection.
494
467
  *
@@ -503,7 +476,7 @@ class $ea64e414b68fe23b$export$25b4633f61498e1 extends (0, $4QiMX$EventEmitter)
503
476
  * @param {boolean} useBigInt whether to use bigint for numbers in json response.
504
477
  *
505
478
  * @throws {Error} if `version` is not a valid version string.
506
- */ constructor(application, version, host, port = (0, $5abc8fb342687c03$export$f019be48b3aacb1a).PORT, scheme = (0, $5abc8fb342687c03$export$f019be48b3aacb1a).TRANSPORT_SCHEME, timeout = (0, $5abc8fb342687c03$export$f019be48b3aacb1a).TIMEOUT, pingInterval = (0, $5abc8fb342687c03$export$f019be48b3aacb1a).PING_INTERVAL, reconnectInterval = (0, $5abc8fb342687c03$export$f019be48b3aacb1a).RECONNECT, useBigInt = (0, $5abc8fb342687c03$export$f019be48b3aacb1a).USE_BIG_INT){
479
+ */ constructor(application, version, host, port = (0, $d801b1f9b7fc3074$export$f019be48b3aacb1a).PORT, scheme = (0, $d801b1f9b7fc3074$export$f019be48b3aacb1a).TRANSPORT_SCHEME, timeout = (0, $d801b1f9b7fc3074$export$f019be48b3aacb1a).TIMEOUT, pingInterval = (0, $d801b1f9b7fc3074$export$f019be48b3aacb1a).PING_INTERVAL, reconnectInterval = (0, $d801b1f9b7fc3074$export$f019be48b3aacb1a).RECONNECT, useBigInt = (0, $d801b1f9b7fc3074$export$f019be48b3aacb1a).USE_BIG_INT){
507
480
  // Initialize the event emitter.
508
481
  super();
509
482
  this.application = application;
@@ -515,12 +488,12 @@ class $ea64e414b68fe23b$export$25b4633f61498e1 extends (0, $4QiMX$EventEmitter)
515
488
  this.pingInterval = pingInterval;
516
489
  this.reconnectInterval = reconnectInterval;
517
490
  this.useBigInt = useBigInt;
518
- this.status = (0, $a58372b18a18806e$export$7516420eb880ab68).DISCONNECTED;
491
+ this.status = (0, $db7c797e63383364$export$7516420eb880ab68).DISCONNECTED;
519
492
  this.timers = {};
520
493
  this.verifications = [];
521
494
  this.messageBuffer = "";
522
495
  // Check if the provided version is a valid version number.
523
- if (!(0, $c78f59d21170b7a6$export$2e2bcd8739ae039).versionRegexp.test(version)) // Throw an error since the version number was not valid.
496
+ if (!(0, $24139611f53a54b8$export$2e2bcd8739ae039).versionRegexp.test(version)) // Throw an error since the version number was not valid.
524
497
  throw new Error(`Provided version string (${version}) is not a valid protocol version number.`);
525
498
  // Create an initial network socket.
526
499
  this.createSocket();
@@ -535,10 +508,10 @@ class $ea64e414b68fe23b$export$25b4633f61498e1 extends (0, $4QiMX$EventEmitter)
535
508
  /**
536
509
  * Create and configures a fresh socket and attaches all relevant listeners.
537
510
  */ createSocket() {
538
- if (this.scheme === (0, $5abc8fb342687c03$export$d048df559e6d3842).TCP.Scheme || this.scheme === (0, $5abc8fb342687c03$export$d048df559e6d3842).TCP_TLS.Scheme) // Initialize a new ElectrumTcpSocket
539
- this.socket = new (0, $ea64e414b68fe23b$export$22c0ca2c816c3e08)();
540
- else if (this.scheme === (0, $5abc8fb342687c03$export$d048df559e6d3842).WS.Scheme || this.scheme === (0, $5abc8fb342687c03$export$d048df559e6d3842).WSS.Scheme) // Initialize a new ElectrumWebSocket
541
- this.socket = new (0, $ea64e414b68fe23b$export$25b4633f61498e1)();
511
+ if (this.scheme === (0, $d801b1f9b7fc3074$export$d048df559e6d3842).TCP.Scheme || this.scheme === (0, $d801b1f9b7fc3074$export$d048df559e6d3842).TCP_TLS.Scheme) // Initialize a new ElectrumTcpSocket
512
+ this.socket = new (0, $0a4cf22b9d6c493c$export$22c0ca2c816c3e08)();
513
+ else if (this.scheme === (0, $d801b1f9b7fc3074$export$d048df559e6d3842).WS.Scheme || this.scheme === (0, $d801b1f9b7fc3074$export$d048df559e6d3842).WSS.Scheme) // Initialize a new ElectrumWebSocket
514
+ this.socket = new (0, $0a4cf22b9d6c493c$export$25b4633f61498e1)();
542
515
  else // Throw an error if an incorrect transport is specified
543
516
  throw new Error(`Provided transport (${this.scheme}) is not a valid ElectrumTransport`);
544
517
  // Set up handlers for connection and disconnection.
@@ -568,15 +541,15 @@ class $ea64e414b68fe23b$export$25b4633f61498e1 extends (0, $4QiMX$EventEmitter)
568
541
  // Add the message to the current message buffer.
569
542
  this.messageBuffer += data;
570
543
  // Check if the new message buffer contains the statement delimiter.
571
- while(this.messageBuffer.includes((0, $c78f59d21170b7a6$export$2e2bcd8739ae039).statementDelimiter)){
544
+ while(this.messageBuffer.includes((0, $24139611f53a54b8$export$2e2bcd8739ae039).statementDelimiter)){
572
545
  // Split message buffer into statements.
573
- const statementParts = this.messageBuffer.split((0, $c78f59d21170b7a6$export$2e2bcd8739ae039).statementDelimiter);
546
+ const statementParts = this.messageBuffer.split((0, $24139611f53a54b8$export$2e2bcd8739ae039).statementDelimiter);
574
547
  // For as long as we still have statements to parse..
575
548
  while(statementParts.length > 1){
576
549
  // Move the first statement to its own variable.
577
550
  const currentStatementList = String(statementParts.shift());
578
551
  // Parse the statement into an object or list of objects.
579
- let statementList = (0, $4QiMX$parse)(currentStatementList, null, this.useBigInt ? (0, $4QiMX$parseNumberAndBigInt) : parseFloat);
552
+ let statementList = (0, $dvphU$parse)(currentStatementList, null, this.useBigInt ? (0, $dvphU$parseNumberAndBigInt) : parseFloat);
580
553
  // Wrap the statement in an array if it is not already a batched statement list.
581
554
  if (!Array.isArray(statementList)) statementList = [
582
555
  statementList
@@ -621,9 +594,9 @@ class $ea64e414b68fe23b$export$25b4633f61498e1 extends (0, $4QiMX$EventEmitter)
621
594
  * part of the message is queued in the user memory
622
595
  */ ping() {
623
596
  // Write a log message.
624
- (0, $ef5ba40c8abe5a13$export$2e2bcd8739ae039).ping(`Sending keep-alive ping to '${this.hostIdentifier}'`);
597
+ (0, $623a31cc1663a627$export$2e2bcd8739ae039).ping(`Sending keep-alive ping to '${this.hostIdentifier}'`);
625
598
  // Craft a keep-alive message.
626
- const message = (0, $c78f59d21170b7a6$export$2e2bcd8739ae039).buildRequestObject("server.ping", [], "keepAlive");
599
+ const message = (0, $24139611f53a54b8$export$2e2bcd8739ae039).buildRequestObject("server.ping", [], "keepAlive");
627
600
  // Send the keep-alive message.
628
601
  const status = this.send(message);
629
602
  // Return the ping status.
@@ -636,14 +609,14 @@ class $ea64e414b68fe23b$export$25b4633f61498e1 extends (0, $4QiMX$EventEmitter)
636
609
  * @returns a promise resolving when the connection is established
637
610
  */ async connect() {
638
611
  // If we are already connected return true.
639
- if (this.status === (0, $a58372b18a18806e$export$7516420eb880ab68).CONNECTED) return;
612
+ if (this.status === (0, $db7c797e63383364$export$7516420eb880ab68).CONNECTED) return;
640
613
  // Indicate that the connection is connecting
641
- this.status = (0, $a58372b18a18806e$export$7516420eb880ab68).CONNECTING;
614
+ this.status = (0, $db7c797e63383364$export$7516420eb880ab68).CONNECTING;
642
615
  // Define a function to wrap connection as a promise.
643
616
  const connectionResolver = (resolve, reject)=>{
644
617
  const rejector = (error)=>{
645
618
  // Set the status back to disconnected
646
- this.status = (0, $a58372b18a18806e$export$7516420eb880ab68).DISCONNECTED;
619
+ this.status = (0, $db7c797e63383364$export$7516420eb880ab68).DISCONNECTED;
647
620
  // Reject with the error as reason
648
621
  reject(error);
649
622
  };
@@ -653,24 +626,24 @@ class $ea64e414b68fe23b$export$25b4633f61498e1 extends (0, $4QiMX$EventEmitter)
653
626
  // Define a function to wrap version negotiation as a callback.
654
627
  const versionNegotiator = ()=>{
655
628
  // Write a log message to show that we have started version negotiation.
656
- (0, $ef5ba40c8abe5a13$export$2e2bcd8739ae039).network(`Requesting protocol version ${this.version} with '${this.hostIdentifier}'.`);
629
+ (0, $623a31cc1663a627$export$2e2bcd8739ae039).network(`Requesting protocol version ${this.version} with '${this.hostIdentifier}'.`);
657
630
  // remove the one-time error handler since no error was detected.
658
631
  this.socket.removeListener("error", rejector);
659
632
  // Build a version negotiation message.
660
- const versionMessage = (0, $c78f59d21170b7a6$export$2e2bcd8739ae039).buildRequestObject("server.version", [
633
+ const versionMessage = (0, $24139611f53a54b8$export$2e2bcd8739ae039).buildRequestObject("server.version", [
661
634
  this.application,
662
635
  this.version
663
636
  ], "versionNegotiation");
664
637
  // Define a function to wrap version validation as a function.
665
638
  const versionValidator = (version)=>{
666
639
  // Check if version negotiation failed.
667
- if ((0, $a192ea5a4eec42d4$export$e1f38ab2b4ebdde6)(version)) {
640
+ if ((0, $e83d2e7688025acd$export$e1f38ab2b4ebdde6)(version)) {
668
641
  // Disconnect from the host.
669
642
  this.disconnect(true);
670
643
  // Declare an error message.
671
644
  const errorMessage = "unsupported protocol version.";
672
645
  // Log the error.
673
- (0, $ef5ba40c8abe5a13$export$2e2bcd8739ae039).errors(`Failed to connect with ${this.hostIdentifier} due to ${errorMessage}`);
646
+ (0, $623a31cc1663a627$export$2e2bcd8739ae039).errors(`Failed to connect with ${this.hostIdentifier} due to ${errorMessage}`);
674
647
  // Reject the connection with false since version negotiation failed.
675
648
  reject(errorMessage);
676
649
  } else if (version.protocol !== this.version && `${version.protocol}.0` !== this.version && `${version.protocol}.0.0` !== this.version) {
@@ -679,14 +652,14 @@ class $ea64e414b68fe23b$export$25b4633f61498e1 extends (0, $4QiMX$EventEmitter)
679
652
  // Declare an error message.
680
653
  const errorMessage = `incompatible protocol version negotiated (${version.protocol} !== ${this.version}).`;
681
654
  // Log the error.
682
- (0, $ef5ba40c8abe5a13$export$2e2bcd8739ae039).errors(`Failed to connect with ${this.hostIdentifier} due to ${errorMessage}`);
655
+ (0, $623a31cc1663a627$export$2e2bcd8739ae039).errors(`Failed to connect with ${this.hostIdentifier} due to ${errorMessage}`);
683
656
  // Reject the connection with false since version negotiation failed.
684
657
  reject(errorMessage);
685
658
  } else {
686
659
  // Write a log message.
687
- (0, $ef5ba40c8abe5a13$export$2e2bcd8739ae039).network(`Negotiated protocol version ${version.protocol} with '${this.hostIdentifier}', powered by ${version.software}.`);
660
+ (0, $623a31cc1663a627$export$2e2bcd8739ae039).network(`Negotiated protocol version ${version.protocol} with '${this.hostIdentifier}', powered by ${version.software}.`);
688
661
  // Set connection status to connected
689
- this.status = (0, $a58372b18a18806e$export$7516420eb880ab68).CONNECTED;
662
+ this.status = (0, $db7c797e63383364$export$7516420eb880ab68).CONNECTED;
690
663
  // Emit a connect event now that the connection is usable.
691
664
  this.emit("connect");
692
665
  // Resolve the connection promise since we successfully connected and negotiated protocol version.
@@ -714,9 +687,9 @@ class $ea64e414b68fe23b$export$25b4633f61498e1 extends (0, $4QiMX$EventEmitter)
714
687
  // If a reconnect timer is set, remove it
715
688
  await this.clearReconnectTimer();
716
689
  // Write a log message.
717
- (0, $ef5ba40c8abe5a13$export$2e2bcd8739ae039).network(`Trying to reconnect to '${this.hostIdentifier}'..`);
690
+ (0, $623a31cc1663a627$export$2e2bcd8739ae039).network(`Trying to reconnect to '${this.hostIdentifier}'..`);
718
691
  // Set the status to reconnecting for more accurate log messages.
719
- this.status = (0, $a58372b18a18806e$export$7516420eb880ab68).RECONNECTING;
692
+ this.status = (0, $db7c797e63383364$export$7516420eb880ab68).RECONNECTING;
720
693
  // Destroy and recreate the socket to get a clean slate.
721
694
  this.destroySocket();
722
695
  this.createSocket();
@@ -759,13 +732,13 @@ class $ea64e414b68fe23b$export$25b4633f61498e1 extends (0, $4QiMX$EventEmitter)
759
732
  * @returns true if successfully disconnected, or false if there was no connection.
760
733
  */ async disconnect(force = false, intentional = true) {
761
734
  // Return early when there is nothing to disconnect from
762
- if (this.status === (0, $a58372b18a18806e$export$7516420eb880ab68).DISCONNECTED && !force) // Return false to indicate that there was nothing to disconnect from.
735
+ if (this.status === (0, $db7c797e63383364$export$7516420eb880ab68).DISCONNECTED && !force) // Return false to indicate that there was nothing to disconnect from.
763
736
  return false;
764
737
  // Update connection state if the disconnection is intentional.
765
738
  // NOTE: The state is meant to represent what the client is requesting, but
766
739
  // is used internally to handle visibility changes in browsers to ensure functional reconnection.
767
740
  if (intentional) // Set connection status to null to indicate tear-down is currently happening.
768
- this.status = (0, $a58372b18a18806e$export$7516420eb880ab68).DISCONNECTING;
741
+ this.status = (0, $db7c797e63383364$export$7516420eb880ab68).DISCONNECTING;
769
742
  // If a keep-alive timer is set, remove it.
770
743
  await this.clearKeepAliveTimer();
771
744
  // If a reconnect timer is set, remove it
@@ -818,7 +791,7 @@ class $ea64e414b68fe23b$export$25b4633f61498e1 extends (0, $4QiMX$EventEmitter)
818
791
  // Set a new keep-alive timer.
819
792
  this.setupKeepAliveTimer();
820
793
  // Write the message to the network socket.
821
- return this.socket.write(message + (0, $c78f59d21170b7a6$export$2e2bcd8739ae039).statementDelimiter);
794
+ return this.socket.write(message + (0, $24139611f53a54b8$export$2e2bcd8739ae039).statementDelimiter);
822
795
  }
823
796
  // --- Event managers. --- //
824
797
  /**
@@ -828,14 +801,14 @@ class $ea64e414b68fe23b$export$25b4633f61498e1 extends (0, $4QiMX$EventEmitter)
828
801
  // If we haven't received any data since we last sent data out..
829
802
  if (Number(this.lastReceivedTimestamp) < sentTimestamp) {
830
803
  // If this connection is already disconnected, we do not change anything
831
- if (this.status === (0, $a58372b18a18806e$export$7516420eb880ab68).DISCONNECTED || this.status === (0, $a58372b18a18806e$export$7516420eb880ab68).DISCONNECTING) {
832
- (0, $ef5ba40c8abe5a13$export$2e2bcd8739ae039).errors(`Tried to verify already disconnected connection to '${this.hostIdentifier}'`);
804
+ if (this.status === (0, $db7c797e63383364$export$7516420eb880ab68).DISCONNECTED || this.status === (0, $db7c797e63383364$export$7516420eb880ab68).DISCONNECTING) {
805
+ (0, $623a31cc1663a627$export$2e2bcd8739ae039).errors(`Tried to verify already disconnected connection to '${this.hostIdentifier}'`);
833
806
  return;
834
807
  }
835
808
  // Remove the current keep-alive timer if it exists.
836
809
  this.clearKeepAliveTimer();
837
810
  // Write a notification to the logs.
838
- (0, $ef5ba40c8abe5a13$export$2e2bcd8739ae039).network(`Connection to '${this.hostIdentifier}' timed out.`);
811
+ (0, $623a31cc1663a627$export$2e2bcd8739ae039).network(`Connection to '${this.hostIdentifier}' timed out.`);
839
812
  // Close the connection to avoid re-use.
840
813
  // NOTE: This initiates reconnection routines if the connection has not
841
814
  // been marked as intentionally disconnected.
@@ -864,21 +837,21 @@ class $ea64e414b68fe23b$export$25b4633f61498e1 extends (0, $4QiMX$EventEmitter)
864
837
  // Remove the current keep-alive timer if it exists.
865
838
  this.clearKeepAliveTimer();
866
839
  // If this is a connection we're trying to tear down..
867
- if (this.status === (0, $a58372b18a18806e$export$7516420eb880ab68).DISCONNECTING) {
840
+ if (this.status === (0, $db7c797e63383364$export$7516420eb880ab68).DISCONNECTING) {
868
841
  // If a reconnect timer is set, remove it.
869
842
  this.clearReconnectTimer();
870
843
  // Remove all event listeners
871
844
  this.removeAllListeners();
872
845
  // Mark the connection as disconnected.
873
- this.status = (0, $a58372b18a18806e$export$7516420eb880ab68).DISCONNECTED;
846
+ this.status = (0, $db7c797e63383364$export$7516420eb880ab68).DISCONNECTED;
874
847
  // Write a log message.
875
- (0, $ef5ba40c8abe5a13$export$2e2bcd8739ae039).network(`Disconnected from '${this.hostIdentifier}'.`);
848
+ (0, $623a31cc1663a627$export$2e2bcd8739ae039).network(`Disconnected from '${this.hostIdentifier}'.`);
876
849
  } else {
877
850
  // If this is for an established connection..
878
- if (this.status === (0, $a58372b18a18806e$export$7516420eb880ab68).CONNECTED) // Write a notification to the logs.
879
- (0, $ef5ba40c8abe5a13$export$2e2bcd8739ae039).errors(`Connection with '${this.hostIdentifier}' was closed, trying to reconnect in ${this.reconnectInterval / 1000} seconds.`);
851
+ if (this.status === (0, $db7c797e63383364$export$7516420eb880ab68).CONNECTED) // Write a notification to the logs.
852
+ (0, $623a31cc1663a627$export$2e2bcd8739ae039).errors(`Connection with '${this.hostIdentifier}' was closed, trying to reconnect in ${this.reconnectInterval / 1000} seconds.`);
880
853
  // Mark the connection as disconnected for now..
881
- this.status = (0, $a58372b18a18806e$export$7516420eb880ab68).DISCONNECTED;
854
+ this.status = (0, $db7c797e63383364$export$7516420eb880ab68).DISCONNECTED;
882
855
  // If we don't have a pending reconnection timer..
883
856
  if (!this.timers.reconnect) // Attempt to reconnect after one keep-alive duration.
884
857
  this.timers.reconnect = setTimeout(this.reconnect.bind(this), this.reconnectInterval);
@@ -895,21 +868,21 @@ class $ea64e414b68fe23b$export$25b4633f61498e1 extends (0, $4QiMX$EventEmitter)
895
868
  return;
896
869
  // If the DNS lookup failed.
897
870
  if (error.code === "EAI_AGAIN") {
898
- (0, $ef5ba40c8abe5a13$export$2e2bcd8739ae039).errors(`Failed to look up DNS records for '${this.host}'.`);
871
+ (0, $623a31cc1663a627$export$2e2bcd8739ae039).errors(`Failed to look up DNS records for '${this.host}'.`);
899
872
  return;
900
873
  }
901
874
  // If the connection timed out..
902
875
  if (error.code === "ETIMEDOUT") {
903
876
  // Log the provided timeout message.
904
- (0, $ef5ba40c8abe5a13$export$2e2bcd8739ae039).errors(error.message);
877
+ (0, $623a31cc1663a627$export$2e2bcd8739ae039).errors(error.message);
905
878
  return;
906
879
  }
907
880
  // Log unknown error
908
- (0, $ef5ba40c8abe5a13$export$2e2bcd8739ae039).errors(`Unknown network error ('${this.hostIdentifier}'): `, error);
881
+ (0, $623a31cc1663a627$export$2e2bcd8739ae039).errors(`Unknown network error ('${this.hostIdentifier}'): `, error);
909
882
  }
910
883
  }
911
884
  var // Export the connection.
912
- $1326c18f93f95fee$export$2e2bcd8739ae039 = $1326c18f93f95fee$var$ElectrumConnection;
885
+ $ff134c9a9e1f7361$export$2e2bcd8739ae039 = $ff134c9a9e1f7361$var$ElectrumConnection;
913
886
 
914
887
 
915
888
 
@@ -917,16 +890,16 @@ $1326c18f93f95fee$export$2e2bcd8739ae039 = $1326c18f93f95fee$var$ElectrumConnect
917
890
 
918
891
 
919
892
  // Acceptable parameter types for RPC messages
920
- const $7c0fb93e8eea922a$export$d73a2e87a509880 = function(message) {
893
+ const $abcb763a48577a1e$export$d73a2e87a509880 = function(message) {
921
894
  return "id" in message && "error" in message;
922
895
  };
923
- const $7c0fb93e8eea922a$export$81276773828ff315 = function(message) {
896
+ const $abcb763a48577a1e$export$81276773828ff315 = function(message) {
924
897
  return "id" in message && "result" in message;
925
898
  };
926
- const $7c0fb93e8eea922a$export$280de919a0cf6928 = function(message) {
899
+ const $abcb763a48577a1e$export$280de919a0cf6928 = function(message) {
927
900
  return !("id" in message) && "method" in message;
928
901
  };
929
- const $7c0fb93e8eea922a$export$94e3360fcddccc76 = function(message) {
902
+ const $abcb763a48577a1e$export$94e3360fcddccc76 = function(message) {
930
903
  return "id" in message && "method" in message;
931
904
  };
932
905
 
@@ -946,7 +919,7 @@ const $7c0fb93e8eea922a$export$94e3360fcddccc76 = function(message) {
946
919
  * @event ElectrumClient#notification
947
920
  */ /**
948
921
  * High-level Electrum client that lets applications send requests and subscribe to notification events from a server.
949
- */ class $620a18299ef8d6fd$var$ElectrumClient extends (0, $4QiMX$EventEmitter) {
922
+ */ class $558b46d3f899ced5$var$ElectrumClient extends (0, $dvphU$EventEmitter) {
950
923
  /**
951
924
  * Initializes an Electrum client.
952
925
  *
@@ -961,7 +934,7 @@ const $7c0fb93e8eea922a$export$94e3360fcddccc76 = function(message) {
961
934
  * @param {boolean} useBigInt whether to use bigint for numbers in json response.
962
935
  *
963
936
  * @throws {Error} if `version` is not a valid version string.
964
- */ constructor(application, version, host, port = (0, $5abc8fb342687c03$export$f019be48b3aacb1a).PORT, scheme = (0, $5abc8fb342687c03$export$f019be48b3aacb1a).TRANSPORT_SCHEME, timeout = (0, $5abc8fb342687c03$export$f019be48b3aacb1a).TIMEOUT, pingInterval = (0, $5abc8fb342687c03$export$f019be48b3aacb1a).PING_INTERVAL, reconnectInterval = (0, $5abc8fb342687c03$export$f019be48b3aacb1a).RECONNECT, useBigInt = (0, $5abc8fb342687c03$export$f019be48b3aacb1a).USE_BIG_INT){
937
+ */ constructor(application, version, host, port = (0, $d801b1f9b7fc3074$export$f019be48b3aacb1a).PORT, scheme = (0, $d801b1f9b7fc3074$export$f019be48b3aacb1a).TRANSPORT_SCHEME, timeout = (0, $d801b1f9b7fc3074$export$f019be48b3aacb1a).TIMEOUT, pingInterval = (0, $d801b1f9b7fc3074$export$f019be48b3aacb1a).PING_INTERVAL, reconnectInterval = (0, $d801b1f9b7fc3074$export$f019be48b3aacb1a).RECONNECT, useBigInt = (0, $d801b1f9b7fc3074$export$f019be48b3aacb1a).USE_BIG_INT){
965
938
  // Initialize the event emitter.
966
939
  super();
967
940
  this.application = application;
@@ -976,9 +949,9 @@ const $7c0fb93e8eea922a$export$94e3360fcddccc76 = function(message) {
976
949
  this.subscriptionMethods = {};
977
950
  this.requestId = 0;
978
951
  this.requestResolvers = {};
979
- this.connectionLock = new (0, $4QiMX$Mutex)();
952
+ this.connectionLock = new (0, $dvphU$Mutex)();
980
953
  // Set up a connection to an electrum server.
981
- this.connection = new (0, $1326c18f93f95fee$export$2e2bcd8739ae039)(application, version, host, port, scheme, timeout, pingInterval, reconnectInterval, useBigInt);
954
+ this.connection = new (0, $ff134c9a9e1f7361$export$2e2bcd8739ae039)(application, version, host, port, scheme, timeout, pingInterval, reconnectInterval, useBigInt);
982
955
  }
983
956
  /**
984
957
  * Connects to the remote server.
@@ -990,7 +963,7 @@ const $7c0fb93e8eea922a$export$94e3360fcddccc76 = function(message) {
990
963
  const unlock = await this.connectionLock.acquire();
991
964
  try {
992
965
  // If we are already connected, do not attempt to connect again.
993
- if (this.connection.status === (0, $a58372b18a18806e$export$7516420eb880ab68).CONNECTED) return;
966
+ if (this.connection.status === (0, $db7c797e63383364$export$7516420eb880ab68).CONNECTED) return;
994
967
  // Listen for parsed statements.
995
968
  this.connection.on("statement", this.response.bind(this));
996
969
  // Hook up resubscription on connection.
@@ -1047,14 +1020,14 @@ const $7c0fb93e8eea922a$export$94e3360fcddccc76 = function(message) {
1047
1020
  * @returns a promise that resolves with the result of the method or an Error.
1048
1021
  */ async request(method, ...parameters) {
1049
1022
  // If we are not connected to a server..
1050
- if (this.connection.status !== (0, $a58372b18a18806e$export$7516420eb880ab68).CONNECTED) // Reject the request with a disconnected error message.
1023
+ if (this.connection.status !== (0, $db7c797e63383364$export$7516420eb880ab68).CONNECTED) // Reject the request with a disconnected error message.
1051
1024
  throw new Error(`Unable to send request to a disconnected server '${this.connection.host}'.`);
1052
1025
  // Increase the request ID by one.
1053
1026
  this.requestId += 1;
1054
1027
  // Store a copy of the request id.
1055
1028
  const id = this.requestId;
1056
1029
  // Format the arguments as an electrum request object.
1057
- const message = (0, $c78f59d21170b7a6$export$2e2bcd8739ae039).buildRequestObject(method, parameters, id);
1030
+ const message = (0, $24139611f53a54b8$export$2e2bcd8739ae039).buildRequestObject(method, parameters, id);
1058
1031
  // Define a function to wrap the request in a promise.
1059
1032
  const requestResolver = (resolve)=>{
1060
1033
  // Add a request resolver for this promise to the list of requests.
@@ -1069,7 +1042,7 @@ const $7c0fb93e8eea922a$export$94e3360fcddccc76 = function(message) {
1069
1042
  this.connection.send(message);
1070
1043
  };
1071
1044
  // Write a log message.
1072
- (0, $ef5ba40c8abe5a13$export$2e2bcd8739ae039).network(`Sending request '${method}' to '${this.connection.host}'`);
1045
+ (0, $623a31cc1663a627$export$2e2bcd8739ae039).network(`Sending request '${method}' to '${this.connection.host}'`);
1073
1046
  // return a promise to deliver results later.
1074
1047
  return new Promise(requestResolver);
1075
1048
  }
@@ -1114,7 +1087,7 @@ const $7c0fb93e8eea922a$export$94e3360fcddccc76 = function(message) {
1114
1087
  * @returns a promise resolving when the subscription is removed.
1115
1088
  */ async unsubscribe(method, ...parameters) {
1116
1089
  // Throw an error if the client is disconnected.
1117
- if (this.connection.status !== (0, $a58372b18a18806e$export$7516420eb880ab68).CONNECTED) throw new Error(`Unable to send unsubscribe request to a disconnected server '${this.connection.host}'.`);
1090
+ if (this.connection.status !== (0, $db7c797e63383364$export$7516420eb880ab68).CONNECTED) throw new Error(`Unable to send unsubscribe request to a disconnected server '${this.connection.host}'.`);
1118
1091
  // If this method has no subscriptions..
1119
1092
  if (!this.subscriptionMethods[method]) // Reject this promise with an explanation.
1120
1093
  throw new Error(`Cannot unsubscribe from '${method}' since the method has no subscriptions.`);
@@ -1129,7 +1102,7 @@ const $7c0fb93e8eea922a$export$94e3360fcddccc76 = function(message) {
1129
1102
  // NOTE: As a convenience we allow users to define the method as the subscribe or unsubscribe version.
1130
1103
  await this.request(method.replace(".subscribe", ".unsubscribe"), ...parameters);
1131
1104
  // Write a log message.
1132
- (0, $ef5ba40c8abe5a13$export$2e2bcd8739ae039).client(`Unsubscribed from '${String(method)}' for the '${subscriptionParameters}' parameters.`);
1105
+ (0, $623a31cc1663a627$export$2e2bcd8739ae039).client(`Unsubscribed from '${String(method)}' for the '${subscriptionParameters}' parameters.`);
1133
1106
  }
1134
1107
  /**
1135
1108
  * Restores existing subscriptions without updating status or triggering manual callbacks.
@@ -1141,7 +1114,7 @@ const $7c0fb93e8eea922a$export$94e3360fcddccc76 = function(message) {
1141
1114
  * @ignore
1142
1115
  */ async resubscribeOnConnect() {
1143
1116
  // Write a log message.
1144
- (0, $ef5ba40c8abe5a13$export$2e2bcd8739ae039).client(`Connected to '${this.connection.hostIdentifier}'.`);
1117
+ (0, $623a31cc1663a627$export$2e2bcd8739ae039).client(`Connected to '${this.connection.hostIdentifier}'.`);
1145
1118
  // Initialize an empty list of resubscription promises.
1146
1119
  const resubscriptionPromises = [];
1147
1120
  // For each method we have a subscription for..
@@ -1157,7 +1130,7 @@ const $7c0fb93e8eea922a$export$94e3360fcddccc76 = function(message) {
1157
1130
  await Promise.all(resubscriptionPromises);
1158
1131
  }
1159
1132
  // Write a log message if there was any subscriptions to restore.
1160
- if (resubscriptionPromises.length > 0) (0, $ef5ba40c8abe5a13$export$2e2bcd8739ae039).client(`Restored ${resubscriptionPromises.length} previous subscriptions for '${this.connection.hostIdentifier}'`);
1133
+ if (resubscriptionPromises.length > 0) (0, $623a31cc1663a627$export$2e2bcd8739ae039).client(`Restored ${resubscriptionPromises.length} previous subscriptions for '${this.connection.hostIdentifier}'`);
1161
1134
  }
1162
1135
  /**
1163
1136
  * Parser messages from the remote server to resolve request promises and emit subscription events.
@@ -1168,9 +1141,9 @@ const $7c0fb93e8eea922a$export$94e3360fcddccc76 = function(message) {
1168
1141
  * @ignore
1169
1142
  */ response(message) {
1170
1143
  // If the received message is a notification, we forward it to all event listeners
1171
- if ((0, $7c0fb93e8eea922a$export$280de919a0cf6928)(message)) {
1144
+ if ((0, $abcb763a48577a1e$export$280de919a0cf6928)(message)) {
1172
1145
  // Write a log message.
1173
- (0, $ef5ba40c8abe5a13$export$2e2bcd8739ae039).client(`Received notification for '${message.method}' from '${this.connection.host}'`);
1146
+ (0, $623a31cc1663a627$export$2e2bcd8739ae039).client(`Received notification for '${message.method}' from '${this.connection.host}'`);
1174
1147
  // Forward the message content to all event listeners.
1175
1148
  this.emit("notification", message);
1176
1149
  // Return since it does not have an associated request resolver
@@ -1187,7 +1160,7 @@ const $7c0fb93e8eea922a$export$94e3360fcddccc76 = function(message) {
1187
1160
  // Remove the promise from the request list.
1188
1161
  delete this.requestResolvers[message.id];
1189
1162
  // If the message contains an error..
1190
- if ((0, $7c0fb93e8eea922a$export$d73a2e87a509880)(message)) // Forward the message error to the request resolver and omit the `result` parameter.
1163
+ if ((0, $abcb763a48577a1e$export$d73a2e87a509880)(message)) // Forward the message error to the request resolver and omit the `result` parameter.
1191
1164
  requestResolver(new Error(message.error.message));
1192
1165
  else // Forward the message content to the request resolver and omit the `error` parameter
1193
1166
  // (by setting it to undefined).
@@ -1213,7 +1186,7 @@ const $7c0fb93e8eea922a$export$94e3360fcddccc76 = function(message) {
1213
1186
  }
1214
1187
  }
1215
1188
  var // Export the client.
1216
- $620a18299ef8d6fd$export$2e2bcd8739ae039 = $620a18299ef8d6fd$var$ElectrumClient;
1189
+ $558b46d3f899ced5$export$2e2bcd8739ae039 = $558b46d3f899ced5$var$ElectrumClient;
1217
1190
 
1218
1191
 
1219
1192
 
@@ -1221,5 +1194,5 @@ $620a18299ef8d6fd$export$2e2bcd8739ae039 = $620a18299ef8d6fd$var$ElectrumClient;
1221
1194
 
1222
1195
 
1223
1196
 
1224
- export {$620a18299ef8d6fd$export$2e2bcd8739ae039 as ElectrumClient, $a192ea5a4eec42d4$export$e1f38ab2b4ebdde6 as isVersionRejected, $a192ea5a4eec42d4$export$9598f0c76aa41d73 as isVersionNegotiated, $5abc8fb342687c03$export$d048df559e6d3842 as ElectrumTransport, $5abc8fb342687c03$export$f019be48b3aacb1a as DefaultParameters, $a58372b18a18806e$export$161fe3707f756bf9 as ClusterOrder, $a58372b18a18806e$export$436a960acc41e848 as ClusterDistribution, $a58372b18a18806e$export$c66b56bc0ff967ca as ClusterStatus, $a58372b18a18806e$export$c4f81c6d30ca200f as ClientState, $a58372b18a18806e$export$7516420eb880ab68 as ConnectionStatus};
1197
+ export {$558b46d3f899ced5$export$2e2bcd8739ae039 as ElectrumClient, $e83d2e7688025acd$export$e1f38ab2b4ebdde6 as isVersionRejected, $e83d2e7688025acd$export$9598f0c76aa41d73 as isVersionNegotiated, $d801b1f9b7fc3074$export$d048df559e6d3842 as ElectrumTransport, $d801b1f9b7fc3074$export$f019be48b3aacb1a as DefaultParameters, $db7c797e63383364$export$c4f81c6d30ca200f as ClientState, $db7c797e63383364$export$7516420eb880ab68 as ConnectionStatus};
1225
1198
  //# sourceMappingURL=index.mjs.map