@electrum-cash/network 4.0.0-development.6392223875 → 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/README.md +17 -21
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +123 -123
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -5
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {EventEmitter as $
|
|
2
|
-
import {Mutex as $
|
|
3
|
-
import $
|
|
4
|
-
import {parse as $
|
|
5
|
-
import {connect as $
|
|
6
|
-
import {isIP as $
|
|
7
|
-
import {WebSocket as $
|
|
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,21 +12,21 @@ function $parcel$export(e, n, v, s) {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
// Create the debug logs.
|
|
15
|
-
const $
|
|
16
|
-
client: (0, $
|
|
17
|
-
errors: (0, $
|
|
18
|
-
warning: (0, $
|
|
19
|
-
network: (0, $
|
|
20
|
-
ping: (0, $
|
|
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 ")
|
|
21
21
|
};
|
|
22
22
|
// Set log colors.
|
|
23
|
-
$
|
|
24
|
-
$
|
|
25
|
-
$
|
|
26
|
-
$
|
|
27
|
-
$
|
|
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";
|
|
28
28
|
var // Export the logs.
|
|
29
|
-
$
|
|
29
|
+
$623a31cc1663a627$export$2e2bcd8739ae039 = $623a31cc1663a627$var$debug;
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
|
|
@@ -34,7 +34,7 @@ $ef5ba40c8abe5a13$export$2e2bcd8739ae039 = $ef5ba40c8abe5a13$var$debug;
|
|
|
34
34
|
* Grouping of utilities that simplifies implementation of the Electrum protocol.
|
|
35
35
|
*
|
|
36
36
|
* @ignore
|
|
37
|
-
*/ class $
|
|
37
|
+
*/ class $24139611f53a54b8$var$ElectrumProtocol {
|
|
38
38
|
/**
|
|
39
39
|
* Helper function that builds an Electrum request object.
|
|
40
40
|
*
|
|
@@ -70,26 +70,26 @@ $ef5ba40c8abe5a13$export$2e2bcd8739ae039 = $ef5ba40c8abe5a13$var$debug;
|
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
var // export the protocol.
|
|
73
|
-
$
|
|
73
|
+
$24139611f53a54b8$export$2e2bcd8739ae039 = $24139611f53a54b8$var$ElectrumProtocol;
|
|
74
74
|
|
|
75
75
|
|
|
76
|
-
var $
|
|
76
|
+
var $e83d2e7688025acd$exports = {};
|
|
77
77
|
|
|
78
|
-
$parcel$export($
|
|
79
|
-
$parcel$export($
|
|
80
|
-
const $
|
|
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) {
|
|
81
81
|
return "error" in object;
|
|
82
82
|
};
|
|
83
|
-
const $
|
|
83
|
+
const $e83d2e7688025acd$export$9598f0c76aa41d73 = function(object) {
|
|
84
84
|
return "software" in object && "protocol" in object;
|
|
85
85
|
};
|
|
86
86
|
|
|
87
87
|
|
|
88
|
-
var $
|
|
88
|
+
var $d801b1f9b7fc3074$exports = {};
|
|
89
89
|
|
|
90
|
-
$parcel$export($
|
|
91
|
-
$parcel$export($
|
|
92
|
-
const $
|
|
90
|
+
$parcel$export($d801b1f9b7fc3074$exports, "ElectrumTransport", () => $d801b1f9b7fc3074$export$d048df559e6d3842);
|
|
91
|
+
$parcel$export($d801b1f9b7fc3074$exports, "DefaultParameters", () => $d801b1f9b7fc3074$export$f019be48b3aacb1a);
|
|
92
|
+
const $d801b1f9b7fc3074$export$d048df559e6d3842 = {
|
|
93
93
|
TCP: {
|
|
94
94
|
Port: 50001,
|
|
95
95
|
Scheme: "tcp"
|
|
@@ -107,11 +107,11 @@ const $5abc8fb342687c03$export$d048df559e6d3842 = {
|
|
|
107
107
|
Scheme: "wss"
|
|
108
108
|
}
|
|
109
109
|
};
|
|
110
|
-
const $
|
|
110
|
+
const $d801b1f9b7fc3074$export$f019be48b3aacb1a = {
|
|
111
111
|
// Port number for TCP TLS connections
|
|
112
|
-
PORT: $
|
|
112
|
+
PORT: $d801b1f9b7fc3074$export$d048df559e6d3842.TCP_TLS.Port,
|
|
113
113
|
// Transport to connect to the Electrum server
|
|
114
|
-
TRANSPORT_SCHEME: $
|
|
114
|
+
TRANSPORT_SCHEME: $d801b1f9b7fc3074$export$d048df559e6d3842.TCP_TLS.Scheme,
|
|
115
115
|
// How long to wait before attempting to reconnect, in milliseconds.
|
|
116
116
|
RECONNECT: 5000,
|
|
117
117
|
// How long to wait for network operations before following up, in milliseconds.
|
|
@@ -131,7 +131,7 @@ const $5abc8fb342687c03$export$f019be48b3aacb1a = {
|
|
|
131
131
|
|
|
132
132
|
|
|
133
133
|
|
|
134
|
-
class $
|
|
134
|
+
class $0a4cf22b9d6c493c$export$22c0ca2c816c3e08 extends (0, $dvphU$EventEmitter) {
|
|
135
135
|
/**
|
|
136
136
|
* Connect to host:port using the specified transport
|
|
137
137
|
*
|
|
@@ -150,39 +150,39 @@ class $ea64e414b68fe23b$export$22c0ca2c816c3e08 extends (0, $4QiMX$EventEmitter)
|
|
|
150
150
|
this.once("connect", this.clearDisconnectTimerOnTimeout);
|
|
151
151
|
// Define how to refer to the connection scheme in debug output.
|
|
152
152
|
const socketTypes = {
|
|
153
|
-
[(0, $
|
|
154
|
-
[(0, $
|
|
153
|
+
[(0, $d801b1f9b7fc3074$export$d048df559e6d3842).TCP.Scheme]: "a TCP Socket",
|
|
154
|
+
[(0, $d801b1f9b7fc3074$export$d048df559e6d3842).TCP_TLS.Scheme]: "an encrypted TCP socket"
|
|
155
155
|
};
|
|
156
156
|
// Log that we are trying to establish a connection.
|
|
157
|
-
(0, $
|
|
158
|
-
if (scheme !== (0, $
|
|
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
|
|
159
159
|
throw new Error("Incorrect transport specified");
|
|
160
|
-
if (scheme === (0, $
|
|
160
|
+
if (scheme === (0, $d801b1f9b7fc3074$export$d048df559e6d3842).TCP_TLS.Scheme) {
|
|
161
161
|
// Initialize connection options.
|
|
162
162
|
const connectionOptions = {
|
|
163
163
|
rejectUnauthorized: false
|
|
164
164
|
};
|
|
165
165
|
// If the hostname is not an IP address..
|
|
166
|
-
if (!$
|
|
166
|
+
if (!$dvphU$isIP(host)) // Set the servername option which enables support for SNI.
|
|
167
167
|
// NOTE: SNI enables a server that hosts multiple domains to provide the appropriate TLS certificate.
|
|
168
168
|
connectionOptions.serverName = host;
|
|
169
169
|
// Initialize the socket (allowing self-signed certificates).
|
|
170
|
-
this.tcpSocket = $
|
|
170
|
+
this.tcpSocket = $dvphU$connect(port, host, connectionOptions);
|
|
171
171
|
// Add a 'secureConnect' listener that checks the authorization status of
|
|
172
172
|
// the socket, and logs a warning when it uses a self signed certificate.
|
|
173
173
|
this.tcpSocket.once("secureConnect", ()=>{
|
|
174
174
|
// Cannot happen, since this event callback *only* exists on TLSSocket
|
|
175
|
-
if (!(this.tcpSocket instanceof $
|
|
175
|
+
if (!(this.tcpSocket instanceof $dvphU$TLSSocket)) return;
|
|
176
176
|
// Force cast authorizationError from Error to string (through unknown)
|
|
177
177
|
// because it is incorrectly typed as an Error
|
|
178
178
|
const authorizationError = this.tcpSocket.authorizationError;
|
|
179
|
-
if (authorizationError === "DEPTH_ZERO_SELF_SIGNED_CERT") (0, $
|
|
179
|
+
if (authorizationError === "DEPTH_ZERO_SELF_SIGNED_CERT") (0, $623a31cc1663a627$export$2e2bcd8739ae039).warning(`Connection to ${host}:${port} uses a self-signed certificate`);
|
|
180
180
|
});
|
|
181
181
|
// Trigger successful connection events.
|
|
182
182
|
this.tcpSocket.on("secureConnect", this.onConnect.bind(this, socketTypes[scheme], host, port));
|
|
183
183
|
} else {
|
|
184
184
|
// Initialize the socket.
|
|
185
|
-
this.tcpSocket = $
|
|
185
|
+
this.tcpSocket = $dvphU$connect1({
|
|
186
186
|
host: host,
|
|
187
187
|
port: port
|
|
188
188
|
});
|
|
@@ -208,7 +208,7 @@ class $ea64e414b68fe23b$export$22c0ca2c816c3e08 extends (0, $4QiMX$EventEmitter)
|
|
|
208
208
|
// If the onConnect function has already run, do not execute it again.
|
|
209
209
|
if (this.onConnectHasRun) return;
|
|
210
210
|
// Log that the connection has been established.
|
|
211
|
-
(0, $
|
|
211
|
+
(0, $623a31cc1663a627$export$2e2bcd8739ae039).network(`Established ${connectionType} connection with '${host}:${port}'.`);
|
|
212
212
|
// Forward the socket events
|
|
213
213
|
this.tcpSocket.addListener("close", this.eventForwarders.disconnect);
|
|
214
214
|
this.tcpSocket.addListener("data", this.eventForwarders.tcpData);
|
|
@@ -292,7 +292,7 @@ class $ea64e414b68fe23b$export$22c0ca2c816c3e08 extends (0, $4QiMX$EventEmitter)
|
|
|
292
292
|
};
|
|
293
293
|
}
|
|
294
294
|
}
|
|
295
|
-
class $
|
|
295
|
+
class $0a4cf22b9d6c493c$export$25b4633f61498e1 extends (0, $dvphU$EventEmitter) {
|
|
296
296
|
/**
|
|
297
297
|
* Connect to host:port using the specified transport
|
|
298
298
|
*
|
|
@@ -311,18 +311,18 @@ class $ea64e414b68fe23b$export$25b4633f61498e1 extends (0, $4QiMX$EventEmitter)
|
|
|
311
311
|
this.once("connect", this.clearDisconnectTimerOnTimeout);
|
|
312
312
|
// Define how to refer to the connection scheme in debug output.
|
|
313
313
|
const socketTypes = {
|
|
314
|
-
[(0, $
|
|
315
|
-
[(0, $
|
|
314
|
+
[(0, $d801b1f9b7fc3074$export$d048df559e6d3842).WS.Scheme]: "a WebSocket",
|
|
315
|
+
[(0, $d801b1f9b7fc3074$export$d048df559e6d3842).WSS.Scheme]: "an encrypted WebSocket"
|
|
316
316
|
};
|
|
317
317
|
// Log that we are trying to establish a connection.
|
|
318
|
-
(0, $
|
|
319
|
-
if (scheme !== (0, $
|
|
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
|
|
320
320
|
throw new Error("Incorrect transport specified");
|
|
321
|
-
if (scheme === (0, $
|
|
321
|
+
if (scheme === (0, $d801b1f9b7fc3074$export$d048df559e6d3842).WSS.Scheme) // Initialize this.webSocket (rejecting self-signed certificates).
|
|
322
322
|
// We reject self-signed certificates to match functionality of browsers.
|
|
323
|
-
this.webSocket = new (0, $
|
|
323
|
+
this.webSocket = new (0, $dvphU$WebSocket)(`wss://${host}:${port}`);
|
|
324
324
|
else // Initialize this.webSocket.
|
|
325
|
-
this.webSocket = new (0, $
|
|
325
|
+
this.webSocket = new (0, $dvphU$WebSocket)(`ws://${host}:${port}`);
|
|
326
326
|
// Trigger successful connection events.
|
|
327
327
|
this.webSocket.addEventListener("open", this.onConnect.bind(this, socketTypes[scheme], host, port));
|
|
328
328
|
// Forward the encountered errors.
|
|
@@ -338,7 +338,7 @@ class $ea64e414b68fe23b$export$25b4633f61498e1 extends (0, $4QiMX$EventEmitter)
|
|
|
338
338
|
// If the onConnect function has already run, do not execute it again.
|
|
339
339
|
if (this.onConnectHasRun) return;
|
|
340
340
|
// Log that the connection has been established.
|
|
341
|
-
(0, $
|
|
341
|
+
(0, $623a31cc1663a627$export$2e2bcd8739ae039).network(`Established ${connectionType} connection with '${host}:${port}'.`);
|
|
342
342
|
// Forward the socket events
|
|
343
343
|
this.webSocket.addEventListener("close", this.eventForwarders.disconnect);
|
|
344
344
|
this.webSocket.addEventListener("message", this.eventForwarders.wsData);
|
|
@@ -431,29 +431,29 @@ class $ea64e414b68fe23b$export$25b4633f61498e1 extends (0, $4QiMX$EventEmitter)
|
|
|
431
431
|
}
|
|
432
432
|
|
|
433
433
|
|
|
434
|
-
var $
|
|
434
|
+
var $db7c797e63383364$exports = {};
|
|
435
435
|
|
|
436
|
-
$parcel$export($
|
|
437
|
-
$parcel$export($
|
|
436
|
+
$parcel$export($db7c797e63383364$exports, "ClientState", () => $db7c797e63383364$export$c4f81c6d30ca200f);
|
|
437
|
+
$parcel$export($db7c797e63383364$exports, "ConnectionStatus", () => $db7c797e63383364$export$7516420eb880ab68);
|
|
438
438
|
// Disable indent rule for this file because it is broken (https://github.com/typescript-eslint/typescript-eslint/issues/1824)
|
|
439
439
|
/* eslint-disable @typescript-eslint/indent */ /**
|
|
440
440
|
* Enum that denotes the availability of an ElectrumClient.
|
|
441
441
|
* @enum {number}
|
|
442
442
|
* @property {0} UNAVAILABLE The client is currently not available.
|
|
443
443
|
* @property {1} AVAILABLE The client is available for use.
|
|
444
|
-
*/ var $
|
|
444
|
+
*/ var $db7c797e63383364$export$c4f81c6d30ca200f;
|
|
445
445
|
(function(ClientState) {
|
|
446
446
|
ClientState[ClientState["UNAVAILABLE"] = 0] = "UNAVAILABLE";
|
|
447
447
|
ClientState[ClientState["AVAILABLE"] = 1] = "AVAILABLE";
|
|
448
|
-
})($
|
|
449
|
-
var $
|
|
448
|
+
})($db7c797e63383364$export$c4f81c6d30ca200f || ($db7c797e63383364$export$c4f81c6d30ca200f = {}));
|
|
449
|
+
var $db7c797e63383364$export$7516420eb880ab68;
|
|
450
450
|
(function(ConnectionStatus) {
|
|
451
451
|
ConnectionStatus[ConnectionStatus["DISCONNECTED"] = 0] = "DISCONNECTED";
|
|
452
452
|
ConnectionStatus[ConnectionStatus["CONNECTED"] = 1] = "CONNECTED";
|
|
453
453
|
ConnectionStatus[ConnectionStatus["DISCONNECTING"] = 2] = "DISCONNECTING";
|
|
454
454
|
ConnectionStatus[ConnectionStatus["CONNECTING"] = 3] = "CONNECTING";
|
|
455
455
|
ConnectionStatus[ConnectionStatus["RECONNECTING"] = 4] = "RECONNECTING";
|
|
456
|
-
})($
|
|
456
|
+
})($db7c797e63383364$export$7516420eb880ab68 || ($db7c797e63383364$export$7516420eb880ab68 = {}));
|
|
457
457
|
|
|
458
458
|
|
|
459
459
|
|
|
@@ -461,7 +461,7 @@ var $a58372b18a18806e$export$7516420eb880ab68;
|
|
|
461
461
|
* Wrapper around TLS/WSS sockets that gracefully separates a network stream into Electrum protocol messages.
|
|
462
462
|
*
|
|
463
463
|
* @ignore
|
|
464
|
-
*/ class $
|
|
464
|
+
*/ class $ff134c9a9e1f7361$var$ElectrumConnection extends (0, $dvphU$EventEmitter) {
|
|
465
465
|
/**
|
|
466
466
|
* Sets up network configuration for an Electrum client connection.
|
|
467
467
|
*
|
|
@@ -476,7 +476,7 @@ var $a58372b18a18806e$export$7516420eb880ab68;
|
|
|
476
476
|
* @param {boolean} useBigInt whether to use bigint for numbers in json response.
|
|
477
477
|
*
|
|
478
478
|
* @throws {Error} if `version` is not a valid version string.
|
|
479
|
-
*/ constructor(application, version, host, port = (0, $
|
|
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){
|
|
480
480
|
// Initialize the event emitter.
|
|
481
481
|
super();
|
|
482
482
|
this.application = application;
|
|
@@ -488,12 +488,12 @@ var $a58372b18a18806e$export$7516420eb880ab68;
|
|
|
488
488
|
this.pingInterval = pingInterval;
|
|
489
489
|
this.reconnectInterval = reconnectInterval;
|
|
490
490
|
this.useBigInt = useBigInt;
|
|
491
|
-
this.status = (0, $
|
|
491
|
+
this.status = (0, $db7c797e63383364$export$7516420eb880ab68).DISCONNECTED;
|
|
492
492
|
this.timers = {};
|
|
493
493
|
this.verifications = [];
|
|
494
494
|
this.messageBuffer = "";
|
|
495
495
|
// Check if the provided version is a valid version number.
|
|
496
|
-
if (!(0, $
|
|
496
|
+
if (!(0, $24139611f53a54b8$export$2e2bcd8739ae039).versionRegexp.test(version)) // Throw an error since the version number was not valid.
|
|
497
497
|
throw new Error(`Provided version string (${version}) is not a valid protocol version number.`);
|
|
498
498
|
// Create an initial network socket.
|
|
499
499
|
this.createSocket();
|
|
@@ -508,10 +508,10 @@ var $a58372b18a18806e$export$7516420eb880ab68;
|
|
|
508
508
|
/**
|
|
509
509
|
* Create and configures a fresh socket and attaches all relevant listeners.
|
|
510
510
|
*/ createSocket() {
|
|
511
|
-
if (this.scheme === (0, $
|
|
512
|
-
this.socket = new (0, $
|
|
513
|
-
else if (this.scheme === (0, $
|
|
514
|
-
this.socket = new (0, $
|
|
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)();
|
|
515
515
|
else // Throw an error if an incorrect transport is specified
|
|
516
516
|
throw new Error(`Provided transport (${this.scheme}) is not a valid ElectrumTransport`);
|
|
517
517
|
// Set up handlers for connection and disconnection.
|
|
@@ -541,15 +541,15 @@ var $a58372b18a18806e$export$7516420eb880ab68;
|
|
|
541
541
|
// Add the message to the current message buffer.
|
|
542
542
|
this.messageBuffer += data;
|
|
543
543
|
// Check if the new message buffer contains the statement delimiter.
|
|
544
|
-
while(this.messageBuffer.includes((0, $
|
|
544
|
+
while(this.messageBuffer.includes((0, $24139611f53a54b8$export$2e2bcd8739ae039).statementDelimiter)){
|
|
545
545
|
// Split message buffer into statements.
|
|
546
|
-
const statementParts = this.messageBuffer.split((0, $
|
|
546
|
+
const statementParts = this.messageBuffer.split((0, $24139611f53a54b8$export$2e2bcd8739ae039).statementDelimiter);
|
|
547
547
|
// For as long as we still have statements to parse..
|
|
548
548
|
while(statementParts.length > 1){
|
|
549
549
|
// Move the first statement to its own variable.
|
|
550
550
|
const currentStatementList = String(statementParts.shift());
|
|
551
551
|
// Parse the statement into an object or list of objects.
|
|
552
|
-
let statementList = (0, $
|
|
552
|
+
let statementList = (0, $dvphU$parse)(currentStatementList, null, this.useBigInt ? (0, $dvphU$parseNumberAndBigInt) : parseFloat);
|
|
553
553
|
// Wrap the statement in an array if it is not already a batched statement list.
|
|
554
554
|
if (!Array.isArray(statementList)) statementList = [
|
|
555
555
|
statementList
|
|
@@ -594,9 +594,9 @@ var $a58372b18a18806e$export$7516420eb880ab68;
|
|
|
594
594
|
* part of the message is queued in the user memory
|
|
595
595
|
*/ ping() {
|
|
596
596
|
// Write a log message.
|
|
597
|
-
(0, $
|
|
597
|
+
(0, $623a31cc1663a627$export$2e2bcd8739ae039).ping(`Sending keep-alive ping to '${this.hostIdentifier}'`);
|
|
598
598
|
// Craft a keep-alive message.
|
|
599
|
-
const message = (0, $
|
|
599
|
+
const message = (0, $24139611f53a54b8$export$2e2bcd8739ae039).buildRequestObject("server.ping", [], "keepAlive");
|
|
600
600
|
// Send the keep-alive message.
|
|
601
601
|
const status = this.send(message);
|
|
602
602
|
// Return the ping status.
|
|
@@ -609,14 +609,14 @@ var $a58372b18a18806e$export$7516420eb880ab68;
|
|
|
609
609
|
* @returns a promise resolving when the connection is established
|
|
610
610
|
*/ async connect() {
|
|
611
611
|
// If we are already connected return true.
|
|
612
|
-
if (this.status === (0, $
|
|
612
|
+
if (this.status === (0, $db7c797e63383364$export$7516420eb880ab68).CONNECTED) return;
|
|
613
613
|
// Indicate that the connection is connecting
|
|
614
|
-
this.status = (0, $
|
|
614
|
+
this.status = (0, $db7c797e63383364$export$7516420eb880ab68).CONNECTING;
|
|
615
615
|
// Define a function to wrap connection as a promise.
|
|
616
616
|
const connectionResolver = (resolve, reject)=>{
|
|
617
617
|
const rejector = (error)=>{
|
|
618
618
|
// Set the status back to disconnected
|
|
619
|
-
this.status = (0, $
|
|
619
|
+
this.status = (0, $db7c797e63383364$export$7516420eb880ab68).DISCONNECTED;
|
|
620
620
|
// Reject with the error as reason
|
|
621
621
|
reject(error);
|
|
622
622
|
};
|
|
@@ -626,24 +626,24 @@ var $a58372b18a18806e$export$7516420eb880ab68;
|
|
|
626
626
|
// Define a function to wrap version negotiation as a callback.
|
|
627
627
|
const versionNegotiator = ()=>{
|
|
628
628
|
// Write a log message to show that we have started version negotiation.
|
|
629
|
-
(0, $
|
|
629
|
+
(0, $623a31cc1663a627$export$2e2bcd8739ae039).network(`Requesting protocol version ${this.version} with '${this.hostIdentifier}'.`);
|
|
630
630
|
// remove the one-time error handler since no error was detected.
|
|
631
631
|
this.socket.removeListener("error", rejector);
|
|
632
632
|
// Build a version negotiation message.
|
|
633
|
-
const versionMessage = (0, $
|
|
633
|
+
const versionMessage = (0, $24139611f53a54b8$export$2e2bcd8739ae039).buildRequestObject("server.version", [
|
|
634
634
|
this.application,
|
|
635
635
|
this.version
|
|
636
636
|
], "versionNegotiation");
|
|
637
637
|
// Define a function to wrap version validation as a function.
|
|
638
638
|
const versionValidator = (version)=>{
|
|
639
639
|
// Check if version negotiation failed.
|
|
640
|
-
if ((0, $
|
|
640
|
+
if ((0, $e83d2e7688025acd$export$e1f38ab2b4ebdde6)(version)) {
|
|
641
641
|
// Disconnect from the host.
|
|
642
642
|
this.disconnect(true);
|
|
643
643
|
// Declare an error message.
|
|
644
644
|
const errorMessage = "unsupported protocol version.";
|
|
645
645
|
// Log the error.
|
|
646
|
-
(0, $
|
|
646
|
+
(0, $623a31cc1663a627$export$2e2bcd8739ae039).errors(`Failed to connect with ${this.hostIdentifier} due to ${errorMessage}`);
|
|
647
647
|
// Reject the connection with false since version negotiation failed.
|
|
648
648
|
reject(errorMessage);
|
|
649
649
|
} else if (version.protocol !== this.version && `${version.protocol}.0` !== this.version && `${version.protocol}.0.0` !== this.version) {
|
|
@@ -652,14 +652,14 @@ var $a58372b18a18806e$export$7516420eb880ab68;
|
|
|
652
652
|
// Declare an error message.
|
|
653
653
|
const errorMessage = `incompatible protocol version negotiated (${version.protocol} !== ${this.version}).`;
|
|
654
654
|
// Log the error.
|
|
655
|
-
(0, $
|
|
655
|
+
(0, $623a31cc1663a627$export$2e2bcd8739ae039).errors(`Failed to connect with ${this.hostIdentifier} due to ${errorMessage}`);
|
|
656
656
|
// Reject the connection with false since version negotiation failed.
|
|
657
657
|
reject(errorMessage);
|
|
658
658
|
} else {
|
|
659
659
|
// Write a log message.
|
|
660
|
-
(0, $
|
|
660
|
+
(0, $623a31cc1663a627$export$2e2bcd8739ae039).network(`Negotiated protocol version ${version.protocol} with '${this.hostIdentifier}', powered by ${version.software}.`);
|
|
661
661
|
// Set connection status to connected
|
|
662
|
-
this.status = (0, $
|
|
662
|
+
this.status = (0, $db7c797e63383364$export$7516420eb880ab68).CONNECTED;
|
|
663
663
|
// Emit a connect event now that the connection is usable.
|
|
664
664
|
this.emit("connect");
|
|
665
665
|
// Resolve the connection promise since we successfully connected and negotiated protocol version.
|
|
@@ -687,9 +687,9 @@ var $a58372b18a18806e$export$7516420eb880ab68;
|
|
|
687
687
|
// If a reconnect timer is set, remove it
|
|
688
688
|
await this.clearReconnectTimer();
|
|
689
689
|
// Write a log message.
|
|
690
|
-
(0, $
|
|
690
|
+
(0, $623a31cc1663a627$export$2e2bcd8739ae039).network(`Trying to reconnect to '${this.hostIdentifier}'..`);
|
|
691
691
|
// Set the status to reconnecting for more accurate log messages.
|
|
692
|
-
this.status = (0, $
|
|
692
|
+
this.status = (0, $db7c797e63383364$export$7516420eb880ab68).RECONNECTING;
|
|
693
693
|
// Destroy and recreate the socket to get a clean slate.
|
|
694
694
|
this.destroySocket();
|
|
695
695
|
this.createSocket();
|
|
@@ -732,13 +732,13 @@ var $a58372b18a18806e$export$7516420eb880ab68;
|
|
|
732
732
|
* @returns true if successfully disconnected, or false if there was no connection.
|
|
733
733
|
*/ async disconnect(force = false, intentional = true) {
|
|
734
734
|
// Return early when there is nothing to disconnect from
|
|
735
|
-
if (this.status === (0, $
|
|
735
|
+
if (this.status === (0, $db7c797e63383364$export$7516420eb880ab68).DISCONNECTED && !force) // Return false to indicate that there was nothing to disconnect from.
|
|
736
736
|
return false;
|
|
737
737
|
// Update connection state if the disconnection is intentional.
|
|
738
738
|
// NOTE: The state is meant to represent what the client is requesting, but
|
|
739
739
|
// is used internally to handle visibility changes in browsers to ensure functional reconnection.
|
|
740
740
|
if (intentional) // Set connection status to null to indicate tear-down is currently happening.
|
|
741
|
-
this.status = (0, $
|
|
741
|
+
this.status = (0, $db7c797e63383364$export$7516420eb880ab68).DISCONNECTING;
|
|
742
742
|
// If a keep-alive timer is set, remove it.
|
|
743
743
|
await this.clearKeepAliveTimer();
|
|
744
744
|
// If a reconnect timer is set, remove it
|
|
@@ -791,7 +791,7 @@ var $a58372b18a18806e$export$7516420eb880ab68;
|
|
|
791
791
|
// Set a new keep-alive timer.
|
|
792
792
|
this.setupKeepAliveTimer();
|
|
793
793
|
// Write the message to the network socket.
|
|
794
|
-
return this.socket.write(message + (0, $
|
|
794
|
+
return this.socket.write(message + (0, $24139611f53a54b8$export$2e2bcd8739ae039).statementDelimiter);
|
|
795
795
|
}
|
|
796
796
|
// --- Event managers. --- //
|
|
797
797
|
/**
|
|
@@ -801,14 +801,14 @@ var $a58372b18a18806e$export$7516420eb880ab68;
|
|
|
801
801
|
// If we haven't received any data since we last sent data out..
|
|
802
802
|
if (Number(this.lastReceivedTimestamp) < sentTimestamp) {
|
|
803
803
|
// If this connection is already disconnected, we do not change anything
|
|
804
|
-
if (this.status === (0, $
|
|
805
|
-
(0, $
|
|
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}'`);
|
|
806
806
|
return;
|
|
807
807
|
}
|
|
808
808
|
// Remove the current keep-alive timer if it exists.
|
|
809
809
|
this.clearKeepAliveTimer();
|
|
810
810
|
// Write a notification to the logs.
|
|
811
|
-
(0, $
|
|
811
|
+
(0, $623a31cc1663a627$export$2e2bcd8739ae039).network(`Connection to '${this.hostIdentifier}' timed out.`);
|
|
812
812
|
// Close the connection to avoid re-use.
|
|
813
813
|
// NOTE: This initiates reconnection routines if the connection has not
|
|
814
814
|
// been marked as intentionally disconnected.
|
|
@@ -837,21 +837,21 @@ var $a58372b18a18806e$export$7516420eb880ab68;
|
|
|
837
837
|
// Remove the current keep-alive timer if it exists.
|
|
838
838
|
this.clearKeepAliveTimer();
|
|
839
839
|
// If this is a connection we're trying to tear down..
|
|
840
|
-
if (this.status === (0, $
|
|
840
|
+
if (this.status === (0, $db7c797e63383364$export$7516420eb880ab68).DISCONNECTING) {
|
|
841
841
|
// If a reconnect timer is set, remove it.
|
|
842
842
|
this.clearReconnectTimer();
|
|
843
843
|
// Remove all event listeners
|
|
844
844
|
this.removeAllListeners();
|
|
845
845
|
// Mark the connection as disconnected.
|
|
846
|
-
this.status = (0, $
|
|
846
|
+
this.status = (0, $db7c797e63383364$export$7516420eb880ab68).DISCONNECTED;
|
|
847
847
|
// Write a log message.
|
|
848
|
-
(0, $
|
|
848
|
+
(0, $623a31cc1663a627$export$2e2bcd8739ae039).network(`Disconnected from '${this.hostIdentifier}'.`);
|
|
849
849
|
} else {
|
|
850
850
|
// If this is for an established connection..
|
|
851
|
-
if (this.status === (0, $
|
|
852
|
-
(0, $
|
|
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.`);
|
|
853
853
|
// Mark the connection as disconnected for now..
|
|
854
|
-
this.status = (0, $
|
|
854
|
+
this.status = (0, $db7c797e63383364$export$7516420eb880ab68).DISCONNECTED;
|
|
855
855
|
// If we don't have a pending reconnection timer..
|
|
856
856
|
if (!this.timers.reconnect) // Attempt to reconnect after one keep-alive duration.
|
|
857
857
|
this.timers.reconnect = setTimeout(this.reconnect.bind(this), this.reconnectInterval);
|
|
@@ -868,21 +868,21 @@ var $a58372b18a18806e$export$7516420eb880ab68;
|
|
|
868
868
|
return;
|
|
869
869
|
// If the DNS lookup failed.
|
|
870
870
|
if (error.code === "EAI_AGAIN") {
|
|
871
|
-
(0, $
|
|
871
|
+
(0, $623a31cc1663a627$export$2e2bcd8739ae039).errors(`Failed to look up DNS records for '${this.host}'.`);
|
|
872
872
|
return;
|
|
873
873
|
}
|
|
874
874
|
// If the connection timed out..
|
|
875
875
|
if (error.code === "ETIMEDOUT") {
|
|
876
876
|
// Log the provided timeout message.
|
|
877
|
-
(0, $
|
|
877
|
+
(0, $623a31cc1663a627$export$2e2bcd8739ae039).errors(error.message);
|
|
878
878
|
return;
|
|
879
879
|
}
|
|
880
880
|
// Log unknown error
|
|
881
|
-
(0, $
|
|
881
|
+
(0, $623a31cc1663a627$export$2e2bcd8739ae039).errors(`Unknown network error ('${this.hostIdentifier}'): `, error);
|
|
882
882
|
}
|
|
883
883
|
}
|
|
884
884
|
var // Export the connection.
|
|
885
|
-
$
|
|
885
|
+
$ff134c9a9e1f7361$export$2e2bcd8739ae039 = $ff134c9a9e1f7361$var$ElectrumConnection;
|
|
886
886
|
|
|
887
887
|
|
|
888
888
|
|
|
@@ -890,16 +890,16 @@ $1326c18f93f95fee$export$2e2bcd8739ae039 = $1326c18f93f95fee$var$ElectrumConnect
|
|
|
890
890
|
|
|
891
891
|
|
|
892
892
|
// Acceptable parameter types for RPC messages
|
|
893
|
-
const $
|
|
893
|
+
const $abcb763a48577a1e$export$d73a2e87a509880 = function(message) {
|
|
894
894
|
return "id" in message && "error" in message;
|
|
895
895
|
};
|
|
896
|
-
const $
|
|
896
|
+
const $abcb763a48577a1e$export$81276773828ff315 = function(message) {
|
|
897
897
|
return "id" in message && "result" in message;
|
|
898
898
|
};
|
|
899
|
-
const $
|
|
899
|
+
const $abcb763a48577a1e$export$280de919a0cf6928 = function(message) {
|
|
900
900
|
return !("id" in message) && "method" in message;
|
|
901
901
|
};
|
|
902
|
-
const $
|
|
902
|
+
const $abcb763a48577a1e$export$94e3360fcddccc76 = function(message) {
|
|
903
903
|
return "id" in message && "method" in message;
|
|
904
904
|
};
|
|
905
905
|
|
|
@@ -919,7 +919,7 @@ const $7c0fb93e8eea922a$export$94e3360fcddccc76 = function(message) {
|
|
|
919
919
|
* @event ElectrumClient#notification
|
|
920
920
|
*/ /**
|
|
921
921
|
* High-level Electrum client that lets applications send requests and subscribe to notification events from a server.
|
|
922
|
-
*/ class $
|
|
922
|
+
*/ class $558b46d3f899ced5$var$ElectrumClient extends (0, $dvphU$EventEmitter) {
|
|
923
923
|
/**
|
|
924
924
|
* Initializes an Electrum client.
|
|
925
925
|
*
|
|
@@ -934,7 +934,7 @@ const $7c0fb93e8eea922a$export$94e3360fcddccc76 = function(message) {
|
|
|
934
934
|
* @param {boolean} useBigInt whether to use bigint for numbers in json response.
|
|
935
935
|
*
|
|
936
936
|
* @throws {Error} if `version` is not a valid version string.
|
|
937
|
-
*/ constructor(application, version, host, port = (0, $
|
|
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){
|
|
938
938
|
// Initialize the event emitter.
|
|
939
939
|
super();
|
|
940
940
|
this.application = application;
|
|
@@ -949,9 +949,9 @@ const $7c0fb93e8eea922a$export$94e3360fcddccc76 = function(message) {
|
|
|
949
949
|
this.subscriptionMethods = {};
|
|
950
950
|
this.requestId = 0;
|
|
951
951
|
this.requestResolvers = {};
|
|
952
|
-
this.connectionLock = new (0, $
|
|
952
|
+
this.connectionLock = new (0, $dvphU$Mutex)();
|
|
953
953
|
// Set up a connection to an electrum server.
|
|
954
|
-
this.connection = new (0, $
|
|
954
|
+
this.connection = new (0, $ff134c9a9e1f7361$export$2e2bcd8739ae039)(application, version, host, port, scheme, timeout, pingInterval, reconnectInterval, useBigInt);
|
|
955
955
|
}
|
|
956
956
|
/**
|
|
957
957
|
* Connects to the remote server.
|
|
@@ -963,7 +963,7 @@ const $7c0fb93e8eea922a$export$94e3360fcddccc76 = function(message) {
|
|
|
963
963
|
const unlock = await this.connectionLock.acquire();
|
|
964
964
|
try {
|
|
965
965
|
// If we are already connected, do not attempt to connect again.
|
|
966
|
-
if (this.connection.status === (0, $
|
|
966
|
+
if (this.connection.status === (0, $db7c797e63383364$export$7516420eb880ab68).CONNECTED) return;
|
|
967
967
|
// Listen for parsed statements.
|
|
968
968
|
this.connection.on("statement", this.response.bind(this));
|
|
969
969
|
// Hook up resubscription on connection.
|
|
@@ -1020,14 +1020,14 @@ const $7c0fb93e8eea922a$export$94e3360fcddccc76 = function(message) {
|
|
|
1020
1020
|
* @returns a promise that resolves with the result of the method or an Error.
|
|
1021
1021
|
*/ async request(method, ...parameters) {
|
|
1022
1022
|
// If we are not connected to a server..
|
|
1023
|
-
if (this.connection.status !== (0, $
|
|
1023
|
+
if (this.connection.status !== (0, $db7c797e63383364$export$7516420eb880ab68).CONNECTED) // Reject the request with a disconnected error message.
|
|
1024
1024
|
throw new Error(`Unable to send request to a disconnected server '${this.connection.host}'.`);
|
|
1025
1025
|
// Increase the request ID by one.
|
|
1026
1026
|
this.requestId += 1;
|
|
1027
1027
|
// Store a copy of the request id.
|
|
1028
1028
|
const id = this.requestId;
|
|
1029
1029
|
// Format the arguments as an electrum request object.
|
|
1030
|
-
const message = (0, $
|
|
1030
|
+
const message = (0, $24139611f53a54b8$export$2e2bcd8739ae039).buildRequestObject(method, parameters, id);
|
|
1031
1031
|
// Define a function to wrap the request in a promise.
|
|
1032
1032
|
const requestResolver = (resolve)=>{
|
|
1033
1033
|
// Add a request resolver for this promise to the list of requests.
|
|
@@ -1042,7 +1042,7 @@ const $7c0fb93e8eea922a$export$94e3360fcddccc76 = function(message) {
|
|
|
1042
1042
|
this.connection.send(message);
|
|
1043
1043
|
};
|
|
1044
1044
|
// Write a log message.
|
|
1045
|
-
(0, $
|
|
1045
|
+
(0, $623a31cc1663a627$export$2e2bcd8739ae039).network(`Sending request '${method}' to '${this.connection.host}'`);
|
|
1046
1046
|
// return a promise to deliver results later.
|
|
1047
1047
|
return new Promise(requestResolver);
|
|
1048
1048
|
}
|
|
@@ -1087,7 +1087,7 @@ const $7c0fb93e8eea922a$export$94e3360fcddccc76 = function(message) {
|
|
|
1087
1087
|
* @returns a promise resolving when the subscription is removed.
|
|
1088
1088
|
*/ async unsubscribe(method, ...parameters) {
|
|
1089
1089
|
// Throw an error if the client is disconnected.
|
|
1090
|
-
if (this.connection.status !== (0, $
|
|
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}'.`);
|
|
1091
1091
|
// If this method has no subscriptions..
|
|
1092
1092
|
if (!this.subscriptionMethods[method]) // Reject this promise with an explanation.
|
|
1093
1093
|
throw new Error(`Cannot unsubscribe from '${method}' since the method has no subscriptions.`);
|
|
@@ -1102,7 +1102,7 @@ const $7c0fb93e8eea922a$export$94e3360fcddccc76 = function(message) {
|
|
|
1102
1102
|
// NOTE: As a convenience we allow users to define the method as the subscribe or unsubscribe version.
|
|
1103
1103
|
await this.request(method.replace(".subscribe", ".unsubscribe"), ...parameters);
|
|
1104
1104
|
// Write a log message.
|
|
1105
|
-
(0, $
|
|
1105
|
+
(0, $623a31cc1663a627$export$2e2bcd8739ae039).client(`Unsubscribed from '${String(method)}' for the '${subscriptionParameters}' parameters.`);
|
|
1106
1106
|
}
|
|
1107
1107
|
/**
|
|
1108
1108
|
* Restores existing subscriptions without updating status or triggering manual callbacks.
|
|
@@ -1114,7 +1114,7 @@ const $7c0fb93e8eea922a$export$94e3360fcddccc76 = function(message) {
|
|
|
1114
1114
|
* @ignore
|
|
1115
1115
|
*/ async resubscribeOnConnect() {
|
|
1116
1116
|
// Write a log message.
|
|
1117
|
-
(0, $
|
|
1117
|
+
(0, $623a31cc1663a627$export$2e2bcd8739ae039).client(`Connected to '${this.connection.hostIdentifier}'.`);
|
|
1118
1118
|
// Initialize an empty list of resubscription promises.
|
|
1119
1119
|
const resubscriptionPromises = [];
|
|
1120
1120
|
// For each method we have a subscription for..
|
|
@@ -1130,7 +1130,7 @@ const $7c0fb93e8eea922a$export$94e3360fcddccc76 = function(message) {
|
|
|
1130
1130
|
await Promise.all(resubscriptionPromises);
|
|
1131
1131
|
}
|
|
1132
1132
|
// Write a log message if there was any subscriptions to restore.
|
|
1133
|
-
if (resubscriptionPromises.length > 0) (0, $
|
|
1133
|
+
if (resubscriptionPromises.length > 0) (0, $623a31cc1663a627$export$2e2bcd8739ae039).client(`Restored ${resubscriptionPromises.length} previous subscriptions for '${this.connection.hostIdentifier}'`);
|
|
1134
1134
|
}
|
|
1135
1135
|
/**
|
|
1136
1136
|
* Parser messages from the remote server to resolve request promises and emit subscription events.
|
|
@@ -1141,9 +1141,9 @@ const $7c0fb93e8eea922a$export$94e3360fcddccc76 = function(message) {
|
|
|
1141
1141
|
* @ignore
|
|
1142
1142
|
*/ response(message) {
|
|
1143
1143
|
// If the received message is a notification, we forward it to all event listeners
|
|
1144
|
-
if ((0, $
|
|
1144
|
+
if ((0, $abcb763a48577a1e$export$280de919a0cf6928)(message)) {
|
|
1145
1145
|
// Write a log message.
|
|
1146
|
-
(0, $
|
|
1146
|
+
(0, $623a31cc1663a627$export$2e2bcd8739ae039).client(`Received notification for '${message.method}' from '${this.connection.host}'`);
|
|
1147
1147
|
// Forward the message content to all event listeners.
|
|
1148
1148
|
this.emit("notification", message);
|
|
1149
1149
|
// Return since it does not have an associated request resolver
|
|
@@ -1160,7 +1160,7 @@ const $7c0fb93e8eea922a$export$94e3360fcddccc76 = function(message) {
|
|
|
1160
1160
|
// Remove the promise from the request list.
|
|
1161
1161
|
delete this.requestResolvers[message.id];
|
|
1162
1162
|
// If the message contains an error..
|
|
1163
|
-
if ((0, $
|
|
1163
|
+
if ((0, $abcb763a48577a1e$export$d73a2e87a509880)(message)) // Forward the message error to the request resolver and omit the `result` parameter.
|
|
1164
1164
|
requestResolver(new Error(message.error.message));
|
|
1165
1165
|
else // Forward the message content to the request resolver and omit the `error` parameter
|
|
1166
1166
|
// (by setting it to undefined).
|
|
@@ -1186,7 +1186,7 @@ const $7c0fb93e8eea922a$export$94e3360fcddccc76 = function(message) {
|
|
|
1186
1186
|
}
|
|
1187
1187
|
}
|
|
1188
1188
|
var // Export the client.
|
|
1189
|
-
$
|
|
1189
|
+
$558b46d3f899ced5$export$2e2bcd8739ae039 = $558b46d3f899ced5$var$ElectrumClient;
|
|
1190
1190
|
|
|
1191
1191
|
|
|
1192
1192
|
|
|
@@ -1194,5 +1194,5 @@ $620a18299ef8d6fd$export$2e2bcd8739ae039 = $620a18299ef8d6fd$var$ElectrumClient;
|
|
|
1194
1194
|
|
|
1195
1195
|
|
|
1196
1196
|
|
|
1197
|
-
export {$
|
|
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};
|
|
1198
1198
|
//# sourceMappingURL=index.mjs.map
|