@pioneer-platform/blockbook 8.3.10 → 8.3.12
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.d.ts +1 -1
- package/lib/index.js +59 -27
- package/package.json +22 -23
package/lib/index.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ declare let get_txids_by_address: (coin: string, address: string, page?: number)
|
|
|
17
17
|
declare let get_info_by_address: (coin: string, address: string, filter?: string) => Promise<any>;
|
|
18
18
|
declare let get_txs_by_xpub: (coin: string, xpub: string) => Promise<any>;
|
|
19
19
|
declare let broadcast_transaction: (coin: string, hex: string) => Promise<{
|
|
20
|
-
txid:
|
|
20
|
+
txid: any;
|
|
21
21
|
success: boolean;
|
|
22
22
|
}>;
|
|
23
23
|
declare let get_transaction: (coin: string, txid: string) => Promise<any>;
|
package/lib/index.js
CHANGED
|
@@ -352,29 +352,61 @@ var get_txs_by_xpub = function (coin, xpub) {
|
|
|
352
352
|
};
|
|
353
353
|
var broadcast_transaction = function (coin, hex) {
|
|
354
354
|
return __awaiter(this, void 0, void 0, function () {
|
|
355
|
-
var tag;
|
|
355
|
+
var tag, url, body, resp, e_7;
|
|
356
356
|
return __generator(this, function (_a) {
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
357
|
+
switch (_a.label) {
|
|
358
|
+
case 0:
|
|
359
|
+
tag = TAG + " | broadcast_transaction | ";
|
|
360
|
+
_a.label = 1;
|
|
361
|
+
case 1:
|
|
362
|
+
_a.trys.push([1, 3, , 4]);
|
|
363
|
+
log.info(tag, "Broadcasting transaction:", hex.substring(0, 20) + "..." + " for coin " + coin);
|
|
364
|
+
if (!BLOCKBOOK_URLS[coin.toUpperCase()]) {
|
|
365
|
+
throw new Error("No blockbook URL configured for coin: ".concat(coin));
|
|
366
|
+
}
|
|
367
|
+
url = BLOCKBOOK_URLS[coin.toUpperCase()] + "/api/v2/sendtx";
|
|
368
|
+
log.debug(tag, "Broadcasting to URL:", url);
|
|
369
|
+
body = {
|
|
370
|
+
method: 'POST',
|
|
371
|
+
url: url,
|
|
372
|
+
headers: {
|
|
373
|
+
'Content-Type': 'application/json',
|
|
374
|
+
'User-Agent': fakeUa()
|
|
375
|
+
},
|
|
376
|
+
data: {
|
|
377
|
+
hex: hex
|
|
378
|
+
}
|
|
379
|
+
};
|
|
380
|
+
return [4 /*yield*/, axios(body)];
|
|
381
|
+
case 2:
|
|
382
|
+
resp = _a.sent();
|
|
383
|
+
log.debug(tag, "Broadcast response:", resp.data);
|
|
384
|
+
// Blockbook returns { result: "txid" } or { error: "message" }
|
|
385
|
+
if (resp.data && resp.data.result) {
|
|
386
|
+
return [2 /*return*/, {
|
|
387
|
+
txid: resp.data.result,
|
|
388
|
+
success: true
|
|
389
|
+
}];
|
|
390
|
+
}
|
|
391
|
+
else if (resp.data && resp.data.error) {
|
|
392
|
+
throw new Error("Blockchain broadcast failed: ".concat(resp.data.error));
|
|
393
|
+
}
|
|
394
|
+
else {
|
|
395
|
+
throw new Error("Unexpected response format: ".concat(JSON.stringify(resp.data)));
|
|
396
|
+
}
|
|
397
|
+
return [3 /*break*/, 4];
|
|
398
|
+
case 3:
|
|
399
|
+
e_7 = _a.sent();
|
|
400
|
+
console.error(tag, "Broadcast error:", e_7);
|
|
401
|
+
throw e_7;
|
|
402
|
+
case 4: return [2 /*return*/];
|
|
370
403
|
}
|
|
371
|
-
return [2 /*return*/];
|
|
372
404
|
});
|
|
373
405
|
});
|
|
374
406
|
};
|
|
375
407
|
var get_transaction = function (coin, txid) {
|
|
376
408
|
return __awaiter(this, void 0, void 0, function () {
|
|
377
|
-
var tag, url, body, resp,
|
|
409
|
+
var tag, url, body, resp, e_8;
|
|
378
410
|
return __generator(this, function (_a) {
|
|
379
411
|
switch (_a.label) {
|
|
380
412
|
case 0:
|
|
@@ -397,9 +429,9 @@ var get_transaction = function (coin, txid) {
|
|
|
397
429
|
resp = _a.sent();
|
|
398
430
|
return [2 /*return*/, resp.data];
|
|
399
431
|
case 3:
|
|
400
|
-
|
|
401
|
-
console.error(tag,
|
|
402
|
-
throw
|
|
432
|
+
e_8 = _a.sent();
|
|
433
|
+
console.error(tag, e_8);
|
|
434
|
+
throw e_8;
|
|
403
435
|
case 4: return [2 /*return*/];
|
|
404
436
|
}
|
|
405
437
|
});
|
|
@@ -407,7 +439,7 @@ var get_transaction = function (coin, txid) {
|
|
|
407
439
|
};
|
|
408
440
|
var get_utxos_by_xpub = function (coin, xpub) {
|
|
409
441
|
return __awaiter(this, void 0, void 0, function () {
|
|
410
|
-
var tag, url, body, resp,
|
|
442
|
+
var tag, url, body, resp, e_9;
|
|
411
443
|
return __generator(this, function (_a) {
|
|
412
444
|
switch (_a.label) {
|
|
413
445
|
case 0:
|
|
@@ -432,9 +464,9 @@ var get_utxos_by_xpub = function (coin, xpub) {
|
|
|
432
464
|
resp = _a.sent();
|
|
433
465
|
return [2 /*return*/, resp.data];
|
|
434
466
|
case 3:
|
|
435
|
-
|
|
436
|
-
console.error(tag,
|
|
437
|
-
throw
|
|
467
|
+
e_9 = _a.sent();
|
|
468
|
+
console.error(tag, e_9);
|
|
469
|
+
throw e_9;
|
|
438
470
|
case 4: return [2 /*return*/];
|
|
439
471
|
}
|
|
440
472
|
});
|
|
@@ -442,7 +474,7 @@ var get_utxos_by_xpub = function (coin, xpub) {
|
|
|
442
474
|
};
|
|
443
475
|
var get_balance_by_xpub = function (coin, xpub) {
|
|
444
476
|
return __awaiter(this, void 0, void 0, function () {
|
|
445
|
-
var tag, output, balance, i, uxto,
|
|
477
|
+
var tag, output, balance, i, uxto, e_10;
|
|
446
478
|
return __generator(this, function (_a) {
|
|
447
479
|
switch (_a.label) {
|
|
448
480
|
case 0:
|
|
@@ -464,9 +496,9 @@ var get_balance_by_xpub = function (coin, xpub) {
|
|
|
464
496
|
}
|
|
465
497
|
return [2 /*return*/, balance / 100000000];
|
|
466
498
|
case 3:
|
|
467
|
-
|
|
468
|
-
console.error(tag,
|
|
469
|
-
throw
|
|
499
|
+
e_10 = _a.sent();
|
|
500
|
+
console.error(tag, e_10);
|
|
501
|
+
throw e_10;
|
|
470
502
|
case 4: return [2 /*return*/];
|
|
471
503
|
}
|
|
472
504
|
});
|
package/package.json
CHANGED
|
@@ -1,35 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pioneer-platform/blockbook",
|
|
3
|
-
"version": "8.3.
|
|
3
|
+
"version": "8.3.12",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
|
-
"types": "./lib/
|
|
5
|
+
"types": "./lib/index.d.ts",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"npm": "pnpm i",
|
|
8
|
-
"start": "node lib/index",
|
|
9
|
-
"build": "tsc -p .",
|
|
10
|
-
"build:watch": "pnpm run build && onchange 'src/**/*.ts' -- pnpm run build",
|
|
11
7
|
"test": "pnpm run build && node __tests__/test-module.js",
|
|
12
|
-
"
|
|
13
|
-
"
|
|
8
|
+
"start": "pnpm run build:live",
|
|
9
|
+
"build": "tsc -p .",
|
|
10
|
+
"prepublish": "tsc -p .",
|
|
11
|
+
"build:live": "nodemon --watch 'src/**/*.ts' --exec 'ts-node' src/index.ts"
|
|
14
12
|
},
|
|
15
13
|
"dependencies": {
|
|
16
|
-
"@altangent/lib-blockbook": "^0.12.9",
|
|
17
14
|
"@pioneer-platform/loggerdog": "^8.3.1",
|
|
18
|
-
"@pioneer-platform/nodes": "^8.3.
|
|
19
|
-
"@pioneer-platform/pioneer-client": "^9.2.6",
|
|
15
|
+
"@pioneer-platform/nodes": "^8.3.1",
|
|
20
16
|
"@types/request-promise-native": "^1.0.17",
|
|
21
|
-
"
|
|
17
|
+
"axiom": "^0.1.6",
|
|
22
18
|
"axios": "^1.6.0",
|
|
23
|
-
"axios-retry": "^3.
|
|
24
|
-
"blockbook-client": "^0.
|
|
25
|
-
"fake-useragent": "^1.0.1"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"
|
|
29
|
-
"@types/node": "^18.16.0",
|
|
30
|
-
"nodemon": "^2.0.3",
|
|
31
|
-
"ts-node": "^10.9.1",
|
|
32
|
-
"typescript": "^5.0.4"
|
|
19
|
+
"axios-retry": "^3.8.0",
|
|
20
|
+
"blockbook-client": "^1.0.26",
|
|
21
|
+
"fake-useragent": "^1.0.1",
|
|
22
|
+
"long": "^5.2.3",
|
|
23
|
+
"request": "^2.88.2",
|
|
24
|
+
"request-promise-native": "^1.0.9"
|
|
33
25
|
},
|
|
34
|
-
"
|
|
26
|
+
"keywords": [
|
|
27
|
+
"bitcoin",
|
|
28
|
+
"cryptocurrency",
|
|
29
|
+
"sdk",
|
|
30
|
+
"keepkey"
|
|
31
|
+
],
|
|
32
|
+
"author": "highlander",
|
|
33
|
+
"license": "MIT"
|
|
35
34
|
}
|