@pioneer-platform/blockbook 8.3.9 → 8.3.11
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 +4 -1
- package/lib/index.js +47 -42
- package/package.json +24 -25
package/lib/index.d.ts
CHANGED
|
@@ -16,7 +16,10 @@ declare let get_info_by_pubkey: (coin: string, pubkey: string, page?: string | u
|
|
|
16
16
|
declare let get_txids_by_address: (coin: string, address: string, page?: number) => Promise<any>;
|
|
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
|
-
declare let broadcast_transaction: (coin: string, hex: string) => Promise<
|
|
19
|
+
declare let broadcast_transaction: (coin: string, hex: string) => Promise<{
|
|
20
|
+
txid: any;
|
|
21
|
+
success: boolean;
|
|
22
|
+
}>;
|
|
20
23
|
declare let get_transaction: (coin: string, txid: string) => Promise<any>;
|
|
21
24
|
declare let get_utxos_by_xpub: (coin: string, xpub: string) => Promise<any>;
|
|
22
25
|
declare let get_balance_by_xpub: (coin: string, xpub: any) => Promise<number>;
|
package/lib/index.js
CHANGED
|
@@ -13,8 +13,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
13
13
|
});
|
|
14
14
|
};
|
|
15
15
|
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
16
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
17
|
-
return g =
|
|
16
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
17
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
18
18
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
19
19
|
function step(op) {
|
|
20
20
|
if (f) throw new TypeError("Generator is already executing.");
|
|
@@ -352,56 +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, url,
|
|
355
|
+
var tag, url, body, resp, e_7;
|
|
356
356
|
return __generator(this, function (_a) {
|
|
357
357
|
switch (_a.label) {
|
|
358
358
|
case 0:
|
|
359
359
|
tag = TAG + " | broadcast_transaction | ";
|
|
360
360
|
_a.label = 1;
|
|
361
361
|
case 1:
|
|
362
|
-
_a.trys.push([1,
|
|
363
|
-
|
|
364
|
-
|
|
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);
|
|
365
369
|
body = {
|
|
370
|
+
method: 'POST',
|
|
366
371
|
url: url,
|
|
367
372
|
headers: {
|
|
368
|
-
'
|
|
373
|
+
'Content-Type': 'application/json',
|
|
369
374
|
'User-Agent': fakeUa()
|
|
370
375
|
},
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
};
|
|
375
|
-
output = {
|
|
376
|
-
success: false
|
|
376
|
+
data: {
|
|
377
|
+
hex: hex
|
|
378
|
+
}
|
|
377
379
|
};
|
|
378
|
-
resp = void 0;
|
|
379
|
-
_a.label = 2;
|
|
380
|
-
case 2:
|
|
381
|
-
_a.trys.push([2, 4, , 5]);
|
|
382
380
|
return [4 /*yield*/, axios(body)];
|
|
383
|
-
case
|
|
381
|
+
case 2:
|
|
384
382
|
resp = _a.sent();
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
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:
|
|
389
399
|
e_7 = _a.sent();
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
case
|
|
393
|
-
case 6:
|
|
394
|
-
e_8 = _a.sent();
|
|
395
|
-
//console.error(tag,e)
|
|
396
|
-
throw e_8;
|
|
397
|
-
case 7: return [2 /*return*/];
|
|
400
|
+
console.error(tag, "Broadcast error:", e_7);
|
|
401
|
+
throw e_7;
|
|
402
|
+
case 4: return [2 /*return*/];
|
|
398
403
|
}
|
|
399
404
|
});
|
|
400
405
|
});
|
|
401
406
|
};
|
|
402
407
|
var get_transaction = function (coin, txid) {
|
|
403
408
|
return __awaiter(this, void 0, void 0, function () {
|
|
404
|
-
var tag, url, body, resp,
|
|
409
|
+
var tag, url, body, resp, e_8;
|
|
405
410
|
return __generator(this, function (_a) {
|
|
406
411
|
switch (_a.label) {
|
|
407
412
|
case 0:
|
|
@@ -424,9 +429,9 @@ var get_transaction = function (coin, txid) {
|
|
|
424
429
|
resp = _a.sent();
|
|
425
430
|
return [2 /*return*/, resp.data];
|
|
426
431
|
case 3:
|
|
427
|
-
|
|
428
|
-
console.error(tag,
|
|
429
|
-
throw
|
|
432
|
+
e_8 = _a.sent();
|
|
433
|
+
console.error(tag, e_8);
|
|
434
|
+
throw e_8;
|
|
430
435
|
case 4: return [2 /*return*/];
|
|
431
436
|
}
|
|
432
437
|
});
|
|
@@ -434,7 +439,7 @@ var get_transaction = function (coin, txid) {
|
|
|
434
439
|
};
|
|
435
440
|
var get_utxos_by_xpub = function (coin, xpub) {
|
|
436
441
|
return __awaiter(this, void 0, void 0, function () {
|
|
437
|
-
var tag, url, body, resp,
|
|
442
|
+
var tag, url, body, resp, e_9;
|
|
438
443
|
return __generator(this, function (_a) {
|
|
439
444
|
switch (_a.label) {
|
|
440
445
|
case 0:
|
|
@@ -459,9 +464,9 @@ var get_utxos_by_xpub = function (coin, xpub) {
|
|
|
459
464
|
resp = _a.sent();
|
|
460
465
|
return [2 /*return*/, resp.data];
|
|
461
466
|
case 3:
|
|
462
|
-
|
|
463
|
-
console.error(tag,
|
|
464
|
-
throw
|
|
467
|
+
e_9 = _a.sent();
|
|
468
|
+
console.error(tag, e_9);
|
|
469
|
+
throw e_9;
|
|
465
470
|
case 4: return [2 /*return*/];
|
|
466
471
|
}
|
|
467
472
|
});
|
|
@@ -469,7 +474,7 @@ var get_utxos_by_xpub = function (coin, xpub) {
|
|
|
469
474
|
};
|
|
470
475
|
var get_balance_by_xpub = function (coin, xpub) {
|
|
471
476
|
return __awaiter(this, void 0, void 0, function () {
|
|
472
|
-
var tag, output, balance, i, uxto,
|
|
477
|
+
var tag, output, balance, i, uxto, e_10;
|
|
473
478
|
return __generator(this, function (_a) {
|
|
474
479
|
switch (_a.label) {
|
|
475
480
|
case 0:
|
|
@@ -491,9 +496,9 @@ var get_balance_by_xpub = function (coin, xpub) {
|
|
|
491
496
|
}
|
|
492
497
|
return [2 /*return*/, balance / 100000000];
|
|
493
498
|
case 3:
|
|
494
|
-
|
|
495
|
-
console.error(tag,
|
|
496
|
-
throw
|
|
499
|
+
e_10 = _a.sent();
|
|
500
|
+
console.error(tag, e_10);
|
|
501
|
+
throw e_10;
|
|
497
502
|
case 4: return [2 /*return*/];
|
|
498
503
|
}
|
|
499
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.11",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
|
-
"types": "./lib/
|
|
5
|
+
"types": "./lib/index.d.ts",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"
|
|
8
|
-
"start": "
|
|
7
|
+
"test": "pnpm run build && node __tests__/test-module.js",
|
|
8
|
+
"start": "pnpm run build:live",
|
|
9
9
|
"build": "tsc -p .",
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"prepublish": "npm run build",
|
|
13
|
-
"refresh": "rm -rf ./node_modules ./package-lock.json && npm install"
|
|
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
|
-
"
|
|
22
|
-
"axios": "^
|
|
23
|
-
"axios-retry": "^3.
|
|
24
|
-
"blockbook-client": "^0.
|
|
25
|
-
"fake-useragent": "^1.0.1"
|
|
17
|
+
"axiom": "^0.1.6",
|
|
18
|
+
"axios": "^1.6.0",
|
|
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"
|
|
26
25
|
},
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
"
|
|
35
|
-
}
|
|
26
|
+
"keywords": [
|
|
27
|
+
"bitcoin",
|
|
28
|
+
"cryptocurrency",
|
|
29
|
+
"sdk",
|
|
30
|
+
"keepkey"
|
|
31
|
+
],
|
|
32
|
+
"author": "highlander",
|
|
33
|
+
"license": "MIT"
|
|
34
|
+
}
|