@pioneer-platform/utxo-network 8.11.8 → 8.11.10
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 -2
- package/CHANGELOG.md +15 -0
- package/lib/index.js +39 -2
- package/package.json +2 -2
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
[0m[2m[35m$[0m [2m[1mtsc -p .[0m
|
|
1
|
+
$ tsc -p .
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @pioneer-platform/utxo-network
|
|
2
2
|
|
|
3
|
+
## 8.11.10
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
- @pioneer-platform/nodes@8.11.10
|
|
9
|
+
|
|
10
|
+
## 8.11.9
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- fix(pioneer-nodes): remove broken node entry without service field
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
- @pioneer-platform/nodes@8.11.9
|
|
17
|
+
|
|
3
18
|
## 8.11.8
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
package/lib/index.js
CHANGED
|
@@ -236,15 +236,51 @@ const init_network = async function (servers) {
|
|
|
236
236
|
}
|
|
237
237
|
};
|
|
238
238
|
exports.init_network = init_network;
|
|
239
|
+
/**
|
|
240
|
+
* Normalize pubkey info response to ensure consistent data structure
|
|
241
|
+
*
|
|
242
|
+
* @param coin - Coin symbol (BTC, DOGE, LTC, etc.)
|
|
243
|
+
* @param rawData - Raw data from blockbook API
|
|
244
|
+
* @returns Normalized pubkey info with guaranteed tokens array structure
|
|
245
|
+
*/
|
|
246
|
+
let normalize_pubkey_info = function (coin, rawData) {
|
|
247
|
+
const tag = TAG + " | normalize_pubkey_info | ";
|
|
248
|
+
// Ensure tokens array exists
|
|
249
|
+
if (!rawData.tokens || !Array.isArray(rawData.tokens)) {
|
|
250
|
+
log.warn(tag, `Missing or invalid tokens array for ${coin}, initializing empty array`);
|
|
251
|
+
rawData.tokens = [];
|
|
252
|
+
}
|
|
253
|
+
// Validate usedTokens field
|
|
254
|
+
if (typeof rawData.usedTokens !== 'number') {
|
|
255
|
+
rawData.usedTokens = rawData.tokens.length;
|
|
256
|
+
log.debug(tag, `Calculated usedTokens from tokens array length: ${rawData.usedTokens}`);
|
|
257
|
+
}
|
|
258
|
+
// Ensure numeric fields are properly typed
|
|
259
|
+
rawData.balance = rawData.balance || '0';
|
|
260
|
+
rawData.totalReceived = rawData.totalReceived || '0';
|
|
261
|
+
rawData.totalSent = rawData.totalSent || '0';
|
|
262
|
+
rawData.txs = typeof rawData.txs === 'number' ? rawData.txs : 0;
|
|
263
|
+
// If we have transactions but no tokens, log a warning
|
|
264
|
+
if (rawData.txs > 0 && rawData.tokens.length === 0) {
|
|
265
|
+
log.warn(tag, `⚠️ ${coin} xpub has ${rawData.txs} transactions but 0 address tokens!`);
|
|
266
|
+
log.warn(tag, `This may indicate blockbook is not returning ?details=tokens properly`);
|
|
267
|
+
log.warn(tag, `Address index calculations may be incorrect - fallback to index 0`);
|
|
268
|
+
}
|
|
269
|
+
return rawData;
|
|
270
|
+
};
|
|
239
271
|
let get_pubkey_info = async function (coin, xpub) {
|
|
240
272
|
let tag = TAG + " | get_pubkey_info | ";
|
|
241
273
|
try {
|
|
242
|
-
let
|
|
243
|
-
log.debug(tag, "output: ",
|
|
274
|
+
let rawOutput = await blockbook.getPubkeyInfo(coin, xpub);
|
|
275
|
+
log.debug(tag, "raw blockbook output: ", rawOutput);
|
|
276
|
+
// Normalize the response to ensure consistent structure
|
|
277
|
+
let output = normalize_pubkey_info(coin, rawOutput);
|
|
278
|
+
log.debug(tag, "normalized output: ", output);
|
|
244
279
|
return output;
|
|
245
280
|
}
|
|
246
281
|
catch (e) {
|
|
247
282
|
console.error(tag, e);
|
|
283
|
+
throw e;
|
|
248
284
|
}
|
|
249
285
|
};
|
|
250
286
|
let get_fees_with_memo = async function (coin, memo) {
|
|
@@ -481,6 +517,7 @@ let get_balance_by_xpub = async function (coin, xpub) {
|
|
|
481
517
|
}
|
|
482
518
|
catch (e) {
|
|
483
519
|
console.error(tag, e);
|
|
520
|
+
throw e; // Propagate error instead of returning undefined
|
|
484
521
|
}
|
|
485
522
|
};
|
|
486
523
|
let get_block_hash = async function (coin, height) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pioneer-platform/utxo-network",
|
|
3
|
-
"version": "8.11.
|
|
3
|
+
"version": "8.11.10",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"types": "./lib/index.d.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"@pioneer-platform/blockbook": "^8.11.0",
|
|
15
15
|
"@pioneer-platform/loggerdog": "^8.11.0",
|
|
16
|
-
"@pioneer-platform/nodes": "8.11.
|
|
16
|
+
"@pioneer-platform/nodes": "8.11.10",
|
|
17
17
|
"@pioneer-platform/pioneer-caip": "^9.10.0",
|
|
18
18
|
"@pioneer-platform/unchained": "^8.11.1",
|
|
19
19
|
"@types/request-promise-native": "^1.0.17",
|