1
1
const utxoLib = require ( 'bitgo-utxo-lib' ) ;
2
2
const accountLib = require ( '@bitgo/account-lib' ) ;
3
+ const statics = require ( '@bitgo/statics' ) ;
3
4
const prova = require ( 'prova-lib' ) ;
4
5
const fs = require ( 'fs' ) ;
5
6
const _ = require ( 'lodash' ) ;
@@ -231,11 +232,7 @@ const handleSignTrx = function(recoveryRequest, key, skipConfirm) {
231
232
}
232
233
233
234
const backupKeyNode = getHDNodeAndVerify ( key , recoveryRequest . backupKey ) ;
234
- try {
235
- builder . sign ( { key : backupKeyNode . keyPair . getPrivateKeyBuffer ( ) } ) ;
236
- } catch ( e ) {
237
- console . log ( e ) ;
238
- }
235
+ builder . sign ( { key : backupKeyNode . keyPair . getPrivateKeyBuffer ( ) } ) ;
239
236
return JSON . stringify ( builder . build ( ) . toJson ( ) ) ;
240
237
} ;
241
238
@@ -453,12 +450,11 @@ const handleSign = function(args) {
453
450
const file = args . file ;
454
451
455
452
const recoveryRequest = JSON . parse ( fs . readFileSync ( file , { encoding : 'utf8' } ) ) ;
456
- let coin = recoveryRequest . coin ;
453
+ const coin = statics . coins . get ( recoveryRequest . coin ) ;
457
454
458
- if ( coin . startsWith ( 't' ) ) {
455
+ if ( coin . network . type === 'testnet' ) {
459
456
bitgo = new bitgojs . BitGo ( { env : 'test' } ) ;
460
457
} else {
461
- console . log ( 'prod' ) ;
462
458
bitgo = new bitgojs . BitGo ( { env : 'prod' } ) ;
463
459
}
464
460
@@ -467,19 +463,19 @@ const handleSign = function(args) {
467
463
args . key = prompt ( "Key: " ) ;
468
464
}
469
465
470
- const key = parseKey ( args . key , coin , args . path ) ;
466
+ const key = parseKey ( args . key , coin . name , args . path ) ;
471
467
472
468
let txHex , halfSignedInfo ;
473
469
474
470
// If a tokenContractAddress was provided, use that. Otherwise use the named coin
475
- const basecoin = recoveryRequest . tokenContractAddress ? bitgo . coin ( recoveryRequest . tokenContractAddress ) : bitgo . coin ( coin ) ;
471
+ const basecoin = recoveryRequest . tokenContractAddress ? bitgo . coin ( recoveryRequest . tokenContractAddress ) : bitgo . coin ( coin . name ) ;
476
472
477
473
switch ( basecoin . getFamily ( ) ) {
478
474
case 'eth' :
479
475
if ( recoveryRequest . txPrebuild ) {
480
476
halfSignedInfo = handleHalfSignEth ( recoveryRequest , key , args . confirm , basecoin ) ;
481
477
} else {
482
- if ( coin . getChain ( ) === 'eth' || coin . getChain ( ) === 'teth' ) {
478
+ if ( coin . family === 'eth' && ! coin . isToken ) {
483
479
txHex = handleSignEthereum ( recoveryRequest , key , args . confirm ) ;
484
480
} else {
485
481
txHex = handleSignErc20 ( recoveryRequest , key , args . confirm , basecoin ) ;
0 commit comments