pub enum VersionedTransaction {
Legacy {
signatures: Vec<SignatureBytes>,
message: LegacyMessage,
},
V0 {
signatures: Vec<SignatureBytes>,
message: VersionedMessageV0,
},
}Expand description
Versioned transaction format
Variants§
Legacy
Legacy transaction format (pre-versioned transactions)
V0
Versioned transaction format V0
Fields
§
signatures: Vec<SignatureBytes>List of signatures
§
message: VersionedMessageV0Message to sign
Implementations§
Source§impl VersionedTransaction
impl VersionedTransaction
Sourcepub fn new(message: VersionedMessage) -> Self
pub fn new(message: VersionedMessage) -> Self
Create a new versioned transaction
Sourcepub fn add_signature(&mut self, signature: SignatureBytes)
pub fn add_signature(&mut self, signature: SignatureBytes)
Add a signature to the transaction
Sourcepub fn num_required_signatures(&self) -> u8
pub fn num_required_signatures(&self) -> u8
Get the number of required signatures
Sourcepub fn num_readonly_signed_accounts(&self) -> u8
pub fn num_readonly_signed_accounts(&self) -> u8
Get the number of read-only signed accounts
Sourcepub fn num_readonly_unsigned_accounts(&self) -> u8
pub fn num_readonly_unsigned_accounts(&self) -> u8
Get the number of read-only unsigned accounts
Sourcepub fn account_keys(&self) -> &[Pubkey]
pub fn account_keys(&self) -> &[Pubkey]
Get the account keys
Sourcepub fn recent_blockhash(&self) -> &[u8; 32]
pub fn recent_blockhash(&self) -> &[u8; 32]
Get the recent blockhash
Sourcepub fn instructions(&self) -> &[CompiledInstruction]
pub fn instructions(&self) -> &[CompiledInstruction]
Get the instructions
pub fn signatures(&self) -> &[SignatureBytes]
pub fn signatures_mut(&mut self) -> &mut Vec<SignatureBytes>
pub fn instructions_mut(&mut self) -> &mut Vec<CompiledInstruction>
pub fn get_compute_unit_price(&self) -> Option<u64>
pub fn set_compute_unit_price(&mut self, micro_lamports: u64) -> Result<bool>
pub fn get_compute_unit_limit(&self) -> Option<u32>
pub fn set_compute_unit_limit(&mut self, units: u32) -> Result<bool>
pub fn add_instruction(&mut self, instruction: Instruction) -> Result<()>
pub fn serialize_message(&self) -> Result<Vec<u8>>
pub fn serialize(&self) -> Result<Vec<u8>>
Sourcepub fn deserialize_with_version(bytes: &[u8]) -> Result<Self>
pub fn deserialize_with_version(bytes: &[u8]) -> Result<Self>
Deserialize a versioned transaction from bytes
Examples found in repository?
examples/decode_tx.rs (line 16)
4fn main() -> Result<(), Box<dyn std::error::Error>> {
5 // https://solscan.io/tx/24iGSgbnUUpL49Hp6ci46CrtujrMbDgZxJYcL6w3ySJudT3c5swGKnNygv4R1G3vYPwPYS9Emr3fimeEJQszDkzV
6 let tx = "ATU3t4TX00FNb4aqeojTYpIOZFQFED4pdoviPCBxUsEXwKHRbHBmmgsyEsDyjXREHGYAWlq13q4WzF5JDOvsBwKAAQAICwzd9xRZ1DCfrYBfTdgj38msCBn1maih1JKu7vCovzzacU2yFtM8/6xky5bNOdOL9vYNQWxOAtjDd8qJeKlPPJIXZyoBm/f1Y2xMsGa3gRLrL4a5Ba4vtFtLcOU1pWTT4wVKU1qZKSEGTSTocWDaOHx8NbXdvJK7geQfqEBBBUSNAwZGb+UhFzL/7K26csOb57yM5bvF9xJrLEObOkAAAAAGxoMMVxwvPwb8Y6KPKojQO9MxPeq3HTSRmeyRYk5jPwlU276eyWDJinopP+ITNpZv4YDRUa5LgXlWH4mFSlP2fhcCyQN7oqc4HZ+5zm3xXQ/FTXS7cxGfivEvGQwOFb4pA2InHkw7ace1KQX3P6I/rhhBsIayFI80eInx/pUv4R7U/fA1on6uX4cAPWh+6q5kflQbDzfTC/LJrf1AdS22d3DH2Q4dNNF2yrr6HjJmXJlYvanqTxxULDNngUZsJSq7g2zxeB7onMepv2C8TaiFnhOPYyeceZ5GEIyJx6r0FAYDADExNzQ2NzAxMDg2MTA0fDMzODYzMjQ4M3wxNzQ2NzAxMDg2MTEzfDMzODYzMjQ4M3xwBAAFApZUAgAEAAkDUMMAAAAAAAAFAgEAGFj16I5t+vX/F0jWAAAAAAAjixxoAAAAAAYMCwIABwgJCgwNDg8QDu7hX57jZwjCAQEBAQAABgwLAgAHCAkKDA0ODxBcPD8yewzFPL4CAAAAAQEAAACE1xcAAAAABAExPRcAAAABAAADAAEtixxoAAAAAAAAAAAAAAEBAQA0kqIPAAAAAPJZLkAXAAAAAQAAAwABLYscaAAAAAAAAAAAAAAB3E42Kl7pkP+vCgX6bK+0TFMtWHz2EUnYgJSxOMI1cDcABoNbXAMFAQ==";
7
8 // Decode base64 transaction
9 let tx_bytes = base64::engine::general_purpose::STANDARD.decode(tx)?;
10
11 // Print the transaction bytes structure
12 println!("Transaction bytes length: {}", tx_bytes.len());
13 println!("First byte (signature count): 0x{:02x}", tx_bytes[0]);
14
15 // Try to decode as versioned transaction using manual deserialization
16 match VersionedTransaction::deserialize_with_version(&tx_bytes) {
17 Ok(decoded_tx) => {
18 println!("✅ Successfully decoded transaction from wire format");
19 print_versioned_transaction(&decoded_tx);
20 }
21 Err(e) => {
22 println!("❌ Failed to decode transaction: {e}");
23 }
24 }
25
26 Ok(())
27}Trait Implementations§
Source§impl BorshDeserialize for VersionedTransaction
impl BorshDeserialize for VersionedTransaction
fn deserialize_reader<__R: Read>(reader: &mut __R) -> Result<Self, Error>
Source§fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
Deserializes this instance from a given slice of bytes.
Updates the buffer to point at the remaining bytes.
Source§fn try_from_slice(v: &[u8]) -> Result<Self, Error>
fn try_from_slice(v: &[u8]) -> Result<Self, Error>
Deserialize this instance from a slice of bytes.
fn try_from_reader<R>(reader: &mut R) -> Result<Self, Error>where
R: Read,
Source§impl Clone for VersionedTransaction
impl Clone for VersionedTransaction
Source§fn clone(&self) -> VersionedTransaction
fn clone(&self) -> VersionedTransaction
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for VersionedTransaction
impl Debug for VersionedTransaction
Source§impl<'de> Deserialize<'de> for VersionedTransaction
impl<'de> Deserialize<'de> for VersionedTransaction
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl EnumExt for VersionedTransaction
impl EnumExt for VersionedTransaction
Auto Trait Implementations§
impl Freeze for VersionedTransaction
impl RefUnwindSafe for VersionedTransaction
impl Send for VersionedTransaction
impl Sync for VersionedTransaction
impl Unpin for VersionedTransaction
impl UnsafeUnpin for VersionedTransaction
impl UnwindSafe for VersionedTransaction
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more