@pioneer-platform/utxo-network 8.1.60 → 8.1.62
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/lib/index.js +60 -128
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -2,104 +2,27 @@
|
|
|
2
2
|
/*
|
|
3
3
|
Anycoin Nodes:
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Types of nodes
|
|
6
6
|
|
|
7
|
+
Daemons: raw coin nodes
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
cointainers
|
|
9
|
+
Blockbook: blockbook indexed nodes (address index)
|
|
10
10
|
|
|
11
|
+
Unchained: shapeshift custom API nodes
|
|
11
12
|
|
|
12
|
-
Tier 1
|
|
13
13
|
|
|
14
|
-
https://www.blockchain.com/explorer
|
|
15
|
-
BTC: BCH ETH
|
|
16
|
-
https://www.blockchain.com/api/q
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
Indexers
|
|
20
|
-
|
|
21
|
-
Tier 0
|
|
22
|
-
* coinquery
|
|
23
|
-
|
|
24
|
-
Blockbook
|
|
25
|
-
* nodes: ['btc1.trezor.io', 'btc2.trezor.io'],
|
|
26
|
-
|
|
27
|
-
electrumx
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
Tier 1
|
|
32
|
-
|
|
33
|
-
(no segwit)
|
|
34
|
-
* Bitpay
|
|
35
|
-
https://insight.bitpay.com/api
|
|
36
|
-
|
|
37
|
-
https://chain.api.btc.com/v3/block/latest/tx?verbose=2
|
|
38
|
-
|
|
39
|
-
(segwit)
|
|
40
|
-
https://api.smartbit.com.au/v1/blockchain/tx/
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
Notes on batching jsonrpc
|
|
44
|
-
https://bitcoin.stackexchange.com/questions/89066/how-to-scale-json-rpc
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
Blockbook docs
|
|
48
|
-
https://www.npmjs.com/package/blockbook-client
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
electrum server lists
|
|
53
|
-
|
|
54
|
-
BTC:
|
|
55
|
-
More: https://uasf.saltylemon.org/electrum
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
'erbium1.sytes.net':DEFAULT_PORTS, # core, e-x
|
|
59
|
-
'ecdsa.net':{'t':'50001', 's':'110'}, # core, e-x
|
|
60
|
-
'gh05.geekhosters.com':DEFAULT_PORTS, # core, e-s
|
|
61
|
-
'VPS.hsmiths.com':DEFAULT_PORTS, # core, e-x
|
|
62
|
-
'electrum.anduck.net':DEFAULT_PORTS, # core, e-s; banner with version pending
|
|
63
|
-
'electrum.no-ip.org':DEFAULT_PORTS, # core, e-s
|
|
64
|
-
'electrum.be':DEFAULT_PORTS, # core, e-x
|
|
65
|
-
'helicarrier.bauerj.eu':DEFAULT_PORTS, # core, e-x
|
|
66
|
-
'elex01.blackpole.online':DEFAULT_PORTS, # core, e-x
|
|
67
|
-
'electrumx.not.fyi':DEFAULT_PORTS, # core, e-x
|
|
68
|
-
'node.xbt.eu':DEFAULT_PORTS, # core, e-x
|
|
69
|
-
'kirsche.emzy.de':DEFAULT_PORTS, # core, e-x
|
|
70
|
-
'electrum.villocq.com':DEFAULT_PORTS, # core?, e-s; banner with version recommended
|
|
71
|
-
'us11.einfachmalnettsein.de':DEFAULT_PORTS, # core, e-x
|
|
72
|
-
'electrum.trouth.net':DEFAULT_PORTS, # BU, e-s
|
|
73
|
-
'Electrum.hsmiths.com':{'t':'8080', 's':'995'}, # core, e-x
|
|
74
|
-
'electrum3.hachre.de':DEFAULT_PORTS, # core, e-x
|
|
75
|
-
'b.1209k.com':DEFAULT_PORTS, # XT, jelectrum
|
|
76
|
-
'elec.luggs.co':{ 's':'443'}, # core, e-x
|
|
77
|
-
'btc.smsys.me':{'t':'110', 's':'995'}, # BU, e-x
|
|
78
|
-
|
|
79
|
-
BTC (testnet)
|
|
80
|
-
|
|
81
|
-
'testnetnode.arihanc.com': DEFAULT_PORTS,
|
|
82
|
-
'testnet1.bauerj.eu': DEFAULT_PORTS,
|
|
83
|
-
'14.3.140.101': DEFAULT_PORTS,
|
|
84
|
-
'testnet.hsmiths.com': {'t':'53011', 's':'53012'},
|
|
85
|
-
'electrum.akinbo.org': DEFAULT_PORTS,
|
|
86
|
-
'ELEX05.blackpole.online': {'t':'52011', 's':'52002'},
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
LTC:
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
BCH:
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
DOGE:
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
DASH:
|
|
102
14
|
|
|
15
|
+
Uncchained Spec
|
|
16
|
+
{
|
|
17
|
+
GetInfo: [Function (anonymous)],
|
|
18
|
+
GetAccount: [Function (anonymous)],
|
|
19
|
+
GetTxHistory: [Function (anonymous)],
|
|
20
|
+
GetUtxos: [Function (anonymous)],
|
|
21
|
+
GetTransaction: [Function (anonymous)],
|
|
22
|
+
GetRawTransaction: [Function (anonymous)],
|
|
23
|
+
SendTx: [Function (anonymous)],
|
|
24
|
+
GetNetworkFees: [Function (anonymous)]
|
|
25
|
+
}
|
|
103
26
|
|
|
104
27
|
|
|
105
28
|
*/
|
|
@@ -303,7 +226,7 @@ var init_network = function (servers) {
|
|
|
303
226
|
return __generator(this, function (_a) {
|
|
304
227
|
switch (_a.label) {
|
|
305
228
|
case 0:
|
|
306
|
-
tag = ' |
|
|
229
|
+
tag = ' | init_network | ';
|
|
307
230
|
_a.label = 1;
|
|
308
231
|
case 1:
|
|
309
232
|
_a.trys.push([1, 4, , 5]);
|
|
@@ -323,11 +246,15 @@ var init_network = function (servers) {
|
|
|
323
246
|
// log.debug(tag,"blockbooks: ",blockbooks)
|
|
324
247
|
_a.sent();
|
|
325
248
|
unchainedServers = servers.filter(function (server) { return server.type === 'unchained'; });
|
|
326
|
-
|
|
327
|
-
|
|
249
|
+
return [4 /*yield*/, Unchained.init(unchainedServers)
|
|
250
|
+
//log.info("unchained: ",unchained)
|
|
251
|
+
//figure out what is online, and if can meet blockchain requirements
|
|
252
|
+
//return online servers
|
|
253
|
+
];
|
|
328
254
|
case 3:
|
|
255
|
+
//log.info(tag,"unchainedServers: ",unchainedServers)
|
|
329
256
|
unchained = _a.sent();
|
|
330
|
-
log.info("unchained: ",
|
|
257
|
+
//log.info("unchained: ",unchained)
|
|
331
258
|
//figure out what is online, and if can meet blockchain requirements
|
|
332
259
|
//return online servers
|
|
333
260
|
return [2 /*return*/, true];
|
|
@@ -425,42 +352,35 @@ var get_fees_with_rates = function (coin, memo) {
|
|
|
425
352
|
};
|
|
426
353
|
var get_fee = function (coin) {
|
|
427
354
|
return __awaiter(this, void 0, void 0, function () {
|
|
428
|
-
var tag, output,
|
|
355
|
+
var tag, output, result, e_5;
|
|
429
356
|
return __generator(this, function (_a) {
|
|
430
357
|
switch (_a.label) {
|
|
431
358
|
case 0:
|
|
432
359
|
tag = TAG + " | get_fee | ";
|
|
433
360
|
_a.label = 1;
|
|
434
361
|
case 1:
|
|
435
|
-
_a.trys.push([1,
|
|
362
|
+
_a.trys.push([1, 5, , 6]);
|
|
436
363
|
output = {};
|
|
437
364
|
log.info(tag, "coin: ", coin);
|
|
438
|
-
if (!(coin === 'BTC')) return [3 /*break*/, 3];
|
|
439
|
-
query = "https://bitcoinfees.earn.com/api/v1/fees/recommended";
|
|
440
|
-
return [4 /*yield*/, axios({ method: 'GET', url: query })];
|
|
441
|
-
case 2:
|
|
442
|
-
output = _a.sent();
|
|
443
|
-
log.debug(tag, "output: ", output.data);
|
|
444
|
-
output = output.data.fastestFee;
|
|
445
|
-
return [3 /*break*/, 6];
|
|
446
|
-
case 3:
|
|
447
365
|
log.info(tag, "caip: ", SYMBOL_TO_CAIP[coin]);
|
|
448
|
-
if (!unchained[SYMBOL_TO_CAIP[coin]]) return [3 /*break*/,
|
|
449
|
-
return [4 /*yield*/, unchained[SYMBOL_TO_CAIP[coin]].GetNetworkFees()
|
|
450
|
-
|
|
366
|
+
if (!unchained[SYMBOL_TO_CAIP[coin]]) return [3 /*break*/, 3];
|
|
367
|
+
return [4 /*yield*/, unchained[SYMBOL_TO_CAIP[coin]].GetNetworkFees()
|
|
368
|
+
//console.log("result: ",result.data)
|
|
369
|
+
];
|
|
370
|
+
case 2:
|
|
451
371
|
result = _a.sent();
|
|
452
|
-
console.log("result: ",
|
|
372
|
+
//console.log("result: ",result.data)
|
|
453
373
|
output = result.data;
|
|
454
|
-
return [3 /*break*/,
|
|
455
|
-
case
|
|
374
|
+
return [3 /*break*/, 4];
|
|
375
|
+
case 3:
|
|
456
376
|
console.log("no unchained for coin: ", coin);
|
|
457
|
-
_a.label =
|
|
458
|
-
case
|
|
459
|
-
case
|
|
377
|
+
_a.label = 4;
|
|
378
|
+
case 4: return [2 /*return*/, output];
|
|
379
|
+
case 5:
|
|
460
380
|
e_5 = _a.sent();
|
|
461
381
|
console.error(tag, e_5);
|
|
462
|
-
return [3 /*break*/,
|
|
463
|
-
case
|
|
382
|
+
return [3 /*break*/, 6];
|
|
383
|
+
case 6: return [2 /*return*/];
|
|
464
384
|
}
|
|
465
385
|
});
|
|
466
386
|
});
|
|
@@ -625,24 +545,36 @@ var get_balance_by_address = function (coin, address) {
|
|
|
625
545
|
};
|
|
626
546
|
var get_utxos_by_xpub = function (coin, xpub) {
|
|
627
547
|
return __awaiter(this, void 0, void 0, function () {
|
|
628
|
-
var tag, output, e_11;
|
|
548
|
+
var tag, output, result, e_11;
|
|
629
549
|
return __generator(this, function (_a) {
|
|
630
550
|
switch (_a.label) {
|
|
631
551
|
case 0:
|
|
632
552
|
tag = TAG + " | get_utxos_by_xpub | ";
|
|
633
553
|
_a.label = 1;
|
|
634
554
|
case 1:
|
|
635
|
-
_a.trys.push([1,
|
|
636
|
-
|
|
555
|
+
_a.trys.push([1, 5, , 6]);
|
|
556
|
+
output = {};
|
|
557
|
+
if (!unchained[SYMBOL_TO_CAIP[coin]]) return [3 /*break*/, 3];
|
|
558
|
+
return [4 /*yield*/, unchained[SYMBOL_TO_CAIP[coin]].GetUtxos({ pubkey: xpub })
|
|
559
|
+
//console.log("result: ",result.data)
|
|
560
|
+
];
|
|
637
561
|
case 2:
|
|
638
|
-
|
|
639
|
-
log
|
|
640
|
-
|
|
562
|
+
result = _a.sent();
|
|
563
|
+
//console.log("result: ",result.data)
|
|
564
|
+
output = result.data;
|
|
565
|
+
return [3 /*break*/, 4];
|
|
641
566
|
case 3:
|
|
567
|
+
console.log("no unchained for coin: ", coin);
|
|
568
|
+
//@TODO fall back to node
|
|
569
|
+
output.success = false;
|
|
570
|
+
output.error = "no unchained for coin: " + coin;
|
|
571
|
+
_a.label = 4;
|
|
572
|
+
case 4: return [2 /*return*/, output];
|
|
573
|
+
case 5:
|
|
642
574
|
e_11 = _a.sent();
|
|
643
575
|
console.error(tag, e_11);
|
|
644
|
-
|
|
645
|
-
case
|
|
576
|
+
throw e_11;
|
|
577
|
+
case 6: return [2 /*return*/];
|
|
646
578
|
}
|
|
647
579
|
});
|
|
648
580
|
});
|
|
@@ -731,7 +663,7 @@ var get_txs_by_xpub = function (coin, xpub) {
|
|
|
731
663
|
return __awaiter(this, void 0, void 0, function () {
|
|
732
664
|
var tag, output, url;
|
|
733
665
|
return __generator(this, function (_a) {
|
|
734
|
-
tag = ' |
|
|
666
|
+
tag = ' | get_txs_by_xpub | ';
|
|
735
667
|
try {
|
|
736
668
|
log.debug(tag, "checkpoint: ", xpub);
|
|
737
669
|
output = [];
|
|
@@ -804,7 +736,7 @@ var get_txs_by_xpubs = function (coin, xpub) {
|
|
|
804
736
|
return __awaiter(this, void 0, void 0, function () {
|
|
805
737
|
var tag, output, txInfo, url;
|
|
806
738
|
return __generator(this, function (_a) {
|
|
807
|
-
tag = ' |
|
|
739
|
+
tag = ' | get_txs_by_xpubs | ';
|
|
808
740
|
try {
|
|
809
741
|
log.debug(tag, "checkpoint: ", xpub);
|
|
810
742
|
output = [];
|