@@ -13,11 +13,11 @@ import {
1313} from '@bitgo/abstract-lightning' ;
1414import * as utxolib from '@bitgo/utxo-lib' ;
1515import { Buffer } from 'buffer' ;
16+ import { ExpressApiRouteRequest } from '../typedRoutes/api' ;
1617
17- import { CreateSignerMacaroonRequest , GetWalletStateResponse , UnlockLightningWalletRequest } from './codecs' ;
18+ import { CreateSignerMacaroonRequest , GetWalletStateResponse } from './codecs' ;
1819import { LndSignerClient } from './lndSignerClient' ;
1920import { ApiResponseError } from '../errors' ;
20- import { ExpressApiRouteRequest } from '../typedRoutes/api' ;
2121
2222type Decrypt = ( params : { input : string ; password : string } ) => string ;
2323
@@ -187,25 +187,13 @@ export async function handleGetLightningWalletState(req: express.Request): Promi
187187/**
188188 * Handle the request to unlock a wallet in the signer.
189189 */
190- export async function handleUnlockLightningWallet ( req : express . Request ) : Promise < { message : string } > {
191- const coinName = req . params . coin ;
190+ export async function handleUnlockLightningWallet (
191+ req : ExpressApiRouteRequest < 'express.lightning.unlockWallet' , 'post' >
192+ ) : Promise < { message : string } > {
193+ const { coin : coinName , id : walletId , passphrase } = req . decoded ;
192194 if ( ! isLightningCoinName ( coinName ) ) {
193195 throw new ApiResponseError ( `Invalid coin to unlock lightning wallet: ${ coinName } ` , 400 ) ;
194196 }
195- const walletId = req . params . id ;
196- if ( typeof walletId !== 'string' ) {
197- throw new ApiResponseError ( `Invalid wallet id: ${ walletId } ` , 400 ) ;
198- }
199-
200- const { passphrase } = decodeOrElse (
201- UnlockLightningWalletRequest . name ,
202- UnlockLightningWalletRequest ,
203- req . body ,
204- ( _ ) => {
205- // DON'T throw errors from decodeOrElse. It could leak sensitive information.
206- throw new ApiResponseError ( 'Invalid request body to unlock lightning wallet' , 400 ) ;
207- }
208- ) ;
209197
210198 const lndSignerClient = await LndSignerClient . create ( walletId , req . config ) ;
211199 // The passphrase at LND can only accommodate a base64 character set
0 commit comments