@@ -148,8 +148,8 @@ int solana_byte_array_to_unsigned_txn(uint8_t *byte_array,
148
148
utxn -> blockhash = byte_array + offset ;
149
149
offset += SOLANA_BLOCKHASH_LENGTH ;
150
150
151
- // Instructions: Currently expecting count to be 3 or 4. TODO: Handle batch
152
- // instructions
151
+ // Instructions: Currently expecting count to be 1 to 4, with only 1 transfer instruction.
152
+ // TODO: Handle batch instructions
153
153
offset += get_compact_array_size (
154
154
byte_array + offset , & (utxn -> instructions_count ), & error );
155
155
if (error != SOL_OK )
@@ -167,6 +167,10 @@ int solana_byte_array_to_unsigned_txn(uint8_t *byte_array,
167
167
hex_string_to_byte_array (SOLANA_TOKEN_PROGRAM_ADDRESS ,
168
168
SOLANA_ACCOUNT_ADDRESS_LENGTH * 2 ,
169
169
system_program_id [SOLANA_TOKEN_PROGRAM_ID_INDEX ]);
170
+ // Set Associated Token Program address
171
+ hex_string_to_byte_array (SOLANA_ASSOCIATED_TOKEN_PROGRAM_ADDRESS ,
172
+ SOLANA_ACCOUNT_ADDRESS_LENGTH * 2 ,
173
+ system_program_id [SOLANA_ASSOCIATED_TOKEN_PROGRAM_ID_INDEX ]);
170
174
// Set Compute Budget Program address
171
175
hex_string_to_byte_array (
172
176
SOLANA_COMPUTE_BUDGET_PROGRAM_ADDRESS ,
@@ -200,10 +204,8 @@ int solana_byte_array_to_unsigned_txn(uint8_t *byte_array,
200
204
SOLANA_ACCOUNT_ADDRESS_LENGTH ,
201
205
system_program_id [SOLANA_SOL_TRANSFER_PROGRAM_ID_INDEX ],
202
206
SOLANA_ACCOUNT_ADDRESS_LENGTH ) == 0 ) {
203
- if (utxn -> instruction [i ].account_addresses_index_count == 0 )
204
- return SOL_D_MIN_LENGTH ;
205
-
206
- if (utxn -> instruction [i ].opaque_data_length == 0 )
207
+ if (utxn -> instruction [i ].account_addresses_index_count == 0
208
+ || utxn -> instruction [i ].opaque_data_length == 0 )
207
209
return SOL_D_MIN_LENGTH ;
208
210
209
211
utxn -> transfer_instruction_index = i ;
@@ -233,7 +235,8 @@ int solana_byte_array_to_unsigned_txn(uint8_t *byte_array,
233
235
SOLANA_ACCOUNT_ADDRESS_LENGTH ,
234
236
system_program_id [SOLANA_TOKEN_PROGRAM_ID_INDEX ],
235
237
SOLANA_ACCOUNT_ADDRESS_LENGTH ) == 0 ) {
236
- if (utxn -> instruction [i ].account_addresses_index_count == 0 )
238
+ if (utxn -> instruction [i ].account_addresses_index_count == 0
239
+ || utxn -> instruction [i ].opaque_data_length == 0 )
237
240
return SOL_D_MIN_LENGTH ;
238
241
239
242
utxn -> transfer_instruction_index = i ;
@@ -268,6 +271,14 @@ int solana_byte_array_to_unsigned_txn(uint8_t *byte_array,
268
271
default :
269
272
break ;
270
273
}
274
+ } else if (memcmp (utxn -> account_addresses +
275
+ utxn -> instruction [i ].program_id_index *
276
+ SOLANA_ACCOUNT_ADDRESS_LENGTH ,
277
+ system_program_id [SOLANA_ASSOCIATED_TOKEN_PROGRAM_ID_INDEX ],
278
+ SOLANA_ACCOUNT_ADDRESS_LENGTH ) == 0 ) {
279
+ if (utxn -> instruction [i ].account_addresses_index_count == 0 )
280
+ return SOL_D_MIN_LENGTH ;
281
+
271
282
} else if (memcmp (utxn -> account_addresses +
272
283
utxn -> instruction [i ].program_id_index *
273
284
SOLANA_ACCOUNT_ADDRESS_LENGTH ,
@@ -316,6 +327,10 @@ int solana_validate_unsigned_txn(const solana_unsigned_txn *utxn) {
316
327
hex_string_to_byte_array (SOLANA_TOKEN_PROGRAM_ADDRESS ,
317
328
SOLANA_ACCOUNT_ADDRESS_LENGTH * 2 ,
318
329
system_program_id [SOLANA_TOKEN_PROGRAM_ID_INDEX ]);
330
+ // Set Associated Token Program address
331
+ hex_string_to_byte_array (SOLANA_ASSOCIATED_TOKEN_PROGRAM_ADDRESS ,
332
+ SOLANA_ACCOUNT_ADDRESS_LENGTH * 2 ,
333
+ system_program_id [SOLANA_ASSOCIATED_TOKEN_PROGRAM_ID_INDEX ]);
319
334
// Set Compute Budget Program address
320
335
hex_string_to_byte_array (
321
336
SOLANA_COMPUTE_BUDGET_PROGRAM_ADDRESS ,
@@ -364,6 +379,14 @@ int solana_validate_unsigned_txn(const solana_unsigned_txn *utxn) {
364
379
return SOL_V_UNSUPPORTED_INSTRUCTION ;
365
380
break ;
366
381
}
382
+ } else if (memcmp (utxn -> account_addresses +
383
+ utxn -> instruction [i ].program_id_index *
384
+ SOLANA_ACCOUNT_ADDRESS_LENGTH ,
385
+ system_program_id [SOLANA_ASSOCIATED_TOKEN_PROGRAM_ID_INDEX ],
386
+ SOLANA_ACCOUNT_ADDRESS_LENGTH ) == 0 ) {
387
+ // no opaque data or instruction enum to validate
388
+ // do nothing
389
+
367
390
} else if (memcmp (utxn -> account_addresses +
368
391
utxn -> instruction [i ].program_id_index *
369
392
SOLANA_ACCOUNT_ADDRESS_LENGTH ,
0 commit comments