For extra security I want to validate a transaction signature before further processing. I'm getting the TransactionSignature
from get_transaction
and the json looks similar to this..
{
slot: 327,
transaction: EncodedTransactionWithStatusMeta(EncodedTransactionWithStatusMeta {
transaction: Json(UiTransaction {
signatures: ["39KgKCP..."],
message: Raw(UiRawMessage {
...,
account_keys: [
"Ai1f6bfbWVfbmaiRciZanknE6U...", //user
"AJc89876CYwrmN6dEHgMRBerw7...", //item Account
"7i57Rf9qHN16JukEh12iXDPaWo...", // <- Want to confirm this
"9KjfZKeCDeo8AU9pzxQZKskiTx...", //another account
"6ihFxDWJoA6f6bj9fdsfew33ohJ6n7kg", //program ID
"11111111111111111111111111111111", //system
"SysvarRent111111111111111111111111111111111" //rent
],
recent_blockhash: "9Uoo2fQ1BwMgF5ZSqHmbYhujF4cuQxtnbaWpMQu67Ffh",
...
})
}),
meta: Some(UiTransactionStatus ....
I'm breaking down this JSON data to receive the account_keys
array and I want to confirm account_keys[2]
is a certain account.
So my question is, will the order of these account keys change randomly or is this a static order?
I want to be able to verify account_keys[2]
to always be a certain value so just want to make sure this will not change.
I should mention that the reason this began as a concern is because in the Anchor Program, this is not the order in which the accounts are listed and I was confused why the order was changed this way.