11import { MasterApiSpecRouteRequest } from '../routers/masterApiSpec' ;
22import logger from '../../../logger' ;
3- import { isSolCoin , isTrxCoin } from '../../../shared/coinUtils' ;
4- import { MPCSweepTxs , MPCTx , MPCTxs } from 'bitgo' ;
3+ import { isSolCoin } from '../../../shared/coinUtils' ;
4+ import { MPCTx } from 'bitgo' ;
55import { RecoveryTransaction } from '@bitgo/sdk-coin-trx' ;
66
77// Handler for recovery from receive addresses (consolidation sweeps)
@@ -16,34 +16,32 @@ export async function handleRecoveryConsolidationsOnPrem(
1616
1717 const sdkCoin = bitgo . coin ( coin ) ;
1818 let txs : MPCTx [ ] | RecoveryTransaction [ ] = [ ] ;
19-
20- logger . debug (
21- `${ isSolCoin ( sdkCoin ) ? 'Solana' : isTrxCoin ( sdkCoin ) ? 'Tron' : 'Unknown' } recovery` ,
22- ) ;
23-
2419 // 1. Build unsigned consolidations
25- if ( isSolCoin ( sdkCoin ) ) {
26- const result = await sdkCoin . recoverConsolidations ( {
27- ...req . decoded ,
28- userKey : userPub ,
29- backupKey : backupPub ,
30- bitgoKey,
31- durableNonces : req . decoded . durableNonces ! ,
32- } ) ;
20+ if ( isSolCoin ( sdkCoin ) && ! req . decoded . durableNonces ) {
21+ throw new Error ( 'durableNonces is required for Solana consolidation recovery' ) ;
22+ }
23+
24+ if ( typeof ( sdkCoin as any ) . recoverConsolidations !== 'function' ) {
25+ throw new Error ( `recoverConsolidations is not supported for coin: ${ coin } ` ) ;
26+ }
3327
34- txs = ( result as MPCTxs ) . transactions || ( result as MPCSweepTxs ) . txRequests || [ ] ;
35- } else if ( isTrxCoin ( sdkCoin ) ) {
36- const result = await sdkCoin . recoverConsolidations ( {
37- ... req . decoded ,
38- userKey : userPub ,
39- backupKey : backupPub ,
40- bitgoKey ,
41- } ) ;
28+ // Use type assertion to access recoverConsolidations
29+ const result = await ( sdkCoin as any ) . recoverConsolidations ( {
30+ ... req . decoded ,
31+ userKey : userPub ,
32+ backupKey : backupPub ,
33+ bitgoKey ,
34+ durableNonces : req . decoded . durableNonces ,
35+ } ) ;
4236
37+ if ( 'transactions' in result ) {
4338 txs = result . transactions ;
39+ } else if ( 'txRequests' in result ) {
40+ txs = result . txRequests ;
41+ } else {
42+ throw new Error ( 'recoverConsolidations did not return expected transactions' ) ;
4443 }
4544
46- console . log ( txs ) ;
4745 logger . debug ( `Found ${ txs . length } unsigned consolidation transactions` ) ;
4846
4947 // 2. For each unsigned sweep, get it signed by EBE (using recoveryMultisig)
0 commit comments