@@ -201,6 +201,34 @@ describe('IOTA:', function () {
201201 ) ;
202202 } ) ;
203203
204+ it ( 'should verify transaction with recipients containing extra fields' , async function ( ) {
205+ // The verification should only compare address, amount, and tokenName
206+ // Extra fields should be ignored
207+ const txBuilder = factory . getTransferBuilder ( ) ;
208+ txBuilder . sender ( testData . sender . address ) ;
209+ txBuilder . recipients ( testData . recipients ) ;
210+ txBuilder . paymentObjects ( testData . paymentObjects ) ;
211+ txBuilder . gasData ( testData . gasData ) ;
212+
213+ const tx = ( await txBuilder . build ( ) ) as TransferTransaction ;
214+ const txHex = Buffer . from ( await tx . toBroadcastFormat ( ) , 'base64' ) . toString ( 'hex' ) ;
215+
216+ // Add extra fields to recipients that should be ignored during comparison
217+ const recipientsWithExtraFields = testData . recipients . map ( ( r ) => ( {
218+ ...r ,
219+ extraField : 'should be ignored' ,
220+ anotherField : 123 ,
221+ } ) ) ;
222+
223+ should . equal (
224+ await basecoin . verifyTransaction ( {
225+ txPrebuild : { txHex : txHex } ,
226+ txParams : { recipients : recipientsWithExtraFields } ,
227+ } ) ,
228+ true
229+ ) ;
230+ } ) ;
231+
204232 it ( 'should detect mismatched recipients' , async function ( ) {
205233 const txBuilder = factory . getTransferBuilder ( ) ;
206234 txBuilder . sender ( testData . sender . address ) ;
@@ -210,11 +238,20 @@ describe('IOTA:', function () {
210238
211239 const tx = ( await txBuilder . build ( ) ) as TransferTransaction ;
212240 const txHex = Buffer . from ( await tx . toBroadcastFormat ( ) , 'base64' ) . toString ( 'hex' ) ;
213- assert . rejects (
241+
242+ // Create mismatched recipients with different addresses/amounts
243+ const mismatchedRecipients = [
244+ {
245+ address : testData . addresses . validAddresses [ 2 ] , // Different address
246+ amount : '9999' , // Different amount
247+ } ,
248+ ] ;
249+
250+ await assert . rejects (
214251 async ( ) =>
215252 await basecoin . verifyTransaction ( {
216253 txPrebuild : { txHex : txHex } ,
217- txParams : { recipients : testData . recipients } ,
254+ txParams : { recipients : mismatchedRecipients } ,
218255 } ) ,
219256 / T x r e c i p i e n t s d o e s n o t m a t c h w i t h e x p e c t e d t x P a r a m s r e c i p i e n t s /
220257 ) ;
0 commit comments