@electrum-cash/network 3.2.0-r2 → 3.3.0-development.6103536979
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 +20 -1
- package/dist/index.cjs +17 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +17 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ Install the library with NPM:
|
|
|
15
15
|
|
|
16
16
|
## Usage
|
|
17
17
|
|
|
18
|
-
###
|
|
18
|
+
### Usage with NodeJS
|
|
19
19
|
|
|
20
20
|
Before you can use the library you need to include it in your project.
|
|
21
21
|
|
|
@@ -33,6 +33,15 @@ If you want to use **multiple servers**, load the `ElectrumCluster` module:
|
|
|
33
33
|
const { ElectrumCluster } = require('electrum-cash');
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
+
### Usage on Web
|
|
37
|
+
|
|
38
|
+
To use the library on the web, use the ESM import syntax and include the `ElectrumTransport` import:
|
|
39
|
+
|
|
40
|
+
```js
|
|
41
|
+
// Load the electrum library.
|
|
42
|
+
import { ElectrumClient, ElectrumTransport } from 'electrum-cash';
|
|
43
|
+
```
|
|
44
|
+
|
|
36
45
|
### Connect to servers
|
|
37
46
|
|
|
38
47
|
After you have loaded the appropriate module you need to initialize the module by configuring your **application identifier** and **protocol version**.
|
|
@@ -46,6 +55,15 @@ const electrum = new ElectrumClient('Electrum client example', '1.4.1', 'bch.ima
|
|
|
46
55
|
await electrum.connect();
|
|
47
56
|
```
|
|
48
57
|
|
|
58
|
+
To connect to an electrum server from a web browser, use the `ElectrumTransport` import to use the WSS `port` and `scheme`:
|
|
59
|
+
|
|
60
|
+
```js
|
|
61
|
+
const electrum = new ElectrumClient(
|
|
62
|
+
'Electrum client example', '1.4.1', 'bch.imaginary.cash',
|
|
63
|
+
ElectrumTransport.WSS.Port, ElectrumTransport.WSS.Scheme
|
|
64
|
+
);
|
|
65
|
+
```
|
|
66
|
+
|
|
49
67
|
If you want to use multiple servers, initialize an `ElectrumCluster` and add some servers:
|
|
50
68
|
|
|
51
69
|
*For more information on various cluster configurations, read the [cluster documentation](https://read.cash/@JonathanSilverblood/electrum-cash-strategic-use-of-clusters-83743111).*
|
|
@@ -65,6 +83,7 @@ electrum.addServer('electrum.imaginary.cash');
|
|
|
65
83
|
await electrum.ready();
|
|
66
84
|
```
|
|
67
85
|
|
|
86
|
+
|
|
68
87
|
### Request information
|
|
69
88
|
|
|
70
89
|
Once your `ElectrumClient` or `ElectrumCluster` is connected and ready, you can call methods:
|
package/dist/index.cjs
CHANGED
|
@@ -182,12 +182,12 @@ const $48ce8effa4fcde4d$export$f019be48b3aacb1a = {
|
|
|
182
182
|
// Transport to connect to the Electrum server
|
|
183
183
|
TRANSPORT_SCHEME: $48ce8effa4fcde4d$export$d048df559e6d3842.TCP_TLS.Scheme,
|
|
184
184
|
// How long to wait before attempting to reconnect, in milliseconds.
|
|
185
|
-
RECONNECT:
|
|
185
|
+
RECONNECT: 5000,
|
|
186
186
|
// How long to wait for network operations before following up, in milliseconds.
|
|
187
|
-
TIMEOUT:
|
|
187
|
+
TIMEOUT: 30000,
|
|
188
188
|
// Time between ping messages, in milliseconds. Pinging keeps the connection alive.
|
|
189
189
|
// The reason for pinging this frequently is to detect connection problems early.
|
|
190
|
-
PING_INTERVAL:
|
|
190
|
+
PING_INTERVAL: 1000,
|
|
191
191
|
// How many servers are required before we trust information provided.
|
|
192
192
|
CLUSTER_CONFIDENCE: 1,
|
|
193
193
|
// How many servers we send requests to.
|
|
@@ -1158,20 +1158,25 @@ $ab5ca7f40897fe20$export$2e2bcd8739ae039 = $ab5ca7f40897fe20$var$ElectrumClient;
|
|
|
1158
1158
|
* Triggers when the cluster connects to enough servers to satisfy both the cluster confidence and distribution policies.
|
|
1159
1159
|
*
|
|
1160
1160
|
* @event ElectrumCluster#ready
|
|
1161
|
+
* @deprecated
|
|
1161
1162
|
*/ /**
|
|
1162
1163
|
* Triggers when the cluster loses a connection and can no longer satisfy the cluster distribution policy.
|
|
1163
1164
|
*
|
|
1164
1165
|
* @event ElectrumCluster#degraded
|
|
1166
|
+
* @deprecated
|
|
1165
1167
|
*/ /**
|
|
1166
1168
|
* Triggers when the cluster loses a connection and can no longer satisfy the cluster confidence policy.
|
|
1167
1169
|
*
|
|
1168
1170
|
* @event ElectrumCluster#disabled
|
|
1171
|
+
* @deprecated
|
|
1169
1172
|
*/ /**
|
|
1170
1173
|
* Triggers when the cluster verifies the integrity of remote server sent data that is not a request responses.
|
|
1171
1174
|
*
|
|
1172
1175
|
* @event ElectrumCluster#notification
|
|
1176
|
+
* @deprecated
|
|
1173
1177
|
*/ /**
|
|
1174
1178
|
* High-level electrum client that provides transparent load balancing, confidence checking and/or low-latency polling.
|
|
1179
|
+
* @deprecated
|
|
1175
1180
|
*/ class $683dbcc250bd73d7$var$ElectrumCluster extends (0, $790lB$events.EventEmitter) {
|
|
1176
1181
|
/**
|
|
1177
1182
|
* @param {string} application your application name, used to identify to the electrum hosts.
|
|
@@ -1220,6 +1225,7 @@ $ab5ca7f40897fe20$export$2e2bcd8739ae039 = $ab5ca7f40897fe20$var$ElectrumClient;
|
|
|
1220
1225
|
}
|
|
1221
1226
|
/**
|
|
1222
1227
|
* Adds a server to the cluster.
|
|
1228
|
+
* @deprecated
|
|
1223
1229
|
*
|
|
1224
1230
|
* @param {string} host fully qualified domain name or IP number of the host.
|
|
1225
1231
|
* @param {number} port the TCP network port of the host.
|
|
@@ -1323,6 +1329,7 @@ $ab5ca7f40897fe20$export$2e2bcd8739ae039 = $ab5ca7f40897fe20$var$ElectrumClient;
|
|
|
1323
1329
|
}
|
|
1324
1330
|
/**
|
|
1325
1331
|
* Calls a method on the remote server with the supplied parameters.
|
|
1332
|
+
* @deprecated
|
|
1326
1333
|
*
|
|
1327
1334
|
* @param {string} method name of the method to call.
|
|
1328
1335
|
* @param {...string} parameters one or more parameters for the method.
|
|
@@ -1439,6 +1446,7 @@ $ab5ca7f40897fe20$export$2e2bcd8739ae039 = $ab5ca7f40897fe20$var$ElectrumClient;
|
|
|
1439
1446
|
}
|
|
1440
1447
|
/**
|
|
1441
1448
|
* Subscribes to the method at the cluster and attaches the callback function to the event feed.
|
|
1449
|
+
* @deprecated
|
|
1442
1450
|
*
|
|
1443
1451
|
* @note the response for the subscription request is issued as a notification event.
|
|
1444
1452
|
*
|
|
@@ -1465,6 +1473,7 @@ $ab5ca7f40897fe20$export$2e2bcd8739ae039 = $ab5ca7f40897fe20$var$ElectrumClient;
|
|
|
1465
1473
|
/**
|
|
1466
1474
|
* Unsubscribes to the method at the cluster and removes any callback functions
|
|
1467
1475
|
* when there are no more subscriptions for the method.
|
|
1476
|
+
* @deprecated
|
|
1468
1477
|
*
|
|
1469
1478
|
* @param {string} method one of the subscribable methods the server supports.
|
|
1470
1479
|
* @param {...string} parameters one or more parameters for the method.
|
|
@@ -1485,6 +1494,7 @@ $ab5ca7f40897fe20$export$2e2bcd8739ae039 = $ab5ca7f40897fe20$var$ElectrumClient;
|
|
|
1485
1494
|
}
|
|
1486
1495
|
/**
|
|
1487
1496
|
* Define a callback function to validate server notifications and pass them to the subscribe callback.
|
|
1497
|
+
* @deprecated
|
|
1488
1498
|
*
|
|
1489
1499
|
* @ignore
|
|
1490
1500
|
*/ async handleSubscriptionNotifications(clientIdentity, data) {
|
|
@@ -1521,11 +1531,13 @@ $ab5ca7f40897fe20$export$2e2bcd8739ae039 = $ab5ca7f40897fe20$var$ElectrumClient;
|
|
|
1521
1531
|
* Forgets/Removes notification data for a specific notification.
|
|
1522
1532
|
*
|
|
1523
1533
|
* This is required in order to allow future identical notifications to be properly processed and emitted.
|
|
1534
|
+
* @deprecated
|
|
1524
1535
|
*/ async dismissSubscriptionNotification(responseDataIdentifier) {
|
|
1525
1536
|
delete this.notifications[responseDataIdentifier];
|
|
1526
1537
|
}
|
|
1527
1538
|
/**
|
|
1528
1539
|
* Provides a method to check or wait for the cluster to become ready.
|
|
1540
|
+
* @deprecated
|
|
1529
1541
|
*
|
|
1530
1542
|
* @returns a promise that resolves when the required servers are available.
|
|
1531
1543
|
*/ async ready() {
|
|
@@ -1563,6 +1575,7 @@ $ab5ca7f40897fe20$export$2e2bcd8739ae039 = $ab5ca7f40897fe20$var$ElectrumClient;
|
|
|
1563
1575
|
/**
|
|
1564
1576
|
* Connects all servers from the cluster and attaches event listeners and handlers
|
|
1565
1577
|
* for all underlying clients and connections.
|
|
1578
|
+
* @deprecated
|
|
1566
1579
|
*
|
|
1567
1580
|
* @throws {Error} if the cluster's version is not a valid version string.
|
|
1568
1581
|
*/ async startup() {
|
|
@@ -1588,6 +1601,7 @@ $ab5ca7f40897fe20$export$2e2bcd8739ae039 = $ab5ca7f40897fe20$var$ElectrumClient;
|
|
|
1588
1601
|
* Disconnects all servers from the cluster. Removes all event listeners and
|
|
1589
1602
|
* handlers from all underlying clients and connections. This includes all
|
|
1590
1603
|
* active subscriptions, unless retainSubscriptions is set to true.
|
|
1604
|
+
* @deprecated
|
|
1591
1605
|
*
|
|
1592
1606
|
* @param {boolean} retainSubscriptions retain subscription data so they will be restored on reconnection.
|
|
1593
1607
|
*
|