@@ -659,8 +659,11 @@ describe('TSS Ecdsa Utils:', async function () {
659659 transactions : [
660660 {
661661 unsignedTx : {
662- serializedTxHex : 'TOO MANY SECRETS' ,
663- signableHex : 'TOO MANY SECRETS' ,
662+ // hteth txid: 0xc5a7bfe6b13ceae563da0f9feaa9c4ad1c101a15366a2a488828a5dd27cb9da3
663+ serializedTxHex :
664+ '02f38242688084448b9b8084448b9b908301637894a1cfb9d51c0af191ff21c5f0f01723e056f7dc12865af3107a400080c0808080' ,
665+ signableHex :
666+ '02f08242688084448b9b8084448b9b908301637894a1cfb9d51c0af191ff21c5f0f01723e056f7dc12865af3107a400080c0' ,
664667 derivationPath : '' , // Needs this when key derivation is supported
665668 } ,
666669 state : 'pendingSignature' ,
@@ -669,8 +672,11 @@ describe('TSS Ecdsa Utils:', async function () {
669672 ] ,
670673 unsignedTxs : [
671674 {
672- serializedTxHex : 'TOO MANY SECRETS' ,
673- signableHex : 'TOO MANY SECRETS' ,
675+ // hteth txid: 0xc5a7bfe6b13ceae563da0f9feaa9c4ad1c101a15366a2a488828a5dd27cb9da3
676+ serializedTxHex :
677+ '02f38242688084448b9b8084448b9b908301637894a1cfb9d51c0af191ff21c5f0f01723e056f7dc12865af3107a400080c0808080' ,
678+ signableHex :
679+ '02f38242688084448b9b8084448b9b908301637894a1cfb9d51c0af191ff21c5f0f01723e056f7dc12865af3107a400080c0808080' ,
674680 derivationPath : '' , // Needs this when key derivation is supported
675681 } ,
676682 ] ,
@@ -933,6 +939,68 @@ describe('TSS Ecdsa Utils:', async function () {
933939 userGpgActual . should . startWith ( '-----BEGIN PGP PUBLIC KEY BLOCK-----' ) ;
934940 } ) ;
935941
942+ it ( 'signTxRequest should fail with wrong recipient' , async function ( ) {
943+ await setupSignTxRequestNocks ( true , userSignShare , aShare , dShare , enterpriseData ) ;
944+ await tssUtils
945+ . signTxRequest ( {
946+ txRequest : txRequestId ,
947+ prv : JSON . stringify ( {
948+ pShare : userKeyShare . pShare ,
949+ bitgoNShare : bitgoKeyShare . nShares [ 1 ] ,
950+ backupNShare : backupKeyShare . nShares [ 1 ] ,
951+ } ) ,
952+ reqId,
953+ txParams : { recipients : [ { address : '0x1234' , amount : '100000000000000' } ] , type : 'transfer' } ,
954+ } )
955+ . should . be . rejectedWith ( 'destination address does not match with the recipient address' ) ;
956+ } ) ;
957+
958+ it ( 'signTxRequest should fail with incorrect value' , async function ( ) {
959+ await setupSignTxRequestNocks ( true , userSignShare , aShare , dShare , enterpriseData ) ;
960+ await tssUtils
961+ . signTxRequest ( {
962+ txRequest : txRequestId ,
963+ prv : JSON . stringify ( {
964+ pShare : userKeyShare . pShare ,
965+ bitgoNShare : bitgoKeyShare . nShares [ 1 ] ,
966+ backupNShare : backupKeyShare . nShares [ 1 ] ,
967+ } ) ,
968+ reqId,
969+ txParams : {
970+ recipients : [ { address : '0xa1cfb9d51c0af191ff21c5f0f01723e056f7dc12' , amount : '1' } ] ,
971+ type : 'transfer' ,
972+ } ,
973+ } )
974+ . should . be . rejectedWith ( 'the transaction amount in txPrebuild does not match the value given by client' ) ;
975+ } ) ;
976+
977+ it ( 'signTxRequest should fail with incorrect value for token txn' , async function ( ) {
978+ const signableHex =
979+ '02f86d8242681083122c9e83122cae8301e04994ebe8b46a42f05072b723b00013ff822b2af1b5cb80b844a9059cbb0000000000000000000000002b0d6cb2f8c388757f4d7ad857fccab18290dbc900000000000000000000000000000000000000000000000000000000000186a0c0' ;
980+ const serializedTxHex =
981+ '02f8708242681083122c9e83122cae8301e04994ebe8b46a42f05072b723b00013ff822b2af1b5cb80b844a9059cbb0000000000000000000000002b0d6cb2f8c388757f4d7ad857fccab18290dbc900000000000000000000000000000000000000000000000000000000000186a0c0808080' ;
982+ await setupSignTxRequestNocks ( true , userSignShare , aShare , dShare , enterpriseData , {
983+ signableHex,
984+ serializedTxHex,
985+ apiVersion : 'full' ,
986+ } ) ;
987+ await tssUtils
988+ . signTxRequest ( {
989+ txRequest : txRequestId ,
990+ prv : JSON . stringify ( {
991+ pShare : userKeyShare . pShare ,
992+ bitgoNShare : bitgoKeyShare . nShares [ 1 ] ,
993+ backupNShare : backupKeyShare . nShares [ 1 ] ,
994+ } ) ,
995+ reqId,
996+ txParams : {
997+ recipients : [ { address : '0x2b0d6cb2f8c388757f4d7ad857fccab18290dbc9' , amount : '707' } ] ,
998+ type : 'transfer' ,
999+ } ,
1000+ } )
1001+ . should . be . rejectedWith ( 'the transaction amount in txPrebuild does not match the value given by client' ) ;
1002+ } ) ;
1003+
9361004 it ( 'getOfflineSignerPaillierModulus should succeed' , async function ( ) {
9371005 const paillierModulus = tssUtils . getOfflineSignerPaillierModulus ( {
9381006 prv : JSON . stringify ( {
@@ -1101,7 +1169,12 @@ describe('TSS Ecdsa Utils:', async function () {
11011169 userSignShare : ECDSA . SignShareRT ,
11021170 aShare : ECDSA . AShare ,
11031171 dShare : ECDSA . DShare ,
1104- enterpriseData ?: EnterpriseData
1172+ enterpriseData : EnterpriseData ,
1173+ {
1174+ signableHex,
1175+ serializedTxHex,
1176+ apiVersion,
1177+ } : { signableHex ?: string ; serializedTxHex ?: string ; apiVersion ?: 'full' | 'lite' } = { }
11051178 ) {
11061179 if ( enterpriseData ) {
11071180 await nockGetEnterprise ( { enterpriseId : enterpriseData . id , response : enterpriseData , times : 1 } ) ;
@@ -1116,12 +1189,13 @@ describe('TSS Ecdsa Utils:', async function () {
11161189 {
11171190 ...txRequest ,
11181191 unsignedTx : {
1119- signableHex : txRequest . unsignedTxs [ 0 ] . signableHex ,
1120- serializedTxHex : txRequest . unsignedTxs [ 0 ] . serializedTxHex ,
1192+ signableHex : signableHex ?? txRequest . unsignedTxs [ 0 ] . signableHex ,
1193+ serializedTxHex : serializedTxHex ?? txRequest . unsignedTxs [ 0 ] . serializedTxHex ,
11211194 derivationPath,
11221195 } ,
11231196 } ,
11241197 ] ,
1198+ apiVersion : apiVersion ,
11251199 } ,
11261200 ] ,
11271201 } ;
@@ -1145,6 +1219,7 @@ describe('TSS Ecdsa Utils:', async function () {
11451219 } ,
11461220 } ,
11471221 ] ,
1222+ apiVersion : apiVersion ,
11481223 } ,
11491224 ] ,
11501225 } ;
@@ -1165,6 +1240,7 @@ describe('TSS Ecdsa Utils:', async function () {
11651240 } ,
11661241 } ,
11671242 ] ,
1243+ apiVersion : apiVersion ,
11681244 } ,
11691245 ] ,
11701246 } ;
0 commit comments