@pioneer-platform/blockbook 8.34.0 → 8.35.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/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +12 -0
- package/lib/index.js +47 -14
- package/package.json +4 -4
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
> @pioneer-platform/blockbook@8.
|
|
3
|
+
> @pioneer-platform/blockbook@8.35.0 build /Users/highlander/WebstormProjects/keepkey-stack/projects/pioneer/modules/intergrations/blockbook
|
|
4
4
|
> tsc -p .
|
|
5
5
|
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @pioneer-platform/blockbook
|
|
2
2
|
|
|
3
|
+
## 8.35.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- chore: chore: feat(e2e): add --blue and --production flags to pioneer-sdk test
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
- @pioneer-platform/pioneer-caip@9.24.0
|
|
13
|
+
- @pioneer-platform/pioneer-nodes@8.34.0
|
|
14
|
+
|
|
3
15
|
## 8.34.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
package/lib/index.js
CHANGED
|
@@ -78,6 +78,24 @@ var stringifyError = function (e) {
|
|
|
78
78
|
return String(e);
|
|
79
79
|
}
|
|
80
80
|
};
|
|
81
|
+
/**
|
|
82
|
+
* Calculate txid from raw transaction hex
|
|
83
|
+
* For Bitcoin-like chains, txid = reverse(sha256(sha256(raw_hex)))
|
|
84
|
+
*/
|
|
85
|
+
var calculateTxidFromRaw = function (rawTxHex) {
|
|
86
|
+
try {
|
|
87
|
+
var crypto_1 = require('crypto');
|
|
88
|
+
var txBuffer = Buffer.from(rawTxHex, 'hex');
|
|
89
|
+
var hash1 = crypto_1.createHash('sha256').update(txBuffer).digest();
|
|
90
|
+
var hash2 = crypto_1.createHash('sha256').update(hash1).digest();
|
|
91
|
+
// Reverse the hash for display (Bitcoin convention)
|
|
92
|
+
return hash2.reverse().toString('hex');
|
|
93
|
+
}
|
|
94
|
+
catch (e) {
|
|
95
|
+
log.error(TAG, 'Failed to calculate txid from raw hex:', e);
|
|
96
|
+
return '';
|
|
97
|
+
}
|
|
98
|
+
};
|
|
81
99
|
/**
|
|
82
100
|
* Convert DGB dgub format to xpub format for blockbook compatibility
|
|
83
101
|
* NowNodes blockbook doesn't accept dgub format
|
|
@@ -311,8 +329,7 @@ var add_custom_node = function (coin, url, priority) {
|
|
|
311
329
|
// Sort by priority and update legacy compatibility
|
|
312
330
|
reorder_nodes_by_priority(symbol);
|
|
313
331
|
update_legacy_urls(symbol);
|
|
314
|
-
log.
|
|
315
|
-
log.info("".concat(symbol, " now has ").concat(BLOCKBOOK_NODES[symbol].length, " node(s)"));
|
|
332
|
+
log.debug("Added node for ".concat(symbol, ": ").concat(cleanUrl, " (priority: ").concat(defaultPriority, ")"));
|
|
316
333
|
return true;
|
|
317
334
|
};
|
|
318
335
|
var remove_node = function (coin, url) {
|
|
@@ -403,31 +420,25 @@ var init_network = function (servers) {
|
|
|
403
420
|
_a.label = 1;
|
|
404
421
|
case 1:
|
|
405
422
|
_a.trys.push([1, 3, , 4]);
|
|
406
|
-
|
|
407
|
-
log.debug(tag, "checkpoint: ");
|
|
423
|
+
log.debug(tag, "Initializing blockbook network");
|
|
408
424
|
return [4 /*yield*/, nodes.getBlockbooks()];
|
|
409
425
|
case 2:
|
|
410
426
|
SEED_NODES = _a.sent();
|
|
411
|
-
|
|
412
|
-
log.info(tag, "SEED_NODES: ", SEED_NODES);
|
|
427
|
+
log.debug(tag, "SEED_NODES: ", SEED_NODES);
|
|
413
428
|
blockbooks = [];
|
|
414
429
|
if (servers && Array.isArray(servers)) { // Type checking for array
|
|
415
430
|
blockbooks = servers.concat(SEED_NODES); // Combine arrays
|
|
416
431
|
}
|
|
417
432
|
else {
|
|
418
|
-
log.warn("Invalid 'servers' parameter. Expected an array.");
|
|
419
433
|
blockbooks = SEED_NODES;
|
|
420
434
|
}
|
|
421
|
-
console.log('[DEBUG] Total blockbooks to process:', blockbooks.length);
|
|
422
435
|
log.debug(tag, "blockbooks: ", blockbooks.length);
|
|
423
436
|
// Clear existing nodes and sockets
|
|
424
437
|
BLOCKBOOK_NODES = {};
|
|
425
438
|
BLOCKBOOK_SOCKETS = {};
|
|
426
439
|
// Process nodes with priority assignment
|
|
427
|
-
console.log('[DEBUG] Processing', blockbooks.length, 'blockbooks...');
|
|
428
440
|
for (i = 0; i < blockbooks.length; i++) {
|
|
429
441
|
blockbook = blockbooks[i];
|
|
430
|
-
console.log('[DEBUG] Processing blockbook', i + 1, '/', blockbooks.length, ':', blockbook.symbol);
|
|
431
442
|
if (blockbook && blockbook.service) {
|
|
432
443
|
symbol = blockbook.symbol.toUpperCase();
|
|
433
444
|
serviceUrl = blockbook.service;
|
|
@@ -437,12 +448,10 @@ var init_network = function (servers) {
|
|
|
437
448
|
NOW_NODES_API_CURRENT = process.env['NOW_NODES_API'] || process.env['NOWNODES_API_KEY'];
|
|
438
449
|
if (NOW_NODES_API_CURRENT) {
|
|
439
450
|
serviceUrl = serviceUrl.replace('{API_KEY}', NOW_NODES_API_CURRENT);
|
|
440
|
-
|
|
441
|
-
log.info(tag, "Configured NowNodes HTTP service for ".concat(blockbook.symbol, " with API key"));
|
|
451
|
+
log.debug(tag, "Configured NowNodes HTTP service for ".concat(blockbook.symbol));
|
|
442
452
|
}
|
|
443
453
|
else {
|
|
444
454
|
log.error(tag, "\u26A0\uFE0F CRITICAL: NowNodes service URL contains {API_KEY} but NOW_NODES_API env var is not set for ".concat(blockbook.symbol));
|
|
445
|
-
console.error('[ERROR] Missing NOW_NODES_API environment variable - service will fail!');
|
|
446
455
|
}
|
|
447
456
|
}
|
|
448
457
|
priority = 50;
|
|
@@ -801,7 +810,7 @@ var get_txs_by_xpub = function (coin, xpub) {
|
|
|
801
810
|
};
|
|
802
811
|
var broadcast_transaction = function (coin, hex) {
|
|
803
812
|
return __awaiter(this, void 0, void 0, function () {
|
|
804
|
-
var tag, symbol, nodes_2, activeNodes, MAX_RETRIES, RETRY_DELAY_MS_1, allErrors, retry, _loop_1, i, state_1, errorSummary, e_8;
|
|
813
|
+
var tag, symbol, nodes_2, activeNodes, MAX_RETRIES, RETRY_DELAY_MS_1, allErrors, retry, _loop_1, i, state_1, errorSummary, allErrorsAreMempoolConflict, calculatedTxid, e_8;
|
|
805
814
|
var _a, _b;
|
|
806
815
|
return __generator(this, function (_c) {
|
|
807
816
|
switch (_c.label) {
|
|
@@ -947,6 +956,30 @@ var broadcast_transaction = function (coin, hex) {
|
|
|
947
956
|
return [3 /*break*/, 2];
|
|
948
957
|
case 9:
|
|
949
958
|
errorSummary = "All ".concat(activeNodes.length, " nodes failed after ").concat(MAX_RETRIES, " attempts each. Errors:\n").concat(allErrors.join('\n'));
|
|
959
|
+
allErrorsAreMempoolConflict = allErrors.every(function (err) {
|
|
960
|
+
return err.toLowerCase().includes('txn-mempool-conflict');
|
|
961
|
+
});
|
|
962
|
+
if (allErrorsAreMempoolConflict) {
|
|
963
|
+
log.info(tag, '✅ All nodes report txn-mempool-conflict - transaction already broadcast, calculating txid from raw hex');
|
|
964
|
+
calculatedTxid = calculateTxidFromRaw(hex);
|
|
965
|
+
if (calculatedTxid) {
|
|
966
|
+
log.info(tag, "\u2705 Calculated txid: ".concat(calculatedTxid));
|
|
967
|
+
return [2 /*return*/, {
|
|
968
|
+
success: true,
|
|
969
|
+
txid: calculatedTxid,
|
|
970
|
+
note: 'Transaction already in mempool (mempool conflict detected)'
|
|
971
|
+
}];
|
|
972
|
+
}
|
|
973
|
+
else {
|
|
974
|
+
// If we can't calculate txid, still mark as success but note the limitation
|
|
975
|
+
log.warn(tag, 'Transaction already broadcast (mempool conflict) but txid calculation failed');
|
|
976
|
+
return [2 /*return*/, {
|
|
977
|
+
success: true,
|
|
978
|
+
note: 'Transaction already broadcast (mempool conflict) but txid calculation failed'
|
|
979
|
+
}];
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
// Not a mempool conflict - this is a real failure
|
|
950
983
|
log.error(tag, errorSummary);
|
|
951
984
|
return [2 /*return*/, {
|
|
952
985
|
success: false,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pioneer-platform/blockbook",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.35.0",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"types": "./lib/index.d.ts",
|
|
6
6
|
"dependencies": {
|
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
"request": "^2.88.2",
|
|
15
15
|
"request-promise-native": "^1.0.9",
|
|
16
16
|
"ws": "^8.18.0",
|
|
17
|
-
"@pioneer-platform/
|
|
18
|
-
"@pioneer-platform/pioneer-
|
|
17
|
+
"@pioneer-platform/pioneer-nodes": "8.34.0",
|
|
18
|
+
"@pioneer-platform/pioneer-caip": "9.24.0",
|
|
19
19
|
"@pioneer-platform/utxo-crypto": "8.11.0",
|
|
20
|
-
"@pioneer-platform/
|
|
20
|
+
"@pioneer-platform/loggerdog": "8.11.0"
|
|
21
21
|
},
|
|
22
22
|
"keywords": [
|
|
23
23
|
"bitcoin",
|