@xchainjs/xchain-utxo-providers 0.1.1 → 0.2.0

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.
Files changed (32) hide show
  1. package/lib/index.esm.js +1036 -0
  2. package/lib/index.js +1056 -13
  3. package/lib/providers/blockcypher/blockcypher-api-types.d.ts +12 -12
  4. package/lib/providers/blockcypher/blockcypher-api.d.ts +4 -4
  5. package/lib/providers/blockcypher/blockcypher-data-provider.d.ts +1 -1
  6. package/lib/providers/haskoin/haskoin-api-types.d.ts +15 -15
  7. package/lib/providers/haskoin/haskoin-api.d.ts +1 -1
  8. package/lib/providers/haskoin/haskoin-data-provider.d.ts +1 -1
  9. package/lib/providers/sochainv3/sochain-api-types.d.ts +13 -13
  10. package/lib/providers/sochainv3/sochain-data-provider.d.ts +1 -1
  11. package/package.json +11 -12
  12. package/lib/index.js.map +0 -1
  13. package/lib/providers/blockcypher/blockcypher-api-types.js +0 -11
  14. package/lib/providers/blockcypher/blockcypher-api-types.js.map +0 -1
  15. package/lib/providers/blockcypher/blockcypher-api.js +0 -231
  16. package/lib/providers/blockcypher/blockcypher-api.js.map +0 -1
  17. package/lib/providers/blockcypher/blockcypher-data-provider.js +0 -366
  18. package/lib/providers/blockcypher/blockcypher-data-provider.js.map +0 -1
  19. package/lib/providers/haskoin/haskoin-api-types.js +0 -14
  20. package/lib/providers/haskoin/haskoin-api-types.js.map +0 -1
  21. package/lib/providers/haskoin/haskoin-api.js +0 -485
  22. package/lib/providers/haskoin/haskoin-api.js.map +0 -1
  23. package/lib/providers/haskoin/haskoin-data-provider.js +0 -269
  24. package/lib/providers/haskoin/haskoin-data-provider.js.map +0 -1
  25. package/lib/providers/index.js +0 -34
  26. package/lib/providers/index.js.map +0 -1
  27. package/lib/providers/sochainv3/sochain-api-types.js +0 -13
  28. package/lib/providers/sochainv3/sochain-api-types.js.map +0 -1
  29. package/lib/providers/sochainv3/sochain-api.js +0 -354
  30. package/lib/providers/sochainv3/sochain-api.js.map +0 -1
  31. package/lib/providers/sochainv3/sochain-data-provider.js +0 -312
  32. package/lib/providers/sochainv3/sochain-data-provider.js.map +0 -1
package/lib/index.js CHANGED
@@ -1,14 +1,1057 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var xchainUtil = require('@xchainjs/xchain-util');
6
+ var axios = require('axios');
7
+ var xchainClient = require('@xchainjs/xchain-client');
8
+ var PromisePool = require('@supercharge/promise-pool');
9
+
10
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
11
+
12
+ var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
13
+ var PromisePool__default = /*#__PURE__*/_interopDefaultLegacy(PromisePool);
14
+
15
+ exports.SochainNetwork = void 0;
16
+ (function (SochainNetwork) {
17
+ SochainNetwork["BTC"] = "BTC";
18
+ SochainNetwork["BTCTEST"] = "BTCTEST";
19
+ SochainNetwork["LTC"] = "LTC";
20
+ SochainNetwork["LTCTEST"] = "LTCTEST";
21
+ SochainNetwork["DOGE"] = "DOGE";
22
+ SochainNetwork["DOGETEST"] = "DOGETEST";
23
+ })(exports.SochainNetwork || (exports.SochainNetwork = {}));
24
+
25
+ /******************************************************************************
26
+ Copyright (c) Microsoft Corporation.
27
+
28
+ Permission to use, copy, modify, and/or distribute this software for any
29
+ purpose with or without fee is hereby granted.
30
+
31
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
32
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
33
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
34
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
35
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
36
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
37
+ PERFORMANCE OF THIS SOFTWARE.
38
+ ***************************************************************************** */
39
+
40
+ function __awaiter(thisArg, _arguments, P, generator) {
41
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
42
+ return new (P || (P = Promise))(function (resolve, reject) {
43
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
44
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
45
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
46
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
47
+ });
48
+ }
49
+
50
+ /**
51
+ * Get transaction by hash.
52
+ *
53
+ * @see https://sochain.com/api#get-tx
54
+ *
55
+ * @param {string} sochainUrl The sochain node url.
56
+ * @param {string} network network id
57
+ * @param {string} hash The transaction hash.
58
+ * @returns {Transactions}
59
+ */
60
+ const getTx$2 = ({ apiKey, sochainUrl, network, hash }) => __awaiter(void 0, void 0, void 0, function* () {
61
+ const url = `${sochainUrl}/transaction/${network}/${hash}`;
62
+ const response = yield axios__default["default"].get(url, { headers: { 'API-KEY': apiKey } });
63
+ const tx = response.data;
64
+ return tx.data;
65
+ });
66
+ /**
67
+ * Get transactions
68
+ *
69
+ * @see https://sochain.com/api#get-tx
70
+ *
71
+ * @param {string} sochainUrl The sochain node url.
72
+ * @param {string} network network id
73
+ * @param {string} hash The transaction hash.
74
+ * @returns {Transactions}
75
+ */
76
+ const getTxs$2 = ({ apiKey, address, sochainUrl, network, page, }) => __awaiter(void 0, void 0, void 0, function* () {
77
+ const url = `${sochainUrl}/transactions/${network}/${address}/${page}`; //TODO support paging
78
+ const response = yield axios__default["default"].get(url, { headers: { 'API-KEY': apiKey } });
79
+ const txs = response.data;
80
+ return txs.data;
81
+ });
82
+ /**
83
+ * Get address balance.
84
+ *
85
+ * @see https://sochain.com/api#get-balance
86
+ *
87
+ * @param {string} sochainUrl The sochain node url.
88
+ * @param {string} network Network
89
+ * @param {string} address Address
90
+ * @param {boolean} confirmedOnly Flag whether to get balances of confirmed txs only or for all
91
+ * @returns {number}
92
+ */
93
+ const getBalance$2 = ({ apiKey, sochainUrl, network, address, confirmedOnly, assetDecimals, }) => __awaiter(void 0, void 0, void 0, function* () {
94
+ const url = `${sochainUrl}/balance/${network}/${address}`;
95
+ const response = yield axios__default["default"].get(url, { headers: { 'API-KEY': apiKey } });
96
+ const balanceResponse = response.data;
97
+ const confirmed = xchainUtil.assetAmount(balanceResponse.data.confirmed, assetDecimals);
98
+ const unconfirmed = xchainUtil.assetAmount(balanceResponse.data.unconfirmed, assetDecimals);
99
+ const netAmt = confirmedOnly ? confirmed : confirmed.plus(unconfirmed);
100
+ const result = xchainUtil.assetToBase(netAmt);
101
+ return result;
102
+ });
103
+ /**
104
+ * Get unspent txs
105
+ *
106
+ * @see https://sochain.com/api#get-unspent-tx
107
+ *
108
+ * @param {string} sochainUrl The sochain node url.
109
+ * @param {string} network
110
+ * @param {string} address
111
+ * @returns {AddressUTXO[]}
112
+ */
113
+ const getUnspentTxs$1 = ({ apiKey, sochainUrl, network, address, page, }) => __awaiter(void 0, void 0, void 0, function* () {
114
+ const url = [sochainUrl, 'unspent_outputs', network, address, page].filter((v) => !!v).join('/');
115
+ const resp = yield axios__default["default"].get(url, { headers: { 'API-KEY': apiKey } });
116
+ const response = resp.data;
117
+ const txs = response.data.outputs;
118
+ if (txs.length === 10) {
119
+ //fetch the next batch
120
+ const nextBatch = yield getUnspentTxs$1({
121
+ apiKey,
122
+ sochainUrl,
123
+ network,
124
+ address,
125
+ page: page + 1,
126
+ });
127
+ return txs.concat(nextBatch);
128
+ }
129
+ else {
130
+ return txs;
131
+ }
132
+ });
133
+ /**
134
+ * Get address balance.
135
+ *
136
+ * @see https://sochain.com/api#get-balance
137
+ *
138
+ * @param {string} sochainUrl The sochain node url.
139
+ * @param {string} network Network
140
+ * @param {string} address Address
141
+ * @param {boolean} confirmedOnly Flag whether to get balances of confirmed txs only or for all
142
+ * @returns {number}
143
+ */
144
+ const broadcastTx$2 = ({ apiKey, sochainUrl, network, txHex, }) => __awaiter(void 0, void 0, void 0, function* () {
145
+ const url = `${sochainUrl}/broadcast_transaction/${network}`;
146
+ const response = yield axios__default["default"].post(url, { tx_hex: txHex }, { headers: { 'API-KEY': apiKey } });
147
+ const broadcastResponse = response.data;
148
+ return broadcastResponse.tx_hex;
149
+ });
150
+
151
+ class SochainProvider {
152
+ constructor(baseUrl = 'https://sochain.com/api/v3', apiKey, chain, asset, assetDecimals, sochainNetwork) {
153
+ this.baseUrl = baseUrl;
154
+ this._apiKey = apiKey;
155
+ this.chain = chain;
156
+ this.asset = asset;
157
+ this.assetDecimals = assetDecimals;
158
+ this.sochainNetwork = sochainNetwork;
159
+ this.asset;
160
+ this.chain;
161
+ }
162
+ get apiKey() {
163
+ return this._apiKey;
164
+ }
165
+ set apiKey(value) {
166
+ this._apiKey = value;
167
+ }
168
+ broadcastTx(txHex) {
169
+ return __awaiter(this, void 0, void 0, function* () {
170
+ return yield broadcastTx$2({
171
+ apiKey: this._apiKey,
172
+ sochainUrl: this.baseUrl,
173
+ network: this.sochainNetwork,
174
+ txHex,
175
+ });
176
+ });
177
+ }
178
+ getConfirmedUnspentTxs(address) {
179
+ return __awaiter(this, void 0, void 0, function* () {
180
+ const allUnspent = yield getUnspentTxs$1({
181
+ apiKey: this._apiKey,
182
+ sochainUrl: this.baseUrl,
183
+ network: this.sochainNetwork,
184
+ address,
185
+ page: 1,
186
+ });
187
+ const confirmedUnspent = allUnspent.filter((i) => i.block); //if it has a block noumber it's been confirmed
188
+ return this.mapUTXOs(confirmedUnspent);
189
+ });
190
+ }
191
+ getUnspentTxs(address) {
192
+ return __awaiter(this, void 0, void 0, function* () {
193
+ const allUnspent = yield getUnspentTxs$1({
194
+ apiKey: this._apiKey,
195
+ sochainUrl: this.baseUrl,
196
+ network: this.sochainNetwork,
197
+ address,
198
+ page: 1,
199
+ });
200
+ return this.mapUTXOs(allUnspent);
201
+ });
202
+ }
203
+ getBalance(address, assets /*ignored*/, confirmedOnly) {
204
+ return __awaiter(this, void 0, void 0, function* () {
205
+ try {
206
+ const amount = yield getBalance$2({
207
+ apiKey: this._apiKey,
208
+ sochainUrl: this.baseUrl,
209
+ network: this.sochainNetwork,
210
+ address,
211
+ confirmedOnly: !!confirmedOnly,
212
+ assetDecimals: this.assetDecimals,
213
+ });
214
+ return [{ amount, asset: this.asset }];
215
+ }
216
+ catch (error) {
217
+ throw new Error(`Could not get balances for address ${address}`);
218
+ }
219
+ });
220
+ }
221
+ /**
222
+ * Get transaction history of a given address with pagination options.
223
+ * By default it will return the transaction history of the current wallet.
224
+ *
225
+ * @param {TxHistoryParams} params The options to get transaction history. (optional)
226
+ * @returns {TxsPage} The transaction history.
227
+ */
228
+ getTransactions(params) {
229
+ var _a;
230
+ return __awaiter(this, void 0, void 0, function* () {
231
+ const offset = (_a = params === null || params === void 0 ? void 0 : params.offset) !== null && _a !== void 0 ? _a : 0;
232
+ const limit = (params === null || params === void 0 ? void 0 : params.limit) || 10;
233
+ if (offset < 0 || limit < 0)
234
+ throw Error('ofset and limit must be equal or greater than 0');
235
+ const firstPage = Math.floor(offset / 10) + 1;
236
+ const lastPage = limit > 10 ? firstPage + Math.floor(limit / 10) : firstPage;
237
+ const offsetOnFirstPage = offset % 10;
238
+ const txHashesToFetch = [];
239
+ let page = firstPage;
240
+ try {
241
+ while (page <= lastPage) {
242
+ const response = yield getTxs$2({
243
+ apiKey: this._apiKey,
244
+ sochainUrl: this.baseUrl,
245
+ network: this.sochainNetwork,
246
+ address: `${params === null || params === void 0 ? void 0 : params.address}`,
247
+ page,
248
+ });
249
+ if (response.transactions.length === 0)
250
+ break;
251
+ if (page === firstPage && response.transactions.length > offsetOnFirstPage) {
252
+ //start from offset
253
+ const txsToGet = response.transactions.slice(offsetOnFirstPage);
254
+ this.addArrayUpToLimit(txHashesToFetch, txsToGet.map((i) => i.hash), limit);
255
+ }
256
+ else {
257
+ this.addArrayUpToLimit(txHashesToFetch, response.transactions.map((i) => i.hash), limit);
258
+ }
259
+ page++;
260
+ }
261
+ }
262
+ catch (error) {
263
+ console.error(error);
264
+ //an errors means no more results
265
+ }
266
+ const total = txHashesToFetch.length;
267
+ const transactions = yield Promise.all(txHashesToFetch.map((hash) => this.getTransactionData(hash)));
268
+ const result = {
269
+ total,
270
+ txs: transactions,
271
+ };
272
+ return result;
273
+ });
274
+ }
275
+ /**
276
+ * Get the transaction details of a given transaction id.
277
+ *
278
+ * @param {string} txId The transaction id.
279
+ * @returns {Tx} The transaction details of the given transaction id.
280
+ */
281
+ getTransactionData(txId) {
282
+ return __awaiter(this, void 0, void 0, function* () {
283
+ try {
284
+ const rawTx = yield getTx$2({
285
+ apiKey: this._apiKey,
286
+ sochainUrl: this.baseUrl,
287
+ network: this.sochainNetwork,
288
+ hash: txId,
289
+ });
290
+ return {
291
+ asset: this.asset,
292
+ from: rawTx.inputs.map((i) => ({
293
+ from: i.address,
294
+ amount: xchainUtil.assetToBase(xchainUtil.assetAmount(i.value, this.assetDecimals)),
295
+ })),
296
+ to: rawTx.outputs
297
+ .filter((i) => i.type !== 'nulldata') //filter out op_return outputs
298
+ .map((i) => ({ to: i.address, amount: xchainUtil.assetToBase(xchainUtil.assetAmount(i.value, this.assetDecimals)) })),
299
+ date: new Date(rawTx.time * 1000),
300
+ type: xchainClient.TxType.Transfer,
301
+ hash: rawTx.hash,
302
+ };
303
+ }
304
+ catch (error) {
305
+ console.error(error);
306
+ throw error;
307
+ }
308
+ });
309
+ }
310
+ mapUTXOs(utxos) {
311
+ return utxos.map((utxo) => ({
312
+ hash: utxo.hash,
313
+ index: utxo.index,
314
+ value: xchainUtil.assetToBase(xchainUtil.assetAmount(utxo.value, this.assetDecimals)).amount().toNumber(),
315
+ witnessUtxo: {
316
+ value: xchainUtil.assetToBase(xchainUtil.assetAmount(utxo.value, this.assetDecimals)).amount().toNumber(),
317
+ script: Buffer.from(utxo.script, 'hex'),
318
+ },
319
+ txHex: utxo.tx_hex,
320
+ }));
321
+ }
322
+ /**
323
+ * helper function tto limit adding to an array
324
+ *
325
+ * @param arr array to be added to
326
+ * @param toAdd elements to add
327
+ * @param limit do not add more than this limit
328
+ */
329
+ addArrayUpToLimit(arr, toAdd, limit) {
330
+ for (let index = 0; index < toAdd.length; index++) {
331
+ const element = toAdd[index];
332
+ if (arr.length < limit) {
333
+ arr.push(element);
334
+ }
335
+ }
336
+ }
337
+ }
338
+
339
+ /**
340
+ * Haskoin API types
341
+ */
342
+ exports.HaskoinNetwork = void 0;
343
+ (function (HaskoinNetwork) {
344
+ HaskoinNetwork["BTC"] = "btc";
345
+ HaskoinNetwork["BTCTEST"] = "btctest";
346
+ HaskoinNetwork["BCH"] = "bch";
347
+ HaskoinNetwork["BCHTEST"] = "bchtest";
348
+ })(exports.HaskoinNetwork || (exports.HaskoinNetwork = {}));
349
+
350
+ /**
351
+ * Module to interact with Haskoin API
352
+ *
353
+ * Doc (SwaggerHub) https://app.swaggerhub.com/apis/eligecode/blockchain-api/0.0.1-oas3
354
+ *
355
+ */
356
+ /**
357
+ * Check error response.
358
+ *
359
+ * @param {any} response The api response.
360
+ * @returns {boolean}
361
+ */
362
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
363
+ const isErrorResponse = (response) => {
364
+ return !!response.error;
11
365
  };
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- __exportStar(require("./providers"), exports);
14
- //# sourceMappingURL=index.js.map
366
+ /**
367
+ * Get account from address.
368
+ *
369
+ * @param {string} haskoinUrl The haskoin API url.
370
+ * @param {string} address The BCH address.
371
+ * @returns {AddressBalance}
372
+ *
373
+ * @throws {"failed to query account by a given address"} thrown if failed to query account by a given address
374
+ */
375
+ const getAccount = ({ haskoinUrl, network, address }) => __awaiter(void 0, void 0, void 0, function* () {
376
+ const url = `${haskoinUrl}/${network}/address/${address}/balance`;
377
+ const result = (yield axios__default["default"].get(url)).data;
378
+ if (!result || isErrorResponse(result))
379
+ throw new Error(`failed to query account by given address ${address}`);
380
+ return result;
381
+ });
382
+ /**
383
+ * Get address information.
384
+ *
385
+ * @param {string} haskoinUrl The haskoin node url.
386
+ * @param {string} network
387
+ * @param {string} address
388
+ * @returns {AddressDTO}
389
+ */
390
+ const getAddress = ({ haskoinUrl, network, address }) => __awaiter(void 0, void 0, void 0, function* () {
391
+ const url = `${haskoinUrl}/${network}/address/${address}/balance`;
392
+ const response = yield axios__default["default"].get(url);
393
+ const addressResponse = response.data;
394
+ return addressResponse.data;
395
+ });
396
+ /**
397
+ * Get transaction by hash.
398
+ *
399
+ * @param {string} haskoinUrl The haskoin API url.
400
+ * @param {string} txId The transaction id.
401
+ * @returns {Transaction}
402
+ *
403
+ * @throws {"failed to query transaction by a given hash"} thrown if failed to query transaction by a given hash
404
+ */
405
+ const getTx$1 = ({ haskoinUrl, txId, network }) => __awaiter(void 0, void 0, void 0, function* () {
406
+ const result = (yield axios__default["default"].get(`${haskoinUrl}/${network}/transaction/${txId}`)).data;
407
+ if (!result || isErrorResponse(result))
408
+ throw new Error(`failed to query transaction by a given hash ${txId}`);
409
+ return result;
410
+ });
411
+ /**
412
+ * Get raw transaction by hash.
413
+ *
414
+ * @param {string} haskoinUrl The haskoin API url.
415
+ * @param {string} txId The transaction id.
416
+ * @returns {Transaction}
417
+ *
418
+ * @throws {"failed to query transaction by a given hash"} thrown if failed to query raw transaction by a given hash
419
+ */
420
+ const getRawTransaction = ({ haskoinUrl, network, txId }) => __awaiter(void 0, void 0, void 0, function* () {
421
+ const result = (yield axios__default["default"].get(`${haskoinUrl}/${network}/transaction/${txId}/raw`))
422
+ .data;
423
+ if (!result || isErrorResponse(result))
424
+ throw new Error(`failed to query transaction by a given hash ${txId}`);
425
+ return result.result;
426
+ });
427
+ /**
428
+ * Get transactions
429
+ *
430
+ * @see https://haskoin.com/api#get-tx
431
+ *
432
+ * @param {string} haskoinUrl The haskoin node url.
433
+ * @param {string} network network id
434
+ * @param {string} hash The transaction hash.
435
+ * @returns {Transactions}
436
+ */
437
+ const getTxs$1 = ({ address, haskoinUrl, network, limit, offset, }) => __awaiter(void 0, void 0, void 0, function* () {
438
+ const params = { limit: `${limit}`, offset: `${offset}` };
439
+ const url = `${haskoinUrl}/${network}/address/${address}/transactions/full`;
440
+ const result = (yield axios__default["default"].get(url, { params })).data;
441
+ if (!result || isErrorResponse(result))
442
+ throw new Error('failed to query transactions');
443
+ return result;
444
+ });
445
+ /**
446
+ *
447
+ * @param param
448
+ * @returns Returns BaseAmount
449
+ */
450
+ const getBalance$1 = ({ haskoinUrl, haskoinNetwork, address, confirmedOnly, assetDecimals, }) => __awaiter(void 0, void 0, void 0, function* () {
451
+ const { data: { confirmed, unconfirmed }, } = yield axios__default["default"].get(`${haskoinUrl}/${haskoinNetwork}/address/${address}/balance`);
452
+ const confirmedAmount = xchainUtil.baseAmount(confirmed, assetDecimals);
453
+ const unconfirmedAmount = xchainUtil.baseAmount(unconfirmed, assetDecimals);
454
+ return confirmedOnly ? confirmedAmount : confirmedAmount.plus(unconfirmedAmount);
455
+ });
456
+ /**
457
+ * Get unspent transactions.
458
+ *
459
+ * @param {string} haskoinUrl The haskoin API url.
460
+ * @param {string} address The BCH address.
461
+ * @returns {TxUnspent[]}
462
+ *
463
+ * @throws {"failed to query unspent transactions"} thrown if failed to query unspent transactions
464
+ */
465
+ const getUnspentTxs = ({ haskoinUrl, network, address }) => __awaiter(void 0, void 0, void 0, function* () {
466
+ // Get transaction count for a given address.
467
+ const account = yield getAccount({ haskoinUrl, network, address });
468
+ // Set limit to the transaction count to be all the utxos.
469
+ const result = (yield axios__default["default"].get(`${haskoinUrl}/${network}/address/${address}/unspent?limit${account === null || account === void 0 ? void 0 : account.utxo}`)).data;
470
+ if (!result || isErrorResponse(result))
471
+ throw new Error('failed to query unspent transactions');
472
+ return result;
473
+ });
474
+ /**
475
+ * Get Tx Confirmation status
476
+ *
477
+ * @param {string} haskoinUrl The haskoin node url.
478
+ * @param {Network} network
479
+ * @param {string} hash tx id
480
+ * @returns {TxConfirmedStatus}
481
+ */
482
+ const getIsTxConfirmed = ({ haskoinUrl, network, txId }) => __awaiter(void 0, void 0, void 0, function* () {
483
+ const tx = yield getTx$1({ haskoinUrl, network, txId });
484
+ return {
485
+ network: network,
486
+ txid: txId,
487
+ confirmations: tx.confirmations,
488
+ is_confirmed: tx.confirmations >= 1,
489
+ };
490
+ });
491
+ /**
492
+ * List of confirmed txs
493
+ *
494
+ * Stores a list of confirmed txs (hashes) in memory to avoid requesting same data
495
+ */
496
+ const confirmedTxs = [];
497
+ /**
498
+ * Helper to get `confirmed` status of a tx.
499
+ *
500
+ * It will get it from cache or try to get it from haskoin (if not cached before)
501
+ */
502
+ const getConfirmedTxStatus = ({ txHash, haskoinUrl, network, }) => __awaiter(void 0, void 0, void 0, function* () {
503
+ // try to get it from cache
504
+ if (confirmedTxs.includes(txHash))
505
+ return true;
506
+ // or get status from haskoin
507
+ const { is_confirmed } = yield getIsTxConfirmed({
508
+ haskoinUrl,
509
+ network,
510
+ txId: txHash,
511
+ });
512
+ // cache status
513
+ confirmedTxs.push(txHash);
514
+ return is_confirmed;
515
+ });
516
+ /**
517
+ * Get unspent txs and filter out pending UTXOs
518
+ *
519
+ * @see https://haskoin.com/api#get-unspent-tx
520
+ *
521
+ * @param {string} haskoinUrl The haskoin node url.
522
+ * @param {Network} network
523
+ * @param {string} address
524
+ * @returns {AddressUTXO[]}
525
+ */
526
+ const getConfirmedUnspentTxs = ({ haskoinUrl, network, address }) => __awaiter(void 0, void 0, void 0, function* () {
527
+ const txs = yield getUnspentTxs({
528
+ haskoinUrl,
529
+ network,
530
+ address,
531
+ });
532
+ const confirmedUTXOs = [];
533
+ yield Promise.all(txs.map((tx) => __awaiter(void 0, void 0, void 0, function* () {
534
+ const confirmed = yield getConfirmedTxStatus({
535
+ haskoinUrl,
536
+ network,
537
+ txHash: tx.txid,
538
+ });
539
+ if (confirmed) {
540
+ confirmedUTXOs.push(tx);
541
+ }
542
+ })));
543
+ return confirmedUTXOs;
544
+ });
545
+ // Stores list of txHex in memory to avoid requesting same data
546
+ const txHexMap = {};
547
+ /**
548
+ * Helper to get `hex` of `Tx`
549
+ *
550
+ * It will try to get it from cache before requesting it from Sochain
551
+ */
552
+ const getTxHex = ({ haskoinUrl, network, txId }) => __awaiter(void 0, void 0, void 0, function* () {
553
+ // try to get hex from cache
554
+ let txHex = txHexMap[txId];
555
+ if (!!txHex)
556
+ return txHex;
557
+ // or get it from Haskoin
558
+ txHex = yield getRawTransaction({ haskoinUrl, txId: txId, network: network });
559
+ // cache it
560
+ txHexMap[txId] = txHex;
561
+ return txHex;
562
+ });
563
+ /**
564
+ * Get unspent transactions.
565
+ *
566
+ * @param {string} haskoinUrl The haskoin API url.
567
+ * @param {string} address The BCH address.
568
+ * @returns {TxUnspent[]}
569
+ *
570
+ * @throws {"failed to query unspent transactions"} thrown if failed to query unspent transactions
571
+ */
572
+ const getUnspentTransactions = ({ haskoinUrl, network, address }) => __awaiter(void 0, void 0, void 0, function* () {
573
+ // Get transaction count for a given address.
574
+ const account = yield getAccount({ haskoinUrl, network, address });
575
+ // Set limit to the transaction count to be all the utxos.
576
+ const result = (yield axios__default["default"].get(`${haskoinUrl}/${network}/address/${address}/unspent?limit${account === null || account === void 0 ? void 0 : account.utxo}`)).data;
577
+ if (!result || isErrorResponse(result))
578
+ throw new Error('failed to query unspent transactions');
579
+ return result;
580
+ });
581
+ /**
582
+ * Broadcast transaction.
583
+ *
584
+ * @see https://app.swaggerhub.com/apis/eligecode/blockchain-api/0.0.1-oas3#/blockchain/sendTransaction
585
+ *
586
+ * Note: Because of an Haskoin issue (@see https://github.com/haskoin/haskoin-store/issues/25),
587
+ * we need to broadcast same tx several times in case of `500` errors
588
+ * @see https://github.com/xchainjs/xchainjs-lib/issues/492
589
+ *
590
+ * @param {BroadcastTxParams} params
591
+ * @returns {TxHash} Transaction hash.
592
+ */
593
+ const broadcastTx$1 = ({ txHex, haskoinUrl, haskoinNetwork, }) => __awaiter(void 0, void 0, void 0, function* () {
594
+ var _a;
595
+ const MAX_RETRIES = 5;
596
+ let retries = 0;
597
+ const axiosInstance = axios__default["default"].create();
598
+ const url = `${haskoinUrl}/${haskoinNetwork}/transactions`;
599
+ while (retries < MAX_RETRIES) {
600
+ try {
601
+ const response = yield axiosInstance.post(url, txHex);
602
+ const { txid } = response.data;
603
+ return txid;
604
+ }
605
+ catch (error) {
606
+ if (((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 500) {
607
+ retries++;
608
+ yield xchainUtil.delay(200 * retries);
609
+ }
610
+ else {
611
+ return Promise.reject(error);
612
+ }
613
+ }
614
+ }
615
+ return Promise.reject(new Error('Max retries exceeded'));
616
+ });
617
+
618
+ class HaskoinProvider {
619
+ constructor(baseUrl = 'https://api.haskoin.com/', chain, asset, assetDecimals, haskoinNetwork) {
620
+ this.baseUrl = baseUrl;
621
+ this.chain = chain;
622
+ this.asset = asset;
623
+ this.assetDecimals = assetDecimals;
624
+ this.haskoinNetwork = haskoinNetwork;
625
+ this.asset;
626
+ this.chain;
627
+ }
628
+ broadcastTx(txHex) {
629
+ return __awaiter(this, void 0, void 0, function* () {
630
+ return yield broadcastTx$1({
631
+ haskoinUrl: this.baseUrl,
632
+ haskoinNetwork: this.haskoinNetwork,
633
+ txHex,
634
+ });
635
+ });
636
+ }
637
+ getConfirmedUnspentTxs(address) {
638
+ return __awaiter(this, void 0, void 0, function* () {
639
+ const allUnspent = yield getUnspentTransactions({
640
+ haskoinUrl: this.baseUrl,
641
+ network: this.haskoinNetwork,
642
+ address,
643
+ });
644
+ const confirmedUnspent = allUnspent.filter((i) => i.block); //if it has a block noumber it's been confirmed
645
+ return this.mapUTXOs(confirmedUnspent);
646
+ });
647
+ }
648
+ getUnspentTxs(address) {
649
+ return __awaiter(this, void 0, void 0, function* () {
650
+ const allUnspent = yield getUnspentTxs({
651
+ haskoinUrl: this.baseUrl,
652
+ network: this.haskoinNetwork,
653
+ address,
654
+ });
655
+ return yield this.mapUTXOs(allUnspent);
656
+ });
657
+ }
658
+ getBalance(address, assets /*ignored*/, confirmedOnly) {
659
+ return __awaiter(this, void 0, void 0, function* () {
660
+ const amount = yield getBalance$1({
661
+ haskoinUrl: this.baseUrl,
662
+ haskoinNetwork: this.haskoinNetwork,
663
+ address,
664
+ confirmedOnly: !!confirmedOnly,
665
+ assetDecimals: this.assetDecimals,
666
+ });
667
+ return [{ amount, asset: this.asset }];
668
+ });
669
+ }
670
+ /**
671
+ * Get transaction history of a given address with pagination options.
672
+ * By default it will return the transaction history of the current wallet.
673
+ *
674
+ * @param {TxHistoryParams} params The options to get transaction history. (optional)
675
+ * @returns {TxsPage} The transaction history.
676
+ */
677
+ getTransactions(params) {
678
+ var _a;
679
+ return __awaiter(this, void 0, void 0, function* () {
680
+ const offset = (_a = params === null || params === void 0 ? void 0 : params.offset) !== null && _a !== void 0 ? _a : 0;
681
+ const limit = (params === null || params === void 0 ? void 0 : params.limit) || 10;
682
+ if (offset + limit > 2000)
683
+ throw Error('cannot fetch more than last 2000 txs');
684
+ if (offset < 0 || limit < 0)
685
+ throw Error('ofset and limit must be equal or greater than 0');
686
+ const response = yield getTxs$1({
687
+ address: `${params === null || params === void 0 ? void 0 : params.address}`,
688
+ haskoinUrl: this.baseUrl,
689
+ network: this.haskoinNetwork,
690
+ limit: limit,
691
+ offset,
692
+ });
693
+ const txs = response.map((i) => this.mapTransactionToTx(i));
694
+ const result = {
695
+ total: txs.length,
696
+ txs: txs,
697
+ };
698
+ return result;
699
+ });
700
+ }
701
+ mapTransactionToTx(rawTx) {
702
+ return {
703
+ asset: this.asset,
704
+ from: rawTx.inputs.map((i) => ({
705
+ from: i.address,
706
+ amount: xchainUtil.baseAmount(i.value, this.assetDecimals),
707
+ })),
708
+ to: rawTx.outputs
709
+ .filter((i) => i.script !== 'null-data') //filter out op_return outputs
710
+ .map((i) => ({ to: i.address, amount: xchainUtil.baseAmount(i.value, this.assetDecimals) })),
711
+ date: new Date(rawTx.time),
712
+ type: xchainClient.TxType.Transfer,
713
+ hash: rawTx.txid,
714
+ };
715
+ }
716
+ /**
717
+ * Get the transaction details of a given transaction id.
718
+ *
719
+ * @param {string} txId The transaction id.
720
+ * @returns {Tx} The transaction details of the given transaction id.
721
+ */
722
+ getTransactionData(txId) {
723
+ return __awaiter(this, void 0, void 0, function* () {
724
+ try {
725
+ const rawTx = yield getTx$1({
726
+ haskoinUrl: this.baseUrl,
727
+ network: this.haskoinNetwork,
728
+ txId: txId,
729
+ });
730
+ return this.mapTransactionToTx(rawTx);
731
+ }
732
+ catch (error) {
733
+ console.error(error);
734
+ throw error;
735
+ }
736
+ });
737
+ }
738
+ /**
739
+ *
740
+ * @param utxos
741
+ * @returns utxo array
742
+ */
743
+ mapUTXOs(utxos) {
744
+ return __awaiter(this, void 0, void 0, function* () {
745
+ return yield Promise.all(utxos.map((utxo) => __awaiter(this, void 0, void 0, function* () {
746
+ return ({
747
+ hash: utxo.txid,
748
+ index: utxo.index,
749
+ value: xchainUtil.baseAmount(utxo.value, this.assetDecimals).amount().toNumber(),
750
+ witnessUtxo: {
751
+ value: xchainUtil.baseAmount(utxo.value, this.assetDecimals).amount().toNumber(),
752
+ script: Buffer.from(utxo.pkscript, 'hex'),
753
+ },
754
+ txHex: yield getTxHex({ haskoinUrl: this.baseUrl, txId: utxo.txid, network: this.haskoinNetwork }),
755
+ });
756
+ })));
757
+ });
758
+ }
759
+ }
760
+
761
+ /**
762
+ * Get transaction by hash.
763
+ *
764
+ *
765
+ * @param {string} baseUrl The sochain node url.
766
+ * @param {string} network network id
767
+ * @param {string} hash The transaction hash.
768
+ * @returns {Transactions}
769
+ */
770
+ const getTx = ({ apiKey, baseUrl, network, hash }) => __awaiter(void 0, void 0, void 0, function* () {
771
+ const params = { includeHex: 'true' };
772
+ if (apiKey)
773
+ params['token'] = apiKey;
774
+ const url = `${baseUrl}/${network}/txs/${hash}`;
775
+ const response = yield axios__default["default"].get(url, { params });
776
+ const tx = response.data;
777
+ return tx;
778
+ });
779
+ /**
780
+ * Get transactions
781
+ *
782
+ *
783
+ * @param {string} baseUrl The sochain node url.
784
+ * @param {string} network network id
785
+ * @param {string} hash The transaction hash.
786
+ * @returns {Transactions}
787
+ */
788
+ const getTxs = ({ apiKey, address, baseUrl, network, beforeBlock, limit, unspentOnly, }) => __awaiter(void 0, void 0, void 0, function* () {
789
+ const params = { limit: `${limit}`, unspentOnly: `${unspentOnly}` };
790
+ const url = `${baseUrl}/${network}/addrs/${address}`;
791
+ if (apiKey)
792
+ params['token'] = apiKey;
793
+ if (beforeBlock)
794
+ params['before'] = `${beforeBlock}`;
795
+ const response = yield axios__default["default"].get(url, { params });
796
+ const txs = response.data;
797
+ return txs;
798
+ });
799
+ /**
800
+ * Get address balance.
801
+ *
802
+ *
803
+ * @param {string} baseUrl The sochain node url.
804
+ * @param {string} network Network
805
+ * @param {string} address Address
806
+ * @param {boolean} confirmedOnly Flag whether to get balances of confirmed txs only or for all
807
+ * @returns {number}
808
+ */
809
+ const getBalance = ({ apiKey, baseUrl, network, address, confirmedOnly, assetDecimals, }) => __awaiter(void 0, void 0, void 0, function* () {
810
+ const params = {};
811
+ const url = `${baseUrl}/${network}/addrs/${address}/balance`;
812
+ if (apiKey)
813
+ params['token'] = apiKey;
814
+ const response = yield axios__default["default"].get(url, { params });
815
+ const balanceResponse = response.data;
816
+ const confirmedAmount = xchainUtil.baseAmount(balanceResponse.balance, assetDecimals);
817
+ const finalBalance = xchainUtil.baseAmount(balanceResponse.final_balance, assetDecimals);
818
+ return confirmedOnly ? confirmedAmount : finalBalance;
819
+ });
820
+ const broadcastTx = ({ apiKey, baseUrl, network, txHex, }) => __awaiter(void 0, void 0, void 0, function* () {
821
+ const params = {};
822
+ const url = `${baseUrl}/${network}/txs/push`;
823
+ if (apiKey)
824
+ params['token'] = apiKey;
825
+ const response = yield axios__default["default"].post(url, { tx: txHex }, { params });
826
+ const broadcastResponse = response.data;
827
+ return broadcastResponse.tx.hash;
828
+ });
829
+
830
+ class BlockcypherProvider {
831
+ constructor(baseUrl = 'https://api.blockcypher.com/v1/', chain, asset, assetDecimals, blockcypherNetwork, apiKey) {
832
+ this.baseUrl = baseUrl;
833
+ this._apiKey = apiKey;
834
+ this.chain = chain;
835
+ this.asset = asset;
836
+ this.assetDecimals = assetDecimals;
837
+ this.blockcypherNetwork = blockcypherNetwork;
838
+ this.asset;
839
+ this.chain;
840
+ }
841
+ get apiKey() {
842
+ return this._apiKey;
843
+ }
844
+ set apiKey(value) {
845
+ this._apiKey = value;
846
+ }
847
+ broadcastTx(txHex) {
848
+ return __awaiter(this, void 0, void 0, function* () {
849
+ return yield broadcastTx({
850
+ apiKey: this._apiKey,
851
+ baseUrl: this.baseUrl,
852
+ network: this.blockcypherNetwork,
853
+ txHex,
854
+ });
855
+ });
856
+ }
857
+ getConfirmedUnspentTxs(address) {
858
+ return __awaiter(this, void 0, void 0, function* () {
859
+ const allUnspent = yield this.getRawTransactions({ address, offset: 0, limit: 2000 }, true);
860
+ return this.mapUTXOs(address, allUnspent.filter((i) => i.confirmed));
861
+ });
862
+ }
863
+ getUnspentTxs(address) {
864
+ return __awaiter(this, void 0, void 0, function* () {
865
+ const allUnspent = yield this.getRawTransactions({ address, offset: 0, limit: 2000 }, true);
866
+ return this.mapUTXOs(address, allUnspent);
867
+ });
868
+ }
869
+ getBalance(address, assets /*ignored*/, confirmedOnly) {
870
+ return __awaiter(this, void 0, void 0, function* () {
871
+ const amount = yield getBalance({
872
+ apiKey: this._apiKey,
873
+ baseUrl: this.baseUrl,
874
+ network: this.blockcypherNetwork,
875
+ address,
876
+ confirmedOnly: !!confirmedOnly,
877
+ assetDecimals: this.assetDecimals,
878
+ });
879
+ return [{ amount, asset: this.asset }];
880
+ });
881
+ }
882
+ /**
883
+ * Get transaction history of a given address with pagination options.
884
+ * By default it will return the transaction history of the current wallet.
885
+ *
886
+ * @param {TxHistoryParams} params The options to get transaction history. (optional)
887
+ * @returns {TxsPage} The transaction history.
888
+ */
889
+ getTransactions(params, unspentOnly = false) {
890
+ return __awaiter(this, void 0, void 0, function* () {
891
+ const rawTxs = yield this.getRawTransactions(params, unspentOnly);
892
+ const txs = rawTxs.map((i) => this.mapTransactionToTx(i));
893
+ const result = {
894
+ total: txs.length,
895
+ txs,
896
+ };
897
+ return result;
898
+ });
899
+ }
900
+ /**
901
+ * Get the transaction details of a given transaction id.
902
+ *
903
+ * @param {string} txId The transaction id.
904
+ * @returns {Tx} The transaction details of the given transaction id.
905
+ */
906
+ getTransactionData(txId) {
907
+ return __awaiter(this, void 0, void 0, function* () {
908
+ try {
909
+ const rawTx = yield getTx({
910
+ apiKey: this._apiKey,
911
+ baseUrl: this.baseUrl,
912
+ network: this.blockcypherNetwork,
913
+ hash: txId,
914
+ });
915
+ return this.mapTransactionToTx(rawTx);
916
+ }
917
+ catch (error) {
918
+ console.error(error);
919
+ throw error;
920
+ }
921
+ });
922
+ }
923
+ mapTransactionToTx(rawTx) {
924
+ return {
925
+ asset: this.asset,
926
+ from: rawTx.inputs.map((i) => ({
927
+ from: i.addresses[0],
928
+ amount: xchainUtil.baseAmount(i.output_value, this.assetDecimals),
929
+ })),
930
+ to: rawTx.outputs
931
+ .filter((i) => i.script_type !== 'null-data') //filter out op_return outputs
932
+ .map((i) => ({ to: i.addresses[0], amount: xchainUtil.baseAmount(i.value, this.assetDecimals) })),
933
+ date: new Date(rawTx.confirmed),
934
+ type: xchainClient.TxType.Transfer,
935
+ hash: rawTx.hash,
936
+ };
937
+ }
938
+ mapUTXOs(address, utxos) {
939
+ const utxosOut = [];
940
+ for (let index = 0; index < utxos.length; index++) {
941
+ const utxo = utxos[index];
942
+ for (let index2 = 0; index2 < utxo.outputs.length; index2++) {
943
+ const output = utxo.outputs[index2];
944
+ if (output.addresses && output.addresses[0] === address) {
945
+ const utxoOut = {
946
+ hash: utxo.hash,
947
+ index: index2,
948
+ value: xchainUtil.baseAmount(output.value, this.assetDecimals).amount().toNumber(),
949
+ witnessUtxo: {
950
+ value: xchainUtil.baseAmount(output.value, this.assetDecimals).amount().toNumber(),
951
+ script: Buffer.from(output.script, 'hex'),
952
+ },
953
+ txHex: utxo.hex,
954
+ };
955
+ utxosOut.push(utxoOut);
956
+ }
957
+ }
958
+ }
959
+ return utxosOut;
960
+ }
961
+ /**
962
+ * helper function tto limit adding to an array
963
+ *
964
+ * @param arr array to be added to
965
+ * @param toAdd elements to add
966
+ * @param limit do not add more than this limit
967
+ */
968
+ addArrayUpToLimit(arr, toAdd, limit) {
969
+ for (let index = 0; index < toAdd.length; index++) {
970
+ const element = toAdd[index];
971
+ if (arr.length < limit) {
972
+ arr.push(element);
973
+ }
974
+ }
975
+ }
976
+ delay(ms) {
977
+ return new Promise((resolve) => setTimeout(resolve, ms));
978
+ }
979
+ /**
980
+ * Get transaction history of a given address with pagination options.
981
+ * By default it will return the transaction history of the current wallet.
982
+ *
983
+ * @param {TxHistoryParams} params The options to get transaction history. (optional)
984
+ * @returns {TxsPage} The transaction history.
985
+ */
986
+ getRawTransactions(params, unspentOnly = false) {
987
+ var _a;
988
+ return __awaiter(this, void 0, void 0, function* () {
989
+ const offset = (_a = params === null || params === void 0 ? void 0 : params.offset) !== null && _a !== void 0 ? _a : 0;
990
+ const limit = (params === null || params === void 0 ? void 0 : params.limit) || 10;
991
+ if (offset + limit > 2000)
992
+ throw Error('cannot fetch more than last 2000 txs');
993
+ if (offset < 0 || limit < 0)
994
+ throw Error('ofset and limit must be equal or greater than 0');
995
+ const txHashesToFetch = [];
996
+ try {
997
+ const response = yield getTxs({
998
+ apiKey: this._apiKey,
999
+ baseUrl: this.baseUrl,
1000
+ network: this.blockcypherNetwork,
1001
+ address: `${params === null || params === void 0 ? void 0 : params.address}`,
1002
+ limit: 2000,
1003
+ unspentOnly,
1004
+ });
1005
+ //remove duplicates
1006
+ const txs = response.txrefs.map((i) => i.tx_hash);
1007
+ const uniqTxs = [...new Set(txs)];
1008
+ const start = offset >= uniqTxs.length ? uniqTxs.length : offset;
1009
+ const end = offset + limit >= uniqTxs.length ? uniqTxs.length : offset + limit;
1010
+ const txsToFetch = uniqTxs.slice(start, end);
1011
+ // console.log(JSON.stringify(txsToFetch, null, 2))
1012
+ this.addArrayUpToLimit(txHashesToFetch, txsToFetch, limit);
1013
+ }
1014
+ catch (error) {
1015
+ console.error(error);
1016
+ //an errors means no more results
1017
+ }
1018
+ //note: blockcypher has rate of 3 req/sec --> https://www.blockcypher.com/dev/bitcoin/#rate-limits-and-tokens
1019
+ const batchResult = yield PromisePool__default["default"].for(txHashesToFetch)
1020
+ .withConcurrency(3)
1021
+ .useCorrespondingResults()
1022
+ .process((hash) => __awaiter(this, void 0, void 0, function* () {
1023
+ yield this.delay(1000);
1024
+ const rawTx = yield getTx({
1025
+ apiKey: this._apiKey,
1026
+ baseUrl: this.baseUrl,
1027
+ network: this.blockcypherNetwork,
1028
+ hash,
1029
+ });
1030
+ return rawTx;
1031
+ }));
1032
+ return batchResult.results;
1033
+ });
1034
+ }
1035
+ }
1036
+
1037
+ exports.BlockcypherNetwork = void 0;
1038
+ (function (BlockcypherNetwork) {
1039
+ BlockcypherNetwork["BTC"] = "btc/main";
1040
+ BlockcypherNetwork["BTCTEST"] = "btc/test3";
1041
+ BlockcypherNetwork["LTC"] = "ltc/main";
1042
+ BlockcypherNetwork["DOGE"] = "doge/main";
1043
+ })(exports.BlockcypherNetwork || (exports.BlockcypherNetwork = {}));
1044
+
1045
+ exports.BlockcypherProvider = BlockcypherProvider;
1046
+ exports.HaskoinProvider = HaskoinProvider;
1047
+ exports.SochainProvider = SochainProvider;
1048
+ exports.broadcastTx = broadcastTx$1;
1049
+ exports.getAccount = getAccount;
1050
+ exports.getAddress = getAddress;
1051
+ exports.getBalance = getBalance$1;
1052
+ exports.getConfirmedTxStatus = getConfirmedTxStatus;
1053
+ exports.getConfirmedUnspentTxs = getConfirmedUnspentTxs;
1054
+ exports.getIsTxConfirmed = getIsTxConfirmed;
1055
+ exports.getTx = getTx$1;
1056
+ exports.getTxs = getTxs$1;
1057
+ exports.getUnspentTxs = getUnspentTxs;