You can access the account_keys
directly on the solana_program::message::v0::Message
struct https://docs.rs/solana-program/latest/solana_program/message/v0/struct.Message.html
And if you want code to help with creating a versioned message, there's a great example at try_compile
https://docs.rs/solana-program/latest/solana_program/message/v0/struct.Message.html#method.try_compile, which I'm pasting here:
use anyhow::Result;
use solana_rpc_client::rpc_client::RpcClient;
use solana_program::address_lookup_table::{self, state::{AddressLookupTable, LookupTableMeta}};
use solana_sdk::{
address_lookup_table_account::AddressLookupTableAccount,
instruction::{AccountMeta, Instruction},
message::{VersionedMessage, v0},
pubkey::Pubkey,
signature::{Keypair, Signer},
transaction::VersionedTransaction,
};
fn create_tx_with_address_table_lookup(
client: &RpcClient,
instruction: Instruction,
address_lookup_table_key: Pubkey,
payer: &Keypair,
) -> Result<VersionedTransaction> {
let raw_account = client.get_account(&address_lookup_table_key)?;
let address_lookup_table = AddressLookupTable::deserialize(&raw_account.data)?;
let address_lookup_table_account = AddressLookupTableAccount {
key: address_lookup_table_key,
addresses: address_lookup_table.addresses.to_vec(),
};
let blockhash = client.get_latest_blockhash()?;
let tx = VersionedTransaction::try_new(
VersionedMessage::V0(v0::Message::try_compile(
&payer.pubkey(),
&[instruction],
&[address_lookup_table_account],
blockhash,
)?),
&[payer],
)?;
Ok(tx)
}