Struct solana_sdk::transaction::Transaction
source · [−]Expand description
An atomic transaction
Fields
signatures: Vec<Signature>
A set of digital signatures of a serialized Message
, signed by the
first signatures.len()
keys of account_keys
.
message: Message
The message to sign.
Implementations
sourceimpl Transaction
impl Transaction
pub fn new_unsigned(message: Message) -> Self
pub fn new_with_payer(
instructions: &[Instruction],
payer: Option<&Pubkey>
) -> Self
sourcepub fn new_signed_with_payer<T: Signers>(
instructions: &[Instruction],
payer: Option<&Pubkey>,
signing_keypairs: &T,
recent_blockhash: Hash
) -> Self
pub fn new_signed_with_payer<T: Signers>(
instructions: &[Instruction],
payer: Option<&Pubkey>,
signing_keypairs: &T,
recent_blockhash: Hash
) -> Self
sourcepub fn new<T: Signers>(
from_keypairs: &T,
message: Message,
recent_blockhash: Hash
) -> Transaction
pub fn new<T: Signers>(
from_keypairs: &T,
message: Message,
recent_blockhash: Hash
) -> Transaction
sourcepub fn new_with_compiled_instructions<T: Signers>(
from_keypairs: &T,
keys: &[Pubkey],
recent_blockhash: Hash,
program_ids: Vec<Pubkey>,
instructions: Vec<CompiledInstruction>
) -> Self
pub fn new_with_compiled_instructions<T: Signers>(
from_keypairs: &T,
keys: &[Pubkey],
recent_blockhash: Hash,
program_ids: Vec<Pubkey>,
instructions: Vec<CompiledInstruction>
) -> Self
Create a signed transaction
from_keypairs
- The keys used to sign the transaction.keys
- The keys for the transaction. These are the program state instances or lamport recipient keys.recent_blockhash
- The PoH hash.program_ids
- The keys that identify programs used in theinstruction
vector.instructions
- Instructions that will be executed atomically.
Panics
Panics when signing fails.
pub fn data(&self, instruction_index: usize) -> &[u8]ⓘNotable traits for &'_ [u8]impl Read for &'_ [u8]impl Write for &'_ mut [u8]
pub fn key(
&self,
instruction_index: usize,
accounts_index: usize
) -> Option<&Pubkey>
pub fn signer_key(
&self,
instruction_index: usize,
accounts_index: usize
) -> Option<&Pubkey>
sourcepub fn message_data(&self) -> Vec<u8>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn message_data(&self) -> Vec<u8>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Return the serialized message data to sign.
sourcepub fn sign<T: Signers>(&mut self, keypairs: &T, recent_blockhash: Hash)
pub fn sign<T: Signers>(&mut self, keypairs: &T, recent_blockhash: Hash)
Check keys and keypair lengths, then sign this transaction.
Panics
Panics when signing fails, use Transaction::try_sign
to handle the error.
sourcepub fn partial_sign<T: Signers>(&mut self, keypairs: &T, recent_blockhash: Hash)
pub fn partial_sign<T: Signers>(&mut self, keypairs: &T, recent_blockhash: Hash)
Sign using some subset of required keys if recent_blockhash is not the same as currently in the transaction, clear any prior signatures and update recent_blockhash
Panics
Panics when signing fails, use Transaction::try_partial_sign
to handle the error.
sourcepub fn partial_sign_unchecked<T: Signers>(
&mut self,
keypairs: &T,
positions: Vec<usize>,
recent_blockhash: Hash
)
pub fn partial_sign_unchecked<T: Signers>(
&mut self,
keypairs: &T,
positions: Vec<usize>,
recent_blockhash: Hash
)
Sign the transaction and place the signatures in their associated positions in signatures
without checking that the positions are correct.
Panics
Panics when signing fails, use Transaction::try_partial_sign_unchecked
to handle the error.
sourcepub fn try_sign<T: Signers>(
&mut self,
keypairs: &T,
recent_blockhash: Hash
) -> Result<(), SignerError>
pub fn try_sign<T: Signers>(
&mut self,
keypairs: &T,
recent_blockhash: Hash
) -> Result<(), SignerError>
Check keys and keypair lengths, then sign this transaction, returning any signing errors encountered
sourcepub fn try_partial_sign<T: Signers>(
&mut self,
keypairs: &T,
recent_blockhash: Hash
) -> Result<(), SignerError>
pub fn try_partial_sign<T: Signers>(
&mut self,
keypairs: &T,
recent_blockhash: Hash
) -> Result<(), SignerError>
Sign using some subset of required keys, returning any signing errors encountered. If recent_blockhash is not the same as currently in the transaction, clear any prior signatures and update recent_blockhash
sourcepub fn try_partial_sign_unchecked<T: Signers>(
&mut self,
keypairs: &T,
positions: Vec<usize>,
recent_blockhash: Hash
) -> Result<(), SignerError>
pub fn try_partial_sign_unchecked<T: Signers>(
&mut self,
keypairs: &T,
positions: Vec<usize>,
recent_blockhash: Hash
) -> Result<(), SignerError>
Sign the transaction, returning any signing errors encountered, and place the
signatures in their associated positions in signatures
without checking that the
positions are correct.
sourcepub fn verify_signatures_len(&self) -> bool
pub fn verify_signatures_len(&self) -> bool
Verify the length of signatures matches the value in the message header
sourcepub fn verify_and_hash_message(&self) -> Result<Hash>
pub fn verify_and_hash_message(&self) -> Result<Hash>
Verify the transaction and hash its message
pub fn verify_with_results(&self) -> Vec<bool>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
pub fn verify_precompiles(&self, feature_set: &Arc<FeatureSet>) -> Result<()>
sourcepub fn get_signing_keypair_positions(
&self,
pubkeys: &[Pubkey]
) -> Result<Vec<Option<usize>>>
pub fn get_signing_keypair_positions(
&self,
pubkeys: &[Pubkey]
) -> Result<Vec<Option<usize>>>
Get the positions of the pubkeys in account_keys
associated with signing keypairs
sourcepub fn replace_signatures(
&mut self,
signers: &[(Pubkey, Signature)]
) -> Result<()>
pub fn replace_signatures(
&mut self,
signers: &[(Pubkey, Signature)]
) -> Result<()>
Replace all the signatures and pubkeys
pub fn is_signed(&self) -> bool
Trait Implementations
sourceimpl AbiExample for Transaction
impl AbiExample for Transaction
sourceimpl Clone for Transaction
impl Clone for Transaction
sourcefn clone(&self) -> Transaction
fn clone(&self) -> Transaction
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for Transaction
impl Debug for Transaction
sourceimpl Default for Transaction
impl Default for Transaction
sourcefn default() -> Transaction
fn default() -> Transaction
Returns the “default value” for a type. Read more
sourceimpl<'de> Deserialize<'de> for Transaction
impl<'de> Deserialize<'de> for Transaction
sourcefn 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
sourceimpl PartialEq<Transaction> for Transaction
impl PartialEq<Transaction> for Transaction
sourcefn eq(&self, other: &Transaction) -> bool
fn eq(&self, other: &Transaction) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &Transaction) -> bool
fn ne(&self, other: &Transaction) -> bool
This method tests for !=
.
sourceimpl Sanitize for Transaction
impl Sanitize for Transaction
fn sanitize(&self) -> Result<(), SanitizeError>
sourceimpl Serialize for Transaction
impl Serialize for Transaction
impl Eq for Transaction
impl StructuralEq for Transaction
impl StructuralPartialEq for Transaction
Auto Trait Implementations
impl RefUnwindSafe for Transaction
impl Send for Transaction
impl Sync for Transaction
impl Unpin for Transaction
impl UnwindSafe for Transaction
Blanket Implementations
sourceimpl<T> AbiEnumVisitor for T where
T: Serialize + ?Sized,
impl<T> AbiEnumVisitor for T where
T: Serialize + ?Sized,
pub default fn visit_for_abi(
&self,
_digester: &mut AbiDigester
) -> Result<AbiDigester, DigestError>
sourceimpl<T> AbiEnumVisitor for T where
T: Serialize + AbiExample + ?Sized,
impl<T> AbiEnumVisitor for T where
T: Serialize + AbiExample + ?Sized,
pub default fn visit_for_abi(
&self,
digester: &mut AbiDigester
) -> Result<AbiDigester, DigestError>
sourceimpl<T> AbiExample for T
impl<T> AbiExample for T
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more