@@ -413,7 +413,9 @@ function decryptPrivKey(bg: BitGo, encryptedPrivKey: string, walletPw: string):
413413 }
414414}
415415
416- export async function handleV2GenerateShareTSS ( req : express . Request ) : Promise < any > {
416+ export async function handleV2GenerateShareTSS (
417+ req : ExpressApiRouteRequest < 'express.v2.tssshare.generate' , 'post' >
418+ ) : Promise < any > {
417419 const walletId = req . body . txRequest ? req . body . txRequest . walletId : req . body . tssParams . txRequest . walletId ;
418420 if ( ! walletId ) {
419421 throw new Error ( 'Missing required field: walletId' ) ;
@@ -429,13 +431,13 @@ export async function handleV2GenerateShareTSS(req: express.Request): Promise<an
429431 const encryptedPrivKey = await getEncryptedPrivKey ( signerFileSystemPath , walletId ) ;
430432 const bitgo = req . bitgo ;
431433 const privKey = decryptPrivKey ( bitgo , encryptedPrivKey , walletPw ) ;
432- const coin = bitgo . coin ( req . params . coin ) ;
434+ const coin = bitgo . coin ( req . decoded . coin ) ;
433435 req . body . prv = privKey ;
434436 req . body . walletPassphrase = walletPw ;
435437 try {
436438 if ( coin . getMPCAlgorithm ( ) === MPCType . EDDSA ) {
437439 const eddsaUtils = new EddsaUtils ( bitgo , coin ) ;
438- switch ( req . params . sharetype ) {
440+ switch ( req . decoded . sharetype ) {
439441 case ShareType . Commitment :
440442 return await eddsaUtils . createCommitmentShareFromTxRequest ( req . body ) ;
441443 case ShareType . R :
@@ -444,19 +446,19 @@ export async function handleV2GenerateShareTSS(req: express.Request): Promise<an
444446 return await eddsaUtils . createGShareFromTxRequest ( req . body ) ;
445447 default :
446448 throw new Error (
447- `Share type ${ req . params . sharetype } not supported, only commitment, G and R share generation is supported.`
449+ `Share type ${ req . decoded . sharetype } not supported, only commitment, G and R share generation is supported.`
448450 ) ;
449451 }
450452 } else if ( coin . getMPCAlgorithm ( ) === MPCType . ECDSA ) {
451453 const isMPCv2 = [
452454 ShareType . MPCv2Round1 . toString ( ) ,
453455 ShareType . MPCv2Round2 . toString ( ) ,
454456 ShareType . MPCv2Round3 . toString ( ) ,
455- ] . includes ( req . params . sharetype ) ;
457+ ] . includes ( req . decoded . sharetype ) ;
456458
457459 if ( isMPCv2 ) {
458460 const ecdsaMPCv2Utils = new EcdsaMPCv2Utils ( bitgo , coin ) ;
459- switch ( req . params . sharetype ) {
461+ switch ( req . decoded . sharetype ) {
460462 case ShareType . MPCv2Round1 :
461463 return await ecdsaMPCv2Utils . createOfflineRound1Share ( req . body ) ;
462464 case ShareType . MPCv2Round2 :
@@ -465,12 +467,12 @@ export async function handleV2GenerateShareTSS(req: express.Request): Promise<an
465467 return await ecdsaMPCv2Utils . createOfflineRound3Share ( req . body ) ;
466468 default :
467469 throw new Error (
468- `Share type ${ req . params . sharetype } not supported for MPCv2, only MPCv2Round1, MPCv2Round2 and MPCv2Round3 is supported.`
470+ `Share type ${ req . decoded . sharetype } not supported for MPCv2, only MPCv2Round1, MPCv2Round2 and MPCv2Round3 is supported.`
469471 ) ;
470472 }
471473 } else {
472474 const ecdsaUtils = new EcdsaUtils ( bitgo , coin ) ;
473- switch ( req . params . sharetype ) {
475+ switch ( req . decoded . sharetype ) {
474476 case ShareType . PaillierModulus :
475477 return ecdsaUtils . getOfflineSignerPaillierModulus ( req . body ) ;
476478 case ShareType . K :
@@ -481,7 +483,7 @@ export async function handleV2GenerateShareTSS(req: express.Request): Promise<an
481483 return await ecdsaUtils . createOfflineSShare ( req . body ) ;
482484 default :
483485 throw new Error (
484- `Share type ${ req . params . sharetype } not supported, only PaillierModulus, K, MUDelta, and S share generation is supported.`
486+ `Share type ${ req . decoded . sharetype } not supported, only PaillierModulus, K, MUDelta, and S share generation is supported.`
485487 ) ;
486488 }
487489 }
@@ -1736,12 +1738,7 @@ export function setupSigningRoutes(app: express.Application, config: Config): vo
17361738 app . use ( router ) ;
17371739
17381740 router . post ( 'express.v2.coin.sign' , [ prepareBitGo ( config ) , typedPromiseWrapper ( handleV2Sign ) ] ) ;
1739- app . post (
1740- '/api/v2/:coin/tssshare/:sharetype' ,
1741- parseBody ,
1742- prepareBitGo ( config ) ,
1743- promiseWrapper ( handleV2GenerateShareTSS )
1744- ) ;
1741+ router . post ( 'express.v2.tssshare.generate' , [ prepareBitGo ( config ) , typedPromiseWrapper ( handleV2GenerateShareTSS ) ] ) ;
17451742 router . post ( 'express.v2.ofc.extSignPayload' , [
17461743 prepareBitGo ( config ) ,
17471744 typedPromiseWrapper ( handleV2OFCSignPayloadInExtSigningMode ) ,
0 commit comments