@@ -59,6 +59,28 @@ describe('TrxToken verifyTransaction:', function () {
5959 assert . strictEqual ( result , true ) ;
6060 } ) ;
6161
62+ it ( 'should validate when recipient is supplied as 0x-prefixed hex (COINS-1575)' , async function ( ) {
63+ const recipientEvm = '0x' + TRC20_RECIPIENT_HEX . slice ( 2 ) . toLowerCase ( ) ;
64+
65+ const result = await tokenCoin . verifyTransaction ( {
66+ txPrebuild : { txHex : TRC20_RAW_DATA_HEX } ,
67+ txParams : { recipients : [ { address : recipientEvm , amount : TRC20_AMOUNT } ] } ,
68+ walletType : 'tss' ,
69+ } as any ) ;
70+
71+ assert . strictEqual ( result , true ) ;
72+ } ) ;
73+
74+ it ( 'should validate when recipient is supplied as 41-prefixed hex (COINS-1575)' , async function ( ) {
75+ const result = await tokenCoin . verifyTransaction ( {
76+ txPrebuild : { txHex : TRC20_RAW_DATA_HEX } ,
77+ txParams : { recipients : [ { address : TRC20_RECIPIENT_HEX , amount : TRC20_AMOUNT } ] } ,
78+ walletType : 'tss' ,
79+ } as any ) ;
80+
81+ assert . strictEqual ( result , true ) ;
82+ } ) ;
83+
6284 it ( 'should throw when amount does not match' , async function ( ) {
6385 const recipientBase58 = Utils . getBase58AddressFromHex ( TRC20_RECIPIENT_HEX ) ;
6486
@@ -127,11 +149,12 @@ describe('TrxToken verifyTransaction:', function () {
127149 } ) ;
128150
129151 describe ( 'non-TSS wallet — builder-based validation (existing path)' , ( ) => {
152+ const txHex =
153+ '{"raw_data":{"contractType":2,"contract":[{"parameter":{"value":{"data":"a9059cbb0000000000000000000000008483618ca85c35a9b923d98bebca718f5a1db2790000000000000000000000000000000000000000000000000000000005f5e100","owner_address":"41c51fbeea78910b15b1d3e8a9b62914ca94d1a4ac","contract_address":"4142a1e39aefa49290f2b3f9ed688d7cecf86cd6e0"},"type_url":"type.googleapis.com/protocol.TriggerSmartContract"},"type":"TriggerSmartContract"}],"expiration":1674581767432,"timestamp":1674578167432,"ref_block_bytes":"578b","ref_block_hash":"6113bb9ac351432b","fee_limit":15000000},"raw_data_hex":"0a02578b22086113bb9ac351432b4088eae7a6de305aae01081f12a9010a31747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e54726967676572536d617274436f6e747261637412740a1541c51fbeea78910b15b1d3e8a9b62914ca94d1a4ac12154142a1e39aefa49290f2b3f9ed688d7cecf86cd6e02244a9059cbb0000000000000000000000008483618ca85c35a9b923d98bebca718f5a1db2790000000000000000000000000000000000000000000000000000000005f5e10070888d8ca5de309001c0c39307","txID":"fe21c49f4febd9089125e3a006943c145721d8fcb7ab84136f8c6663ff92f8ed","signature":["0775cde302689eb8293883c66a89b31e80d608bfc3ad3c283b64a490ea4cc712c55a2fd2e62c75843dd7e77d8c4cb52e0f371fbb29b332c259f8cb63c2e6195301"]}' ;
154+
130155 it ( 'should validate a correct non-TSS TRC20 transfer using txBuilder' , async function ( ) {
131156 // The non-TSS path uses getBuilder().from(rawTx).build() and checks tx.outputs[0]
132157 // This test uses the full JSON tx format that the builder understands.
133- const txHex =
134- '{"raw_data":{"contractType":2,"contract":[{"parameter":{"value":{"data":"a9059cbb0000000000000000000000008483618ca85c35a9b923d98bebca718f5a1db2790000000000000000000000000000000000000000000000000000000005f5e100","owner_address":"41c51fbeea78910b15b1d3e8a9b62914ca94d1a4ac","contract_address":"4142a1e39aefa49290f2b3f9ed688d7cecf86cd6e0"},"type_url":"type.googleapis.com/protocol.TriggerSmartContract"},"type":"TriggerSmartContract"}],"expiration":1674581767432,"timestamp":1674578167432,"ref_block_bytes":"578b","ref_block_hash":"6113bb9ac351432b","fee_limit":15000000},"raw_data_hex":"0a02578b22086113bb9ac351432b4088eae7a6de305aae01081f12a9010a31747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e54726967676572536d617274436f6e747261637412740a1541c51fbeea78910b15b1d3e8a9b62914ca94d1a4ac12154142a1e39aefa49290f2b3f9ed688d7cecf86cd6e02244a9059cbb0000000000000000000000008483618ca85c35a9b923d98bebca718f5a1db2790000000000000000000000000000000000000000000000000000000005f5e10070888d8ca5de309001c0c39307","txID":"fe21c49f4febd9089125e3a006943c145721d8fcb7ab84136f8c6663ff92f8ed","signature":["0775cde302689eb8293883c66a89b31e80d608bfc3ad3c283b64a490ea4cc712c55a2fd2e62c75843dd7e77d8c4cb52e0f371fbb29b332c259f8cb63c2e6195301"]}' ;
135158 const recipientBase58 = Utils . getBase58AddressFromHex ( TRC20_RECIPIENT_HEX ) ;
136159
137160 const result = await tokenCoin . verifyTransaction ( {
@@ -141,5 +164,25 @@ describe('TrxToken verifyTransaction:', function () {
141164
142165 assert . strictEqual ( result , true ) ;
143166 } ) ;
167+
168+ it ( 'should validate when recipient is 0x-prefixed hex (hot wallet sendmany / COINS-1575)' , async function ( ) {
169+ const recipientEvm = '0x' + TRC20_RECIPIENT_HEX . slice ( 2 ) . toLowerCase ( ) ;
170+
171+ const result = await tokenCoin . verifyTransaction ( {
172+ txPrebuild : { txHex } ,
173+ txParams : { recipients : [ { address : recipientEvm , amount : TRC20_AMOUNT } ] } ,
174+ } as any ) ;
175+
176+ assert . strictEqual ( result , true ) ;
177+ } ) ;
178+
179+ it ( 'should validate when recipient is 41-prefixed hex (hot wallet sendmany / COINS-1575)' , async function ( ) {
180+ const result = await tokenCoin . verifyTransaction ( {
181+ txPrebuild : { txHex } ,
182+ txParams : { recipients : [ { address : TRC20_RECIPIENT_HEX , amount : TRC20_AMOUNT } ] } ,
183+ } as any ) ;
184+
185+ assert . strictEqual ( result , true ) ;
186+ } ) ;
144187 } ) ;
145188} ) ;
0 commit comments