@electrum-cash/network 4.0.0-development.6655313659 → 4.0.0-development.8017676278

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.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { EventEmitter } from "events";
2
+ import { ElectrumSocket } from "@electrum-cash/sockets";
2
3
  type RPCParameter = string | number | boolean | null;
3
4
  interface RPCBase {
4
5
  jsonrpc: string;
@@ -75,41 +76,9 @@ export interface ConnectionOptions {
75
76
  rejectUnauthorized?: boolean;
76
77
  serverName?: string;
77
78
  }
78
- /**
79
- * Object containing the commonly used ports and schemes for specific Transports.
80
- * @example const electrum = new ElectrumClient('Electrum client example', '1.4.1', 'bch.imaginary.cash', Transport.WSS.Port, Transport.WSS.Scheme);
81
- *
82
- * @property {object} TCP Port and Scheme to use unencrypted TCP sockets.
83
- * @property {object} TCP_TLS Port and Scheme to use TLS-encrypted TCP sockets.
84
- * @property {object} WS Port and Scheme to use unencrypted WebSockets.
85
- * @property {object} WSS Port and Scheme to use TLS-encrypted WebSockets.
86
- */
87
- export const ElectrumTransport: {
88
- TCP: {
89
- Port: number;
90
- Scheme: TransportScheme;
91
- };
92
- TCP_TLS: {
93
- Port: number;
94
- Scheme: TransportScheme;
95
- };
96
- WS: {
97
- Port: number;
98
- Scheme: TransportScheme;
99
- };
100
- WSS: {
101
- Port: number;
102
- Scheme: TransportScheme;
103
- };
104
- };
105
- export const DefaultParameters: {
106
- PORT: number;
107
- TRANSPORT_SCHEME: TransportScheme;
108
- RECONNECT: number;
109
- TIMEOUT: number;
110
- PING_INTERVAL: number;
111
- USE_BIG_INT: boolean;
112
- };
79
+ export const DEFAULT_PING_INTERVAL: number;
80
+ export const DEFAULT_RECONNECT_INTERVAL: number;
81
+ export const DEFAULT_BIG_INTEGERS = false;
113
82
  /**
114
83
  * Triggers when the underlying connection is established.
115
84
  *
@@ -131,10 +100,7 @@ export const DefaultParameters: {
131
100
  export class ElectrumClient extends EventEmitter {
132
101
  application: string;
133
102
  version: string;
134
- host: string;
135
- port: number;
136
- scheme: TransportScheme;
137
- timeout: number;
103
+ socketOrHostname: ElectrumSocket | string;
138
104
  pingInterval: number;
139
105
  reconnectInterval: number;
140
106
  useBigInt: boolean;
@@ -163,19 +129,21 @@ export class ElectrumClient extends EventEmitter {
163
129
  /**
164
130
  * Initializes an Electrum client.
165
131
  *
166
- * @param {string} application your application name, used to identify to the electrum host.
167
- * @param {string} version protocol version to use with the host.
168
- * @param {string} host fully qualified domain name or IP number of the host.
169
- * @param {number} port the TCP network port of the host.
170
- * @param {TransportScheme} scheme the transport scheme to use for connection
171
- * @param {number} timeout how long network delays we will wait for before taking action, in milliseconds.
172
- * @param {number} pingInterval the time between sending pings to the electrum host, in milliseconds.
173
- * @param {number} reconnectInterval the time between reconnection attempts to the electrum host, in milliseconds.
174
- * @param {boolean} useBigInt whether to use bigint for numbers in json response.
132
+ * @param application - your application name, used to identify to the electrum host.
133
+ * @param version - protocol version to use with the host.
134
+ * @param socketOrHostname - socket fully qualified domain name or IP number of the host
135
+ * @param pingInterval - the time between sending pings to the electrum host, in milliseconds.
136
+ * @param reconnectInterval - the time between reconnection attempts to the electrum host, in milliseconds.
137
+ * @param useBigInt - whether to use bigint for numbers in json response.
175
138
  *
176
139
  * @throws {Error} if `version` is not a valid version string.
177
140
  */
178
- constructor(application: string, version: string, host: string, port?: number, scheme?: TransportScheme, timeout?: number, pingInterval?: number, reconnectInterval?: number, useBigInt?: boolean);
141
+ constructor(application: string, version: string, socketOrHostname: ElectrumSocket | string, pingInterval?: number, reconnectInterval?: number, useBigInt?: boolean);
142
+ get hostIdentifier(): string;
143
+ get host(): string;
144
+ get port(): number;
145
+ get encrypted(): boolean;
146
+ get timeout(): number;
179
147
  /**
180
148
  * Connects to the remote server.
181
149
  *
@@ -186,8 +154,8 @@ export class ElectrumClient extends EventEmitter {
186
154
  /**
187
155
  * Disconnects from the remote server and removes all event listeners/subscriptions and open requests.
188
156
  *
189
- * @param {boolean} force disconnect even if the connection has not been fully established yet.
190
- * @param {boolean} retainSubscriptions retain subscription data so they will be restored on reconnection.
157
+ * @param force - disconnect even if the connection has not been fully established yet.
158
+ * @param retainSubscriptions - retain subscription data so they will be restored on reconnection.
191
159
  *
192
160
  * @returns true if successfully disconnected, or false if there was no connection.
193
161
  */
@@ -195,8 +163,8 @@ export class ElectrumClient extends EventEmitter {
195
163
  /**
196
164
  * Calls a method on the remote server with the supplied parameters.
197
165
  *
198
- * @param {string} method name of the method to call.
199
- * @param {...string} parameters one or more parameters for the method.
166
+ * @param method - name of the method to call.
167
+ * @param parameters - one or more parameters for the method.
200
168
  *
201
169
  * @throws {Error} if the client is disconnected.
202
170
  * @returns a promise that resolves with the result of the method or an Error.
@@ -207,8 +175,8 @@ export class ElectrumClient extends EventEmitter {
207
175
  *
208
176
  * @note the response for the subscription request is issued as a notification event.
209
177
  *
210
- * @param {string} method one of the subscribable methods the server supports.
211
- * @param {...string} parameters one or more parameters for the method.
178
+ * @param method - one of the subscribable methods the server supports.
179
+ * @param parameters - one or more parameters for the method.
212
180
  *
213
181
  * @throws {Error} if the client is disconnected.
214
182
  * @returns a promise resolving when the subscription is established.
@@ -218,8 +186,8 @@ export class ElectrumClient extends EventEmitter {
218
186
  * Unsubscribes to the method at the server and removes any callback functions
219
187
  * when there are no more subscriptions for the method.
220
188
  *
221
- * @param {string} method a previously subscribed to method.
222
- * @param {...string} parameters one or more parameters for the method.
189
+ * @param method - a previously subscribed to method.
190
+ * @param parameters - one or more parameters for the method.
223
191
  *
224
192
  * @throws {Error} if no subscriptions exist for the combination of the provided `method` and `parameters.
225
193
  * @throws {Error} if the client is disconnected.
@@ -229,7 +197,7 @@ export class ElectrumClient extends EventEmitter {
229
197
  /**
230
198
  * Parser messages from the remote server to resolve request promises and emit subscription events.
231
199
  *
232
- * @param {RPCNotification | RPCResponse} message the response message
200
+ * @param message - the response message
233
201
  *
234
202
  * @throws {Error} if the message ID does not match an existing request.
235
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AAE,MAAoC,EACvD,SAAS,GAAE,OAAuC;IAU1D;;;;;OAKG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IA0C9B;;;;;;;OAOG;IACG,UAAU,CAAC,KAAK,GAAE,OAAe,EAAE,mBAAmB,GAAE,OAAe,GAAG,OAAO,CAAC,OAAO,CAAC;IAehG;;;;;;;;OAQG;IACG,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,KAAK,GAAG,eAAe,CAAC;IAgD9F;;;;;;;;;;OAUG;IACG,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IA6B7E;;;;;;;;;;OAUG;IACG,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAgF/E;;;;;;;OAOG;IACH,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,WAAW,GAAG,IAAI;IA0DtD;;;;;OAKG;IACG,sBAAsB,IAAI,OAAO,CAAC,IAAI,CAAC;IAmB7C;;;;OAIG;IACG,oBAAoB,CAAC,gBAAgB,KAAA,GAAG,OAAO,CAAC,IAAI,CAAC;IAa3D;;;;OAIG;IACG,2BAA2B,IAAI,OAAO,CAAC,IAAI,CAAC;IAMlD;;;;;OAKG;IACG,yCAAyC,CAAC,OAAO,KAAA,GAAG,OAAO,CAAC,IAAI,CAAC;IAUvE;;;;;OAKG;IACG,oCAAoC,CAAC,OAAO,KAAA,GAAG,OAAO,CAAC,IAAI,CAAC;IAiBlE;;OAEG;IACG,6BAA6B,CAAC,SAAS,KAAA,GAAG,OAAO,CAAC,IAAI,CAAC;CAQ7D","sources":["source/source/util.ts","source/source/rpc-interfaces.ts","source/source/electrum-protocol.ts","source/source/enums.ts","source/source/interfaces.ts","source/source/constants.ts","source/source/electrum-socket.ts","source/source/electrum-connection.ts","source/source/electrum-client.ts","source/source/index.ts","source/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,null,"export { default as ElectrumClient } from './electrum-client';\n\nexport * from './interfaces';\nexport * from './constants';\nexport * from './enums';\n"],"names":[],"version":3,"file":"index.d.ts.map"}
1
+ {"mappings":";;AACA,oBAA2B,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AAG5D;IAEC,OAAO,EAAE,MAAM,CAAC;CAChB;AAGD,yBAAiC,SAAQ,OAAO;IAE/C,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,YAAY,EAAE,CAAC;CACxB;AAWD,sBAA8B,SAAQ,OAAO;IAE5C,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CACf;AAED;IAEC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,GAAG,CAAC;CACX;AAGD,0BAAkC,SAAQ,OAAO;IAEhD,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAClB,KAAK,EAAE,QAAQ,CAAC;CAChB;AAGD,mBAA0B,gBAAgB,GAAG,YAAY,CAAC;AE3C1D;;;;;GAKG;AACH;IAEC,WAAW,IAAI;IACf,SAAS,IAAI;CACb;AAED;;;;;;;;GAQG;AACH;IAEC,YAAY,IAAI;IAChB,SAAS,IAAI;IACb,aAAa,IAAI;IACjB,UAAU,IAAI;IACd,YAAY,IAAI;CAChB;AC3BD;IAGC,KAAK,EAAE,WAAW,CAAC;IAGnB,UAAU,EAAE,cAAc,CAAC;CAC3B;AAED;;GAEG;AACH,8BAA8B,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,eAAe,EAAE,CAAC;AAI5F,8BAA8B,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;A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AAG,OAAO,CAAC,IAAI,CAAC;IAiBlE;;OAEG;IACG,6BAA6B,CAAC,SAAS,KAAA,GAAG,OAAO,CAAC,IAAI,CAAC;CAQ7D","sources":["source/source/rpc-interfaces.ts","source/source/electrum-protocol.ts","source/source/enums.ts","source/source/interfaces.ts","source/source/constants.ts","source/source/electrum-connection.ts","source/source/electrum-client.ts","source/source/index.ts","source/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,"export { default as ElectrumClient } from './electrum-client';\n\nexport * from './interfaces';\nexport * from './constants';\nexport * from './enums';\n"],"names":[],"version":3,"file":"index.d.ts.map"}