@@ -490,8 +490,11 @@ describe('TSS Ecdsa Utils:', async function () {
490490 transactions : [
491491 {
492492 unsignedTx : {
493- serializedTxHex : 'TOO MANY SECRETS' ,
494- signableHex : 'TOO MANY SECRETS' ,
493+ // hteth txid: 0xc5a7bfe6b13ceae563da0f9feaa9c4ad1c101a15366a2a488828a5dd27cb9da3
494+ serializedTxHex :
495+ '02f38242688084448b9b8084448b9b908301637894a1cfb9d51c0af191ff21c5f0f01723e056f7dc12865af3107a400080c0808080' ,
496+ signableHex :
497+ '02f08242688084448b9b8084448b9b908301637894a1cfb9d51c0af191ff21c5f0f01723e056f7dc12865af3107a400080c0' ,
495498 derivationPath : '' , // Needs this when key derivation is supported
496499 } ,
497500 state : 'pendingSignature' ,
@@ -500,8 +503,11 @@ describe('TSS Ecdsa Utils:', async function () {
500503 ] ,
501504 unsignedTxs : [
502505 {
503- serializedTxHex : 'TOO MANY SECRETS' ,
504- signableHex : 'TOO MANY SECRETS' ,
506+ // hteth txid: 0xc5a7bfe6b13ceae563da0f9feaa9c4ad1c101a15366a2a488828a5dd27cb9da3
507+ serializedTxHex :
508+ '02f38242688084448b9b8084448b9b908301637894a1cfb9d51c0af191ff21c5f0f01723e056f7dc12865af3107a400080c0808080' ,
509+ signableHex :
510+ '02f38242688084448b9b8084448b9b908301637894a1cfb9d51c0af191ff21c5f0f01723e056f7dc12865af3107a400080c0808080' ,
505511 derivationPath : '' , // Needs this when key derivation is supported
506512 } ,
507513 ] ,
@@ -764,6 +770,68 @@ describe('TSS Ecdsa Utils:', async function () {
764770 userGpgActual . should . startWith ( '-----BEGIN PGP PUBLIC KEY BLOCK-----' ) ;
765771 } ) ;
766772
773+ it ( 'signTxRequest should fail with wrong recipient' , async function ( ) {
774+ await setupSignTxRequestNocks ( true , userSignShare , aShare , dShare , enterpriseData ) ;
775+ await tssUtils
776+ . signTxRequest ( {
777+ txRequest : txRequestId ,
778+ prv : JSON . stringify ( {
779+ pShare : userKeyShare . pShare ,
780+ bitgoNShare : bitgoKeyShare . nShares [ 1 ] ,
781+ backupNShare : backupKeyShare . nShares [ 1 ] ,
782+ } ) ,
783+ reqId,
784+ txParams : { recipients : [ { address : '0x1234' , amount : '100000000000000' } ] , type : 'transfer' } ,
785+ } )
786+ . should . be . rejectedWith ( 'destination address does not match with the recipient address' ) ;
787+ } ) ;
788+
789+ it ( 'signTxRequest should fail with incorrect value' , async function ( ) {
790+ await setupSignTxRequestNocks ( true , userSignShare , aShare , dShare , enterpriseData ) ;
791+ await tssUtils
792+ . signTxRequest ( {
793+ txRequest : txRequestId ,
794+ prv : JSON . stringify ( {
795+ pShare : userKeyShare . pShare ,
796+ bitgoNShare : bitgoKeyShare . nShares [ 1 ] ,
797+ backupNShare : backupKeyShare . nShares [ 1 ] ,
798+ } ) ,
799+ reqId,
800+ txParams : {
801+ recipients : [ { address : '0xa1cfb9d51c0af191ff21c5f0f01723e056f7dc12' , amount : '1' } ] ,
802+ type : 'transfer' ,
803+ } ,
804+ } )
805+ . should . be . rejectedWith ( 'the transaction amount in txPrebuild does not match the value given by client' ) ;
806+ } ) ;
807+
808+ it ( 'signTxRequest should fail with incorrect value for token txn' , async function ( ) {
809+ const signableHex =
810+ '02f86d8242681083122c9e83122cae8301e04994ebe8b46a42f05072b723b00013ff822b2af1b5cb80b844a9059cbb0000000000000000000000002b0d6cb2f8c388757f4d7ad857fccab18290dbc900000000000000000000000000000000000000000000000000000000000186a0c0' ;
811+ const serializedTxHex =
812+ '02f8708242681083122c9e83122cae8301e04994ebe8b46a42f05072b723b00013ff822b2af1b5cb80b844a9059cbb0000000000000000000000002b0d6cb2f8c388757f4d7ad857fccab18290dbc900000000000000000000000000000000000000000000000000000000000186a0c0808080' ;
813+ await setupSignTxRequestNocks ( true , userSignShare , aShare , dShare , enterpriseData , {
814+ signableHex,
815+ serializedTxHex,
816+ apiVersion : 'full' ,
817+ } ) ;
818+ await tssUtils
819+ . signTxRequest ( {
820+ txRequest : txRequestId ,
821+ prv : JSON . stringify ( {
822+ pShare : userKeyShare . pShare ,
823+ bitgoNShare : bitgoKeyShare . nShares [ 1 ] ,
824+ backupNShare : backupKeyShare . nShares [ 1 ] ,
825+ } ) ,
826+ reqId,
827+ txParams : {
828+ recipients : [ { address : '0x2b0d6cb2f8c388757f4d7ad857fccab18290dbc9' , amount : '707' } ] ,
829+ type : 'transfer' ,
830+ } ,
831+ } )
832+ . should . be . rejectedWith ( 'the transaction amount in txPrebuild does not match the value given by client' ) ;
833+ } ) ;
834+
767835 it ( 'getOfflineSignerPaillierModulus should succeed' , async function ( ) {
768836 const paillierModulus = tssUtils . getOfflineSignerPaillierModulus ( {
769837 prv : JSON . stringify ( {
@@ -932,7 +1000,12 @@ describe('TSS Ecdsa Utils:', async function () {
9321000 userSignShare : ECDSA . SignShareRT ,
9331001 aShare : ECDSA . AShare ,
9341002 dShare : ECDSA . DShare ,
935- enterpriseData ?: EnterpriseData
1003+ enterpriseData : EnterpriseData ,
1004+ {
1005+ signableHex,
1006+ serializedTxHex,
1007+ apiVersion,
1008+ } : { signableHex ?: string ; serializedTxHex ?: string ; apiVersion ?: 'full' | 'lite' } = { }
9361009 ) {
9371010 if ( enterpriseData ) {
9381011 await nockGetEnterprise ( { enterpriseId : enterpriseData . id , response : enterpriseData , times : 1 } ) ;
@@ -947,12 +1020,13 @@ describe('TSS Ecdsa Utils:', async function () {
9471020 {
9481021 ...txRequest ,
9491022 unsignedTx : {
950- signableHex : txRequest . unsignedTxs [ 0 ] . signableHex ,
951- serializedTxHex : txRequest . unsignedTxs [ 0 ] . serializedTxHex ,
1023+ signableHex : signableHex ?? txRequest . unsignedTxs [ 0 ] . signableHex ,
1024+ serializedTxHex : serializedTxHex ?? txRequest . unsignedTxs [ 0 ] . serializedTxHex ,
9521025 derivationPath,
9531026 } ,
9541027 } ,
9551028 ] ,
1029+ apiVersion : apiVersion ,
9561030 } ,
9571031 ] ,
9581032 } ;
@@ -976,6 +1050,7 @@ describe('TSS Ecdsa Utils:', async function () {
9761050 } ,
9771051 } ,
9781052 ] ,
1053+ apiVersion : apiVersion ,
9791054 } ,
9801055 ] ,
9811056 } ;
@@ -996,6 +1071,7 @@ describe('TSS Ecdsa Utils:', async function () {
9961071 } ,
9971072 } ,
9981073 ] ,
1074+ apiVersion : apiVersion ,
9991075 } ,
10001076 ] ,
10011077 } ;
0 commit comments