@@ -659,8 +659,11 @@ describe('TSS Ecdsa Utils:', async function () {
659
659
transactions : [
660
660
{
661
661
unsignedTx : {
662
- serializedTxHex : 'TOO MANY SECRETS' ,
663
- signableHex : 'TOO MANY SECRETS' ,
662
+ // hteth txid: 0xc5a7bfe6b13ceae563da0f9feaa9c4ad1c101a15366a2a488828a5dd27cb9da3
663
+ serializedTxHex :
664
+ '02f38242688084448b9b8084448b9b908301637894a1cfb9d51c0af191ff21c5f0f01723e056f7dc12865af3107a400080c0808080' ,
665
+ signableHex :
666
+ '02f08242688084448b9b8084448b9b908301637894a1cfb9d51c0af191ff21c5f0f01723e056f7dc12865af3107a400080c0' ,
664
667
derivationPath : '' , // Needs this when key derivation is supported
665
668
} ,
666
669
state : 'pendingSignature' ,
@@ -669,8 +672,11 @@ describe('TSS Ecdsa Utils:', async function () {
669
672
] ,
670
673
unsignedTxs : [
671
674
{
672
- serializedTxHex : 'TOO MANY SECRETS' ,
673
- signableHex : 'TOO MANY SECRETS' ,
675
+ // hteth txid: 0xc5a7bfe6b13ceae563da0f9feaa9c4ad1c101a15366a2a488828a5dd27cb9da3
676
+ serializedTxHex :
677
+ '02f38242688084448b9b8084448b9b908301637894a1cfb9d51c0af191ff21c5f0f01723e056f7dc12865af3107a400080c0808080' ,
678
+ signableHex :
679
+ '02f38242688084448b9b8084448b9b908301637894a1cfb9d51c0af191ff21c5f0f01723e056f7dc12865af3107a400080c0808080' ,
674
680
derivationPath : '' , // Needs this when key derivation is supported
675
681
} ,
676
682
] ,
@@ -933,6 +939,68 @@ describe('TSS Ecdsa Utils:', async function () {
933
939
userGpgActual . should . startWith ( '-----BEGIN PGP PUBLIC KEY BLOCK-----' ) ;
934
940
} ) ;
935
941
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
+
936
1004
it ( 'getOfflineSignerPaillierModulus should succeed' , async function ( ) {
937
1005
const paillierModulus = tssUtils . getOfflineSignerPaillierModulus ( {
938
1006
prv : JSON . stringify ( {
@@ -1101,7 +1169,12 @@ describe('TSS Ecdsa Utils:', async function () {
1101
1169
userSignShare : ECDSA . SignShareRT ,
1102
1170
aShare : ECDSA . AShare ,
1103
1171
dShare : ECDSA . DShare ,
1104
- enterpriseData ?: EnterpriseData
1172
+ enterpriseData : EnterpriseData ,
1173
+ {
1174
+ signableHex,
1175
+ serializedTxHex,
1176
+ apiVersion,
1177
+ } : { signableHex ?: string ; serializedTxHex ?: string ; apiVersion ?: 'full' | 'lite' } = { }
1105
1178
) {
1106
1179
if ( enterpriseData ) {
1107
1180
await nockGetEnterprise ( { enterpriseId : enterpriseData . id , response : enterpriseData , times : 1 } ) ;
@@ -1116,12 +1189,13 @@ describe('TSS Ecdsa Utils:', async function () {
1116
1189
{
1117
1190
...txRequest ,
1118
1191
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 ,
1121
1194
derivationPath,
1122
1195
} ,
1123
1196
} ,
1124
1197
] ,
1198
+ apiVersion : apiVersion ,
1125
1199
} ,
1126
1200
] ,
1127
1201
} ;
@@ -1145,6 +1219,7 @@ describe('TSS Ecdsa Utils:', async function () {
1145
1219
} ,
1146
1220
} ,
1147
1221
] ,
1222
+ apiVersion : apiVersion ,
1148
1223
} ,
1149
1224
] ,
1150
1225
} ;
@@ -1165,6 +1240,7 @@ describe('TSS Ecdsa Utils:', async function () {
1165
1240
} ,
1166
1241
} ,
1167
1242
] ,
1243
+ apiVersion : apiVersion ,
1168
1244
} ,
1169
1245
] ,
1170
1246
} ;
0 commit comments