@pioneer-platform/blockbook 8.20.0 → 8.25.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.
- package/CHANGELOG.md +61 -0
- package/build +22 -0
- package/lib/index.d.ts +10 -0
- package/lib/index.js +188 -51
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,66 @@
|
|
|
1
1
|
# @pioneer-platform/blockbook
|
|
2
2
|
|
|
3
|
+
## 8.25.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- chore: feat(pioneer-server): Migrate from Bun to Node.js for Blockbook WebSocket compatibility
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
- @pioneer-platform/nodes@8.24.0
|
|
13
|
+
|
|
14
|
+
## 8.24.0
|
|
15
|
+
|
|
16
|
+
### Minor Changes
|
|
17
|
+
|
|
18
|
+
- feat(pioneer-server): Migrate from Bun to Node.js for Blockbook WebSocket compatibility
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- Updated dependencies
|
|
23
|
+
- @pioneer-platform/nodes@8.23.0
|
|
24
|
+
|
|
25
|
+
## 8.23.0
|
|
26
|
+
|
|
27
|
+
### Minor Changes
|
|
28
|
+
|
|
29
|
+
- feat(pioneer-server): Migrate from Bun to Node.js for Blockbook WebSocket compatibility
|
|
30
|
+
|
|
31
|
+
### Patch Changes
|
|
32
|
+
|
|
33
|
+
- Updated dependencies
|
|
34
|
+
- @pioneer-platform/nodes@8.22.0
|
|
35
|
+
|
|
36
|
+
## 8.22.0
|
|
37
|
+
|
|
38
|
+
### Minor Changes
|
|
39
|
+
|
|
40
|
+
- feat(pioneer-server): Migrate from Bun to Node.js for Blockbook WebSocket compatibility
|
|
41
|
+
|
|
42
|
+
### Patch Changes
|
|
43
|
+
|
|
44
|
+
- Updated dependencies
|
|
45
|
+
- @pioneer-platform/nodes@8.21.0
|
|
46
|
+
|
|
47
|
+
## 8.21.0
|
|
48
|
+
|
|
49
|
+
### Minor Changes
|
|
50
|
+
|
|
51
|
+
- feat(pioneer-server): Migrate from Bun to Node.js for Blockbook WebSocket compatibility
|
|
52
|
+
|
|
53
|
+
### Patch Changes
|
|
54
|
+
|
|
55
|
+
- Updated dependencies
|
|
56
|
+
- @pioneer-platform/nodes@8.20.0
|
|
57
|
+
|
|
58
|
+
## 8.20.1
|
|
59
|
+
|
|
60
|
+
### Patch Changes
|
|
61
|
+
|
|
62
|
+
- fix(pioneer-server): Fix Blockbook WebSocket event system initialization
|
|
63
|
+
|
|
3
64
|
## 8.20.0
|
|
4
65
|
|
|
5
66
|
### Minor Changes
|
package/build
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Fast Bun build (replaces slow tsc)
|
|
3
|
+
|
|
4
|
+
OUTDIR="${1:-lib}"
|
|
5
|
+
ENTRY="${2:-src/index.ts}"
|
|
6
|
+
|
|
7
|
+
# Clean output
|
|
8
|
+
rm -rf "$OUTDIR"
|
|
9
|
+
mkdir -p "$OUTDIR"
|
|
10
|
+
|
|
11
|
+
# Build with Bun (10x faster than tsc)
|
|
12
|
+
bun build "$ENTRY" \
|
|
13
|
+
--outdir "$OUTDIR" \
|
|
14
|
+
--target node \
|
|
15
|
+
--format cjs \
|
|
16
|
+
--sourcemap \
|
|
17
|
+
--minify
|
|
18
|
+
|
|
19
|
+
# Generate TypeScript declarations
|
|
20
|
+
bunx tsc --emitDeclarationOnly --outDir "$OUTDIR" --project .
|
|
21
|
+
|
|
22
|
+
echo "✅ Built $OUTDIR"
|
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
declare const TAG = " | blockbook-client | ";
|
|
2
2
|
declare const Blockbook: any;
|
|
3
3
|
declare const log: any;
|
|
4
|
+
/**
|
|
5
|
+
* Stringify error for single-line logging
|
|
6
|
+
* Handles AxiosError, Error objects, and unknown types
|
|
7
|
+
*/
|
|
8
|
+
declare const stringifyError: (e: any) => string;
|
|
9
|
+
/**
|
|
10
|
+
* Convert DGB dgub format to xpub format for blockbook compatibility
|
|
11
|
+
* NowNodes blockbook doesn't accept dgub format
|
|
12
|
+
*/
|
|
13
|
+
declare const convertDgubToXpub: (pubkey: string, symbol: string) => string;
|
|
4
14
|
declare const fakeUa: any;
|
|
5
15
|
declare const axiosLib: any;
|
|
6
16
|
declare const Axios: any;
|
package/lib/index.js
CHANGED
|
@@ -42,6 +42,67 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
42
42
|
var TAG = " | blockbook-client | ";
|
|
43
43
|
var Blockbook = require('blockbook-client').Blockbook;
|
|
44
44
|
var log = require('@pioneer-platform/loggerdog')();
|
|
45
|
+
/**
|
|
46
|
+
* Stringify error for single-line logging
|
|
47
|
+
* Handles AxiosError, Error objects, and unknown types
|
|
48
|
+
*/
|
|
49
|
+
var stringifyError = function (e) {
|
|
50
|
+
var _a, _b, _c, _d, _e, _f;
|
|
51
|
+
if (!e)
|
|
52
|
+
return 'Unknown error';
|
|
53
|
+
// Handle AxiosError specifically
|
|
54
|
+
if (e.isAxiosError) {
|
|
55
|
+
return JSON.stringify({
|
|
56
|
+
message: e.message,
|
|
57
|
+
code: e.code,
|
|
58
|
+
status: (_a = e.response) === null || _a === void 0 ? void 0 : _a.status,
|
|
59
|
+
statusText: (_b = e.response) === null || _b === void 0 ? void 0 : _b.statusText,
|
|
60
|
+
url: (_c = e.config) === null || _c === void 0 ? void 0 : _c.url,
|
|
61
|
+
method: (_d = e.config) === null || _d === void 0 ? void 0 : _d.method,
|
|
62
|
+
data: (_e = e.response) === null || _e === void 0 ? void 0 : _e.data
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
// Handle standard Error objects
|
|
66
|
+
if (e instanceof Error) {
|
|
67
|
+
return JSON.stringify({
|
|
68
|
+
name: e.name,
|
|
69
|
+
message: e.message,
|
|
70
|
+
stack: (_f = e.stack) === null || _f === void 0 ? void 0 : _f.split('\n').slice(0, 3).join(' | ') // First 3 lines only
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
// Handle everything else
|
|
74
|
+
try {
|
|
75
|
+
return JSON.stringify(e);
|
|
76
|
+
}
|
|
77
|
+
catch (_g) {
|
|
78
|
+
return String(e);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Convert DGB dgub format to xpub format for blockbook compatibility
|
|
83
|
+
* NowNodes blockbook doesn't accept dgub format
|
|
84
|
+
*/
|
|
85
|
+
var convertDgubToXpub = function (pubkey, symbol) {
|
|
86
|
+
if (symbol === 'DGB' && pubkey.startsWith('dgub')) {
|
|
87
|
+
var b58 = require('bs58');
|
|
88
|
+
try {
|
|
89
|
+
var data = b58.decode(pubkey);
|
|
90
|
+
var payload = data.slice(4);
|
|
91
|
+
var xpubPrefix = Buffer.from('0488b21e', 'hex');
|
|
92
|
+
var convertedData = Buffer.concat([xpubPrefix, payload]);
|
|
93
|
+
var convertedXpub = b58.encode(convertedData);
|
|
94
|
+
log.info(TAG, "Converting DGB dgub to xpub format for blockbook compatibility");
|
|
95
|
+
log.info(TAG, "Original: ".concat(pubkey.substring(0, 20), "..."));
|
|
96
|
+
log.info(TAG, "Converted: ".concat(convertedXpub.substring(0, 20), "..."));
|
|
97
|
+
return convertedXpub;
|
|
98
|
+
}
|
|
99
|
+
catch (conversionError) {
|
|
100
|
+
log.error(TAG, "Failed to convert dgub to xpub: ".concat(stringifyError(conversionError)));
|
|
101
|
+
return pubkey; // Return original if conversion fails
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return pubkey;
|
|
105
|
+
};
|
|
45
106
|
var fakeUa = require('fake-useragent');
|
|
46
107
|
var axiosLib = require('axios');
|
|
47
108
|
var Axios = axiosLib.default || axiosLib;
|
|
@@ -237,29 +298,34 @@ var init_network = function (servers) {
|
|
|
237
298
|
return __generator(this, function (_a) {
|
|
238
299
|
switch (_a.label) {
|
|
239
300
|
case 0:
|
|
240
|
-
tag = ' |
|
|
301
|
+
tag = ' | blockbook-module | ';
|
|
241
302
|
_a.label = 1;
|
|
242
303
|
case 1:
|
|
243
304
|
_a.trys.push([1, 3, , 4]);
|
|
305
|
+
console.log('[DEBUG] init_network CALLED');
|
|
244
306
|
log.debug(tag, "checkpoint: ");
|
|
245
307
|
return [4 /*yield*/, nodes.getBlockbooks()];
|
|
246
308
|
case 2:
|
|
247
309
|
SEED_NODES = _a.sent();
|
|
310
|
+
console.log('[DEBUG] SEED_NODES loaded:', SEED_NODES.length, 'blockbooks');
|
|
248
311
|
log.info(tag, "SEED_NODES: ", SEED_NODES);
|
|
249
312
|
blockbooks = [];
|
|
250
313
|
if (servers && Array.isArray(servers)) { // Type checking for array
|
|
251
314
|
blockbooks = servers.concat(SEED_NODES); // Combine arrays
|
|
252
315
|
}
|
|
253
316
|
else {
|
|
254
|
-
|
|
317
|
+
log.warn("Invalid 'servers' parameter. Expected an array.");
|
|
255
318
|
blockbooks = SEED_NODES;
|
|
256
319
|
}
|
|
320
|
+
console.log('[DEBUG] Total blockbooks to process:', blockbooks.length);
|
|
257
321
|
log.debug(tag, "blockbooks: ", blockbooks.length);
|
|
258
322
|
// Clear existing nodes
|
|
259
323
|
BLOCKBOOK_NODES = {};
|
|
260
324
|
// Process nodes with priority assignment
|
|
325
|
+
console.log('[DEBUG] Processing', blockbooks.length, 'blockbooks...');
|
|
261
326
|
for (i = 0; i < blockbooks.length; i++) {
|
|
262
327
|
blockbook = blockbooks[i];
|
|
328
|
+
console.log('[DEBUG] Processing blockbook', i + 1, '/', blockbooks.length, ':', blockbook.symbol);
|
|
263
329
|
if (blockbook && blockbook.service) {
|
|
264
330
|
symbol = blockbook.symbol.toUpperCase();
|
|
265
331
|
priority = 50;
|
|
@@ -277,6 +343,7 @@ var init_network = function (servers) {
|
|
|
277
343
|
}
|
|
278
344
|
if (blockbook && blockbook.websocket) {
|
|
279
345
|
wsUrl = blockbook.websocket;
|
|
346
|
+
console.log('[DEBUG] Found WebSocket for', blockbook.symbol, ':', wsUrl);
|
|
280
347
|
// Ensure proper wss:// protocol
|
|
281
348
|
if (!wsUrl.startsWith('wss://') && !wsUrl.startsWith('ws://')) {
|
|
282
349
|
wsUrl = 'wss://' + wsUrl;
|
|
@@ -287,20 +354,24 @@ var init_network = function (servers) {
|
|
|
287
354
|
// Remove any existing /wss/ suffix, then add /wss/API_KEY
|
|
288
355
|
wsUrl = wsUrl.replace(/\/wss\/?$/, ''); // Remove trailing /wss or /wss/
|
|
289
356
|
wsUrl = wsUrl + '/wss/' + NOW_NODES_API;
|
|
357
|
+
console.log('[DEBUG] Added API key to', blockbook.symbol, 'WebSocket');
|
|
290
358
|
log.info(tag, "Configured NowNodes websocket for ".concat(blockbook.symbol, " with API key"));
|
|
291
359
|
}
|
|
292
360
|
// Ensure /websocket suffix (only if not already there)
|
|
293
361
|
if (!wsUrl.endsWith('/websocket')) {
|
|
294
362
|
wsUrl = wsUrl + '/websocket';
|
|
295
363
|
}
|
|
364
|
+
console.log('[DEBUG] Final WebSocket URL for', blockbook.symbol, ':', wsUrl);
|
|
296
365
|
log.info(tag, "WebSocket URL for ".concat(blockbook.symbol, ": ").concat(wsUrl));
|
|
297
366
|
// Use blockbook-client package
|
|
298
367
|
BLOCKBOOK_SOCKETS[blockbook.symbol.toUpperCase()] = new Blockbook({
|
|
299
368
|
nodes: [wsUrl],
|
|
300
369
|
disableTypeValidation: true,
|
|
301
370
|
});
|
|
371
|
+
console.log('[DEBUG] Created Blockbook socket for', blockbook.symbol);
|
|
302
372
|
}
|
|
303
373
|
else {
|
|
374
|
+
console.log('[DEBUG] NO WebSocket for', blockbook.symbol);
|
|
304
375
|
log.info(tag, "no websocket for: ", blockbook.symbol);
|
|
305
376
|
}
|
|
306
377
|
}
|
|
@@ -364,17 +435,47 @@ var get_fees = function (coin) {
|
|
|
364
435
|
};
|
|
365
436
|
var get_info_by_pubkey = function (coin, pubkey, page) {
|
|
366
437
|
return __awaiter(this, void 0, void 0, function () {
|
|
367
|
-
var tag, url, body, resp, e_3;
|
|
368
|
-
|
|
369
|
-
|
|
438
|
+
var tag, symbol, isXpub, url, body, resp, e_3, e_4;
|
|
439
|
+
var _a;
|
|
440
|
+
return __generator(this, function (_b) {
|
|
441
|
+
switch (_b.label) {
|
|
370
442
|
case 0:
|
|
371
443
|
tag = TAG + " | get_info_by_pubkey | ";
|
|
372
|
-
|
|
444
|
+
_b.label = 1;
|
|
373
445
|
case 1:
|
|
374
|
-
|
|
446
|
+
_b.trys.push([1, 6, , 7]);
|
|
375
447
|
if (!page)
|
|
376
448
|
page = "1";
|
|
377
|
-
|
|
449
|
+
symbol = coin.toUpperCase();
|
|
450
|
+
// CRITICAL FIX: Convert dgub to xpub for DGB (NowNodes blockbook doesn't accept dgub format)
|
|
451
|
+
pubkey = convertDgubToXpub(pubkey, symbol);
|
|
452
|
+
isXpub = pubkey.startsWith('xpub') ||
|
|
453
|
+
pubkey.startsWith('ypub') ||
|
|
454
|
+
pubkey.startsWith('zpub') ||
|
|
455
|
+
pubkey.startsWith('tpub') ||
|
|
456
|
+
pubkey.startsWith('upub') ||
|
|
457
|
+
pubkey.startsWith('vpub') ||
|
|
458
|
+
pubkey.startsWith('dgub');
|
|
459
|
+
url = void 0;
|
|
460
|
+
if (isXpub) {
|
|
461
|
+
// CRITICAL: Use tokens=derived&gap=20 to get ALL derived addresses up to gap limit
|
|
462
|
+
// This is essential for Blockbook websocket subscriptions - we need to subscribe to
|
|
463
|
+
// ALL addresses (including fresh ones) to detect incoming transactions!
|
|
464
|
+
//
|
|
465
|
+
// tokens parameter values:
|
|
466
|
+
// - nonzero: Only addresses with current non-zero balance (DEFAULT - problematic!)
|
|
467
|
+
// - used: Addresses that have had transactions (even if zero balance now)
|
|
468
|
+
// - derived: ALL derived addresses up to gap limit - REQUIRED for websocket subscription!
|
|
469
|
+
//
|
|
470
|
+
// gap parameter: Number of addresses to derive (default 20, matching BIP44 gap limit)
|
|
471
|
+
url = BLOCKBOOK_URLS[symbol] + "/api/v2/xpub/" + pubkey + "?details=tokens&tokens=derived&gap=20&page=" + page;
|
|
472
|
+
log.debug(tag, "Using xpub endpoint for ".concat(pubkey.substring(0, 20), "..."));
|
|
473
|
+
}
|
|
474
|
+
else {
|
|
475
|
+
// Regular address - use address endpoint with transaction details
|
|
476
|
+
url = BLOCKBOOK_URLS[symbol] + "/api/v2/address/" + pubkey + "?details=txs&page=" + page;
|
|
477
|
+
log.debug(tag, "Using address endpoint for ".concat(pubkey));
|
|
478
|
+
}
|
|
378
479
|
log.debug(tag, "url: ", url);
|
|
379
480
|
body = {
|
|
380
481
|
method: 'GET',
|
|
@@ -384,32 +485,68 @@ var get_info_by_pubkey = function (coin, pubkey, page) {
|
|
|
384
485
|
'User-Agent': fakeUa()
|
|
385
486
|
},
|
|
386
487
|
};
|
|
387
|
-
|
|
488
|
+
resp = void 0;
|
|
489
|
+
_b.label = 2;
|
|
388
490
|
case 2:
|
|
389
|
-
|
|
491
|
+
_b.trys.push([2, 4, , 5]);
|
|
492
|
+
return [4 /*yield*/, axios(body)];
|
|
493
|
+
case 3:
|
|
494
|
+
resp = _b.sent();
|
|
495
|
+
return [3 /*break*/, 5];
|
|
496
|
+
case 4:
|
|
497
|
+
e_3 = _b.sent();
|
|
498
|
+
// Handle 404 - pubkey doesn't exist on chain yet (no transactions)
|
|
499
|
+
if (((_a = e_3.response) === null || _a === void 0 ? void 0 : _a.status) === 404 || e_3.status === 404) {
|
|
500
|
+
log.debug(tag, "Pubkey not found (404) for ".concat(coin, " - treating as zero balance"));
|
|
501
|
+
return [2 /*return*/, {
|
|
502
|
+
balance: '0',
|
|
503
|
+
unconfirmedBalance: '0',
|
|
504
|
+
totalReceived: '0',
|
|
505
|
+
totalSent: '0',
|
|
506
|
+
txs: 0,
|
|
507
|
+
usedTokens: 0,
|
|
508
|
+
tokens: []
|
|
509
|
+
}];
|
|
510
|
+
}
|
|
511
|
+
// Log detailed error information for 500 and other errors
|
|
512
|
+
log.error(tag, "getPubkeyInfo failed for ".concat(coin, ": ").concat(stringifyError(e_3)));
|
|
513
|
+
throw e_3;
|
|
514
|
+
case 5:
|
|
390
515
|
log.debug(tag, "resp: ", resp);
|
|
391
|
-
//
|
|
392
|
-
if (
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
516
|
+
// Normalize response format based on endpoint type
|
|
517
|
+
if (isXpub) {
|
|
518
|
+
// Validate that we got the tokens array from xpub endpoint
|
|
519
|
+
if (!resp.data.tokens || !Array.isArray(resp.data.tokens)) {
|
|
520
|
+
log.warn(tag, "\u26A0\uFE0F Blockbook response missing tokens array for ".concat(coin, " xpub ").concat(pubkey.substring(0, 20), "..."));
|
|
521
|
+
log.warn(tag, "Response has ".concat(resp.data.txs || 0, " transactions but no address details"));
|
|
522
|
+
log.warn(tag, "This should not happen with tokens=derived parameter!");
|
|
523
|
+
}
|
|
524
|
+
else {
|
|
525
|
+
log.info(tag, "\u2705 Got ".concat(resp.data.tokens.length, " derived address tokens for xpub (txs: ").concat(resp.data.txs, ", usedTokens: ").concat(resp.data.usedTokens, ")"));
|
|
526
|
+
}
|
|
396
527
|
}
|
|
397
528
|
else {
|
|
398
|
-
|
|
529
|
+
// Address endpoint returns balance data directly (no tokens array)
|
|
530
|
+
// Normalize to match xpub format for consistency
|
|
531
|
+
log.info(tag, "\u2705 Got balance for address: ".concat(resp.data.balance, " (txs: ").concat(resp.data.txs || 0, ")"));
|
|
532
|
+
// For regular addresses, create a synthetic tokens array with just this address
|
|
533
|
+
if (!resp.data.tokens) {
|
|
534
|
+
resp.data.tokens = [];
|
|
535
|
+
}
|
|
399
536
|
}
|
|
400
537
|
return [2 /*return*/, resp.data];
|
|
401
|
-
case
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
throw
|
|
405
|
-
case
|
|
538
|
+
case 6:
|
|
539
|
+
e_4 = _b.sent();
|
|
540
|
+
log.error(tag, stringifyError(e_4));
|
|
541
|
+
throw e_4;
|
|
542
|
+
case 7: return [2 /*return*/];
|
|
406
543
|
}
|
|
407
544
|
});
|
|
408
545
|
});
|
|
409
546
|
};
|
|
410
547
|
var get_txids_by_address = function (coin, address, page) {
|
|
411
548
|
return __awaiter(this, void 0, void 0, function () {
|
|
412
|
-
var tag, url, body, resp,
|
|
549
|
+
var tag, url, body, resp, e_5;
|
|
413
550
|
return __generator(this, function (_a) {
|
|
414
551
|
switch (_a.label) {
|
|
415
552
|
case 0:
|
|
@@ -437,9 +574,9 @@ var get_txids_by_address = function (coin, address, page) {
|
|
|
437
574
|
//TODO paginate?
|
|
438
575
|
return [2 /*return*/, resp.data];
|
|
439
576
|
case 3:
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
throw
|
|
577
|
+
e_5 = _a.sent();
|
|
578
|
+
log.error(tag, stringifyError(e_5));
|
|
579
|
+
throw e_5;
|
|
443
580
|
case 4: return [2 /*return*/];
|
|
444
581
|
}
|
|
445
582
|
});
|
|
@@ -447,7 +584,7 @@ var get_txids_by_address = function (coin, address, page) {
|
|
|
447
584
|
};
|
|
448
585
|
var get_info_by_address = function (coin, address, filter, options) {
|
|
449
586
|
return __awaiter(this, void 0, void 0, function () {
|
|
450
|
-
var tag, url, params, body, resp,
|
|
587
|
+
var tag, url, params, body, resp, e_6;
|
|
451
588
|
return __generator(this, function (_a) {
|
|
452
589
|
switch (_a.label) {
|
|
453
590
|
case 0:
|
|
@@ -489,9 +626,9 @@ var get_info_by_address = function (coin, address, filter, options) {
|
|
|
489
626
|
resp = _a.sent();
|
|
490
627
|
return [2 /*return*/, resp.data];
|
|
491
628
|
case 3:
|
|
492
|
-
|
|
493
|
-
console.error(tag,
|
|
494
|
-
throw
|
|
629
|
+
e_6 = _a.sent();
|
|
630
|
+
console.error(tag, e_6);
|
|
631
|
+
throw e_6;
|
|
495
632
|
case 4: return [2 /*return*/];
|
|
496
633
|
}
|
|
497
634
|
});
|
|
@@ -499,7 +636,7 @@ var get_info_by_address = function (coin, address, filter, options) {
|
|
|
499
636
|
};
|
|
500
637
|
var get_txs_by_xpub = function (coin, xpub) {
|
|
501
638
|
return __awaiter(this, void 0, void 0, function () {
|
|
502
|
-
var tag, url, body, resp,
|
|
639
|
+
var tag, url, body, resp, e_7;
|
|
503
640
|
return __generator(this, function (_a) {
|
|
504
641
|
switch (_a.label) {
|
|
505
642
|
case 0:
|
|
@@ -521,9 +658,9 @@ var get_txs_by_xpub = function (coin, xpub) {
|
|
|
521
658
|
resp = _a.sent();
|
|
522
659
|
return [2 /*return*/, resp.data];
|
|
523
660
|
case 3:
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
throw
|
|
661
|
+
e_7 = _a.sent();
|
|
662
|
+
log.error(tag, stringifyError(e_7));
|
|
663
|
+
throw e_7;
|
|
527
664
|
case 4: return [2 /*return*/];
|
|
528
665
|
}
|
|
529
666
|
});
|
|
@@ -531,7 +668,7 @@ var get_txs_by_xpub = function (coin, xpub) {
|
|
|
531
668
|
};
|
|
532
669
|
var broadcast_transaction = function (coin, hex) {
|
|
533
670
|
return __awaiter(this, void 0, void 0, function () {
|
|
534
|
-
var tag, symbol, nodes_2, activeNodes, MAX_RETRIES, RETRY_DELAY_MS_1, allErrors, retry, _loop_1, i, state_1, errorSummary,
|
|
671
|
+
var tag, symbol, nodes_2, activeNodes, MAX_RETRIES, RETRY_DELAY_MS_1, allErrors, retry, _loop_1, i, state_1, errorSummary, e_8;
|
|
535
672
|
var _a, _b;
|
|
536
673
|
return __generator(this, function (_c) {
|
|
537
674
|
switch (_c.label) {
|
|
@@ -684,9 +821,9 @@ var broadcast_transaction = function (coin, hex) {
|
|
|
684
821
|
statusCode: 500
|
|
685
822
|
}];
|
|
686
823
|
case 10:
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
throw
|
|
824
|
+
e_8 = _c.sent();
|
|
825
|
+
log.error(tag, stringifyError(e_8));
|
|
826
|
+
throw e_8;
|
|
690
827
|
case 11: return [2 /*return*/];
|
|
691
828
|
}
|
|
692
829
|
});
|
|
@@ -694,7 +831,7 @@ var broadcast_transaction = function (coin, hex) {
|
|
|
694
831
|
};
|
|
695
832
|
var get_transaction = function (coin, txid) {
|
|
696
833
|
return __awaiter(this, void 0, void 0, function () {
|
|
697
|
-
var tag, url, body, resp,
|
|
834
|
+
var tag, url, body, resp, e_9;
|
|
698
835
|
return __generator(this, function (_a) {
|
|
699
836
|
switch (_a.label) {
|
|
700
837
|
case 0:
|
|
@@ -717,9 +854,9 @@ var get_transaction = function (coin, txid) {
|
|
|
717
854
|
resp = _a.sent();
|
|
718
855
|
return [2 /*return*/, resp.data];
|
|
719
856
|
case 3:
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
throw
|
|
857
|
+
e_9 = _a.sent();
|
|
858
|
+
log.error(tag, stringifyError(e_9));
|
|
859
|
+
throw e_9;
|
|
723
860
|
case 4: return [2 /*return*/];
|
|
724
861
|
}
|
|
725
862
|
});
|
|
@@ -728,7 +865,7 @@ var get_transaction = function (coin, txid) {
|
|
|
728
865
|
// Enhanced UTXO function with priority-based sequential failover
|
|
729
866
|
var get_utxos_by_xpub = function (coin, xpub) {
|
|
730
867
|
return __awaiter(this, void 0, void 0, function () {
|
|
731
|
-
var tag, symbol, isBitcoin, b58, data, payload, xpubPrefix, convertedData, convertedXpub, nodes_3, activeNodes, i, node, startTime, url, body, resp, responseTime, error_2, responseTime, errorMessage,
|
|
868
|
+
var tag, symbol, isBitcoin, b58, data, payload, xpubPrefix, convertedData, convertedXpub, nodes_3, activeNodes, i, node, startTime, url, body, resp, responseTime, error_2, responseTime, errorMessage, e_10;
|
|
732
869
|
var _a;
|
|
733
870
|
return __generator(this, function (_b) {
|
|
734
871
|
switch (_b.label) {
|
|
@@ -852,12 +989,12 @@ var get_utxos_by_xpub = function (coin, xpub) {
|
|
|
852
989
|
return [3 /*break*/, 2];
|
|
853
990
|
case 7: return [3 /*break*/, 9];
|
|
854
991
|
case 8:
|
|
855
|
-
|
|
992
|
+
e_10 = _b.sent();
|
|
856
993
|
if (isBitcoin) {
|
|
857
|
-
log.error(tag,
|
|
994
|
+
log.error(tag, "\uD83D\uDD0D [BITCOIN BLOCKBOOK] Final error after all nodes failed: ".concat(stringifyError(e_10)));
|
|
858
995
|
}
|
|
859
|
-
|
|
860
|
-
throw
|
|
996
|
+
log.error(tag, stringifyError(e_10));
|
|
997
|
+
throw e_10;
|
|
861
998
|
case 9: return [2 /*return*/];
|
|
862
999
|
}
|
|
863
1000
|
});
|
|
@@ -911,7 +1048,7 @@ var update_node_performance = function (coin, url, success, responseTime) {
|
|
|
911
1048
|
};
|
|
912
1049
|
var get_balance_by_xpub = function (coin, xpub) {
|
|
913
1050
|
return __awaiter(this, void 0, void 0, function () {
|
|
914
|
-
var tag, result, output, nodeUrl, balance, i, uxto,
|
|
1051
|
+
var tag, result, output, nodeUrl, balance, i, uxto, e_11;
|
|
915
1052
|
return __generator(this, function (_a) {
|
|
916
1053
|
switch (_a.label) {
|
|
917
1054
|
case 0:
|
|
@@ -939,9 +1076,9 @@ var get_balance_by_xpub = function (coin, xpub) {
|
|
|
939
1076
|
// Return both balance and node URL
|
|
940
1077
|
return [2 /*return*/, { balance: balance / 100000000, nodeUrl: nodeUrl }];
|
|
941
1078
|
case 3:
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
throw
|
|
1079
|
+
e_11 = _a.sent();
|
|
1080
|
+
log.error(tag, stringifyError(e_11));
|
|
1081
|
+
throw e_11;
|
|
945
1082
|
case 4: return [2 /*return*/];
|
|
946
1083
|
}
|
|
947
1084
|
});
|
|
@@ -956,7 +1093,7 @@ var get_node_info = function () {
|
|
|
956
1093
|
return [2 /*return*/, true];
|
|
957
1094
|
}
|
|
958
1095
|
catch (e) {
|
|
959
|
-
|
|
1096
|
+
log.error(tag, stringifyError(e));
|
|
960
1097
|
throw e;
|
|
961
1098
|
}
|
|
962
1099
|
return [2 /*return*/];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pioneer-platform/blockbook",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.25.0",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"types": "./lib/index.d.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"@pioneer-platform/loggerdog": "^8.11.0",
|
|
15
|
-
"@pioneer-platform/nodes": "^8.
|
|
15
|
+
"@pioneer-platform/nodes": "^8.24.0",
|
|
16
16
|
"@pioneer-platform/pioneer-caip": "^9.19.0",
|
|
17
17
|
"@types/request-promise-native": "^1.0.17",
|
|
18
18
|
"axiom": "^0.1.6",
|