@pioneer-platform/utxo-network 8.3.10 → 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.js +80 -91
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -404,28 +404,19 @@ var get_fee = function (coin) {
|
|
|
404
404
|
*/
|
|
405
405
|
var broadcast_transaction = function (coin, tx) {
|
|
406
406
|
return __awaiter(this, void 0, void 0, function () {
|
|
407
|
-
var tag, output,
|
|
407
|
+
var tag, output, responseBroadcast, e_6;
|
|
408
408
|
return __generator(this, function (_a) {
|
|
409
409
|
switch (_a.label) {
|
|
410
410
|
case 0:
|
|
411
411
|
tag = TAG + " | broadcast_transaction | ";
|
|
412
412
|
_a.label = 1;
|
|
413
413
|
case 1:
|
|
414
|
-
_a.trys.push([1,
|
|
414
|
+
_a.trys.push([1, 3, , 4]);
|
|
415
415
|
output = {
|
|
416
416
|
success: false
|
|
417
417
|
};
|
|
418
|
-
|
|
419
|
-
if (!unchained[shortListSymbolToCaip[coin]]) return [3 /*break*/, 3];
|
|
420
|
-
return [4 /*yield*/, unchained[shortListSymbolToCaip[coin]].SendTx({ hex: tx })];
|
|
418
|
+
return [4 /*yield*/, blockbook.broadcast(coin, tx)];
|
|
421
419
|
case 2:
|
|
422
|
-
result = _a.sent();
|
|
423
|
-
log.debug(tag, "result.data: ", result.data);
|
|
424
|
-
output.txid = result.data;
|
|
425
|
-
output.success = true;
|
|
426
|
-
return [3 /*break*/, 5];
|
|
427
|
-
case 3: return [4 /*yield*/, blockbook.broadcast(coin, tx)];
|
|
428
|
-
case 4:
|
|
429
420
|
responseBroadcast = _a.sent();
|
|
430
421
|
log.debug(tag, 'responseBroadcast: ', responseBroadcast);
|
|
431
422
|
if (responseBroadcast.success && responseBroadcast.success !== false) {
|
|
@@ -444,88 +435,86 @@ var broadcast_transaction = function (coin, tx) {
|
|
|
444
435
|
output.error = "unknown error";
|
|
445
436
|
output.debug = responseBroadcast;
|
|
446
437
|
}
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
return [2 /*return*/, output];
|
|
524
|
-
case 6:
|
|
438
|
+
//Jesus fuck
|
|
439
|
+
// try{
|
|
440
|
+
// //TODO use for non-bitcoin? wtf why bitcoin blockbook broke?
|
|
441
|
+
// let responseBroadcast
|
|
442
|
+
// if(coin === 'BTC'){
|
|
443
|
+
// log.debug(tag,"BTC detected!")
|
|
444
|
+
// let url = "https://api.bitcoin.shapeshift.com/api/v1/send"
|
|
445
|
+
// let body = {
|
|
446
|
+
// url,
|
|
447
|
+
// method: 'POST',
|
|
448
|
+
// json:false,
|
|
449
|
+
// data:{hex:tx},
|
|
450
|
+
// }
|
|
451
|
+
// let output:any = {
|
|
452
|
+
// success:false
|
|
453
|
+
// }
|
|
454
|
+
// try{
|
|
455
|
+
// responseBroadcast = await axios(body)
|
|
456
|
+
// responseBroadcast = responseBroadcast.data
|
|
457
|
+
// log.debug(tag,'responseBroadcast: ',responseBroadcast)
|
|
458
|
+
// output.txid = responseBroadcast
|
|
459
|
+
// if(output.txid)output.success = true
|
|
460
|
+
//
|
|
461
|
+
// }catch(e:any){
|
|
462
|
+
// // log.debug(tag,"error: ",e)
|
|
463
|
+
// // log.debug(tag,"data0: ",e)
|
|
464
|
+
// // log.debug(tag,"resp: ",resp)
|
|
465
|
+
// // log.debug(tag,"data0: ",Object.keys(e))
|
|
466
|
+
// // log.debug(tag,"data1: ",e.response.req)
|
|
467
|
+
// log.debug(tag,"data2: ",e.response.data)
|
|
468
|
+
// log.debug(tag,"data2: ",e.response.data.message)
|
|
469
|
+
// // log.debug(tag,"error3: ",e.toJSON().request)
|
|
470
|
+
// // log.debug(tag,"erro4: ",e.toJSON().data)
|
|
471
|
+
// // log.debug(tag,"error5: ",e.toJSON().code)
|
|
472
|
+
// if(e.response.data.message){
|
|
473
|
+
// log.debug(tag,"saving message! ")
|
|
474
|
+
// output.error = e.response.data.message
|
|
475
|
+
// }else{
|
|
476
|
+
// output.error = e
|
|
477
|
+
// }
|
|
478
|
+
// }
|
|
479
|
+
// log.debug(tag,"output: ",output)
|
|
480
|
+
// return output
|
|
481
|
+
// } else {
|
|
482
|
+
// responseBroadcast = await blockbook.broadcast(coin,tx)
|
|
483
|
+
// log.debug(tag,'responseBroadcast: ',responseBroadcast)
|
|
484
|
+
// if(responseBroadcast.success && responseBroadcast.success !== false){
|
|
485
|
+
// output.success = true
|
|
486
|
+
// if(responseBroadcast.txid){
|
|
487
|
+
// output.txid = responseBroadcast.resp.data.result
|
|
488
|
+
// }
|
|
489
|
+
// if(responseBroadcast.resp.data.result){
|
|
490
|
+
// output.txid = responseBroadcast.resp.data.result
|
|
491
|
+
// }
|
|
492
|
+
// } else if(responseBroadcast.error) {
|
|
493
|
+
// output.error = responseBroadcast.error
|
|
494
|
+
// } else {
|
|
495
|
+
// output.error = "unknown error"
|
|
496
|
+
// output.debug = responseBroadcast
|
|
497
|
+
// }
|
|
498
|
+
// return output
|
|
499
|
+
// }
|
|
500
|
+
//
|
|
501
|
+
// //use nodes
|
|
502
|
+
// // log.debug(tag,'nodeMap: ',nodeMap)
|
|
503
|
+
// // let responseBroadcast = await nodeMap[coin].sendRawTransaction(tx)
|
|
504
|
+
// // log.debug(tag,'responseBroadcast: ',responseBroadcast)
|
|
505
|
+
//
|
|
506
|
+
//
|
|
507
|
+
// }catch(e){
|
|
508
|
+
// //TODO handle errors
|
|
509
|
+
// if(!output.error)output.error = e
|
|
510
|
+
// return output
|
|
511
|
+
// }
|
|
512
|
+
return [2 /*return*/, output];
|
|
513
|
+
case 3:
|
|
525
514
|
e_6 = _a.sent();
|
|
526
515
|
console.error(tag, e_6);
|
|
527
516
|
throw e_6;
|
|
528
|
-
case
|
|
517
|
+
case 4: return [2 /*return*/];
|
|
529
518
|
}
|
|
530
519
|
});
|
|
531
520
|
});
|