Enum fuel_tx::Transaction
source · [−]pub enum Transaction {
Script {
gas_price: Word,
gas_limit: Word,
maturity: Word,
receipts_root: Bytes32,
script: Vec<u8>,
script_data: Vec<u8>,
inputs: Vec<Input>,
outputs: Vec<Output>,
witnesses: Vec<Witness>,
metadata: Option<Metadata>,
},
Create {
gas_price: Word,
gas_limit: Word,
maturity: Word,
bytecode_length: Word,
bytecode_witness_index: u8,
salt: Salt,
storage_slots: Vec<StorageSlot>,
inputs: Vec<Input>,
outputs: Vec<Output>,
witnesses: Vec<Witness>,
metadata: Option<Metadata>,
},
}
Variants
Script
Create
Fields
gas_price: Word
gas_limit: Word
maturity: Word
bytecode_length: Word
bytecode_witness_index: u8
salt: Salt
storage_slots: Vec<StorageSlot>
Implementations
sourceimpl Transaction
impl Transaction
pub fn precompute_metadata(&mut self)
sourceimpl Transaction
impl Transaction
sourcepub const fn script_offset() -> usize
pub const fn script_offset() -> usize
For a serialized transaction of type Script
, return the bytes offset
of the script
sourcepub fn script_data_offset(&self) -> Option<usize>
pub fn script_data_offset(&self) -> Option<usize>
For a serialized transaction of type Script
, return the bytes offset
of the script data
sourcepub fn input_predicate_offset(&self, index: usize) -> Option<(usize, usize)>
pub fn input_predicate_offset(&self, index: usize) -> Option<(usize, usize)>
Return the offset/length tuple for an input predicate indexed by index
.
Return None
either if index
is invalid, or if its not a [Input::CoinPredicate
]
sourcepub fn input_offset(&self, index: usize) -> Option<usize>
pub fn input_offset(&self, index: usize) -> Option<usize>
Return the serialized bytes offset of the input with the provided index
Return None
if index
is invalid
sourcepub fn output_offset(&self, index: usize) -> Option<usize>
pub fn output_offset(&self, index: usize) -> Option<usize>
Return the serialized bytes offset of the output with the provided index
Return None
if index
is invalid
sourcepub fn witness_offset(&self, index: usize) -> Option<usize>
pub fn witness_offset(&self, index: usize) -> Option<usize>
Return the serialized bytes offset of the witness with the provided index
Return None
if index
is invalid
sourcepub const fn receipts_root_offset(&self) -> Option<usize>
pub const fn receipts_root_offset(&self) -> Option<usize>
For a serialized transaction of type Script
, return the bytes offset
of the receipts root
sourceimpl Transaction
impl Transaction
sourcepub fn validate(
&self,
block_height: Word,
parameters: &ConsensusParameters
) -> Result<(), ValidationError>
pub fn validate(
&self,
block_height: Word,
parameters: &ConsensusParameters
) -> Result<(), ValidationError>
Validate the transaction.
This function will reflect the stateful property of Output::validate
pub fn validate_input_signature(&self) -> Result<(), ValidationError>
sourcepub fn validate_without_signature(
&self,
block_height: Word,
parameters: &ConsensusParameters
) -> Result<(), ValidationError>
pub fn validate_without_signature(
&self,
block_height: Word,
parameters: &ConsensusParameters
) -> Result<(), ValidationError>
Validate the transaction.
This function will reflect the stateful property of Output::validate
sourceimpl Transaction
impl Transaction
sourceimpl Transaction
impl Transaction
pub fn try_from_bytes(bytes: &[u8]) -> Result<(usize, Self)>
sourceimpl Transaction
impl Transaction
pub const fn script(
gas_price: Word,
gas_limit: Word,
maturity: Word,
script: Vec<u8>,
script_data: Vec<u8>,
inputs: Vec<Input>,
outputs: Vec<Output>,
witnesses: Vec<Witness>
) -> Self
pub fn create(
gas_price: Word,
gas_limit: Word,
maturity: Word,
bytecode_witness_index: u8,
salt: Salt,
storage_slots: Vec<StorageSlot>,
inputs: Vec<Input>,
outputs: Vec<Output>,
witnesses: Vec<Witness>
) -> Self
pub fn input_asset_ids(&self) -> impl Iterator<Item = &AssetId>
pub fn input_asset_ids_unique(&self) -> impl Iterator<Item = &AssetId>
pub fn input_contracts(&self) -> impl Iterator<Item = &ContractId>
pub fn check_predicate_owners(&self) -> bool
pub fn check_predicate_owner(&self, idx: usize) -> bool
pub const fn gas_price(&self) -> Word
pub fn set_gas_price(&mut self, price: Word)
pub const fn gas_limit(&self) -> Word
pub fn set_gas_limit(&mut self, limit: Word)
pub const fn maturity(&self) -> Word
pub fn set_maturity(&mut self, mat: Word)
pub const fn is_script(&self) -> bool
pub const fn metadata(&self) -> Option<&Metadata>
pub const fn salt(&self) -> Option<&Salt>
pub fn inputs(&self) -> &[Input]
pub fn outputs(&self) -> &[Output]
pub fn witnesses(&self) -> &[Witness]
pub fn set_witnesses(&mut self, new_witnesses: Vec<Witness>)
pub const fn receipts_root(&self) -> Option<&Bytes32>
pub fn set_receipts_root(&mut self, root: Bytes32) -> Option<Bytes32>
sourcepub fn add_unsigned_coin_input(
&mut self,
utxo_id: UtxoId,
owner: &PublicKey,
amount: Word,
asset_id: AssetId,
tx_pointer: TxPointer,
maturity: Word
)
pub fn add_unsigned_coin_input(
&mut self,
utxo_id: UtxoId,
owner: &PublicKey,
amount: Word,
asset_id: AssetId,
tx_pointer: TxPointer,
maturity: Word
)
Append a new unsigned coin input to the transaction.
When the transaction is constructed, Transaction::sign_inputs
should
be called for every secret key used with this method.
The production of the signatures can be done only after the full transaction skeleton is built because the input of the hash message is the ID of the final transaction.
sourcepub fn add_unsigned_message_input(
&mut self,
sender: Address,
recipient: Address,
nonce: Word,
owner: &PublicKey,
amount: Word,
data: Vec<u8>
)
pub fn add_unsigned_message_input(
&mut self,
sender: Address,
recipient: Address,
nonce: Word,
owner: &PublicKey,
amount: Word,
data: Vec<u8>
)
Append a new unsigned message input to the transaction.
When the transaction is constructed, Transaction::sign_inputs
should
be called for every secret key used with this method.
The production of the signatures can be done only after the full transaction skeleton is built because the input of the hash message is the ID of the final transaction.
sourcepub fn sign_inputs(&mut self, secret: &SecretKey)
pub fn sign_inputs(&mut self, secret: &SecretKey)
For all inputs of type coin
or message
, check if its owner
equals the public
counterpart of the provided key. Sign all matches.
sourcepub fn metered_bytes_size(&self) -> usize
pub fn metered_bytes_size(&self) -> usize
Used for accounting purposes when charging byte based fees
sourcepub fn prepare_init_script(&mut self) -> Result<&mut Self>
pub fn prepare_init_script(&mut self) -> Result<&mut Self>
Prepare the transaction for VM initialization for script execution
note: Fields dependent on storage/state such as balance and state roots, or tx pointers, should already set by the client beforehand.
sourcepub fn prepare_init_predicate(&mut self) -> &mut Self
pub fn prepare_init_predicate(&mut self) -> &mut Self
Prepare the transaction for VM initialization for predicate verification
pub fn script_len(&self) -> Option<usize>
pub fn script_data_len(&self) -> Option<usize>
pub const fn bytecode_length(&self) -> Option<Word>
pub const fn bytecode_witness_index(&self) -> Option<u8>
pub fn storage_slots(&self) -> Option<&[StorageSlot]>
pub const fn salt_offset(&self) -> Option<usize>
pub fn storage_slot_offset(&self, idx: usize) -> Option<usize>
pub fn find_output_contract(&self, input: usize) -> Option<(usize, &Output)>
sourceimpl Transaction
impl Transaction
sourcepub fn check(
self,
block_height: Word,
params: &ConsensusParameters
) -> Result<CheckedTransaction, ValidationError>
pub fn check(
self,
block_height: Word,
params: &ConsensusParameters
) -> Result<CheckedTransaction, ValidationError>
Fully verify transaction, including signatures.
For more info, check CheckedTransaction::check
.
sourcepub fn check_without_signature(
self,
block_height: Word,
params: &ConsensusParameters
) -> Result<CheckedTransaction, ValidationError>
pub fn check_without_signature(
self,
block_height: Word,
params: &ConsensusParameters
) -> Result<CheckedTransaction, ValidationError>
Verify transaction, without signature checks.
For more info, check CheckedTransaction::check_unsigned
.
Trait Implementations
sourceimpl AsRef<Transaction> for CheckedTransaction
impl AsRef<Transaction> for CheckedTransaction
sourcefn as_ref(&self) -> &TransactionⓘNotable traits for Transactionimpl Read for Transactionimpl Write for Transaction
fn as_ref(&self) -> &TransactionⓘNotable traits for Transactionimpl Read for Transactionimpl Write for Transaction
Converts this type into a shared reference of the (usually inferred) input type.
sourceimpl Borrow<Transaction> for CheckedTransaction
impl Borrow<Transaction> for CheckedTransaction
sourcefn borrow(&self) -> &TransactionⓘNotable traits for Transactionimpl Read for Transactionimpl Write for Transaction
fn borrow(&self) -> &TransactionⓘNotable traits for Transactionimpl Read for Transactionimpl Write for Transaction
Immutably borrows from an owned value. Read more
sourceimpl Clone for Transaction
impl Clone for Transaction
sourcefn clone(&self) -> TransactionⓘNotable traits for Transactionimpl Read for Transactionimpl Write for Transaction
fn clone(&self) -> TransactionⓘNotable traits for Transactionimpl Read for Transactionimpl Write for 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
sourceimpl From<&Transaction> for TransactionRepr
impl From<&Transaction> for TransactionRepr
sourcefn from(tx: &Transaction) -> Self
fn from(tx: &Transaction) -> Self
Converts to this type from the input type.
sourceimpl From<CheckedTransaction> for Transaction
impl From<CheckedTransaction> for Transaction
sourcefn from(tx: CheckedTransaction) -> Self
fn from(tx: CheckedTransaction) -> Self
Converts to this type from the input type.
sourceimpl Hash for Transaction
impl Hash for Transaction
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 Read for Transaction
impl Read for Transaction
sourcefn read(&mut self, buf: &mut [u8]) -> Result<usize>
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
Pull some bytes from this source into the specified buffer, returning how many bytes were read. Read more
1.36.0 · sourcefn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
Like read
, except that it reads into a slice of buffers. Read more
sourcefn is_read_vectored(&self) -> bool
fn is_read_vectored(&self) -> bool
can_vector
)Determines if this Read
er has an efficient read_vectored
implementation. Read more
1.0.0 · sourcefn read_to_end(&mut self, buf: &mut Vec<u8, Global>) -> Result<usize, Error>
fn read_to_end(&mut self, buf: &mut Vec<u8, Global>) -> Result<usize, Error>
Read all bytes until EOF in this source, placing them into buf
. Read more
1.0.0 · sourcefn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
Read all bytes until EOF in this source, appending them to buf
. Read more
1.6.0 · sourcefn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
Read the exact number of bytes required to fill buf
. Read more
sourcefn read_buf(&mut self, buf: &mut ReadBuf<'_>) -> Result<(), Error>
fn read_buf(&mut self, buf: &mut ReadBuf<'_>) -> Result<(), Error>
read_buf
)Pull some bytes from this source into the specified buffer. Read more
sourcefn read_buf_exact(&mut self, buf: &mut ReadBuf<'_>) -> Result<(), Error>
fn read_buf_exact(&mut self, buf: &mut ReadBuf<'_>) -> Result<(), Error>
read_buf
)Read the exact number of bytes required to fill buf
. Read more
1.0.0 · sourcefn by_ref(&mut self) -> &mut Self
fn by_ref(&mut self) -> &mut Self
Creates a “by reference” adaptor for this instance of Read
. Read more
sourceimpl SizedBytes for Transaction
impl SizedBytes for Transaction
sourcefn serialized_size(&self) -> usize
fn serialized_size(&self) -> usize
Return the expected serialized size for an instance of the type.
sourceimpl TryFrom<&Transaction> for Contract
impl TryFrom<&Transaction> for Contract
type Error = ValidationError
type Error = ValidationError
The type returned in the event of a conversion error.
sourcefn try_from(tx: &Transaction) -> Result<Self, Self::Error>
fn try_from(tx: &Transaction) -> Result<Self, Self::Error>
Performs the conversion.
sourceimpl Write for Transaction
impl Write for Transaction
sourcefn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
Write a buffer into this writer, returning how many bytes were written. Read more
sourcefn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
Flush this output stream, ensuring that all intermediately buffered contents reach their destination. Read more
sourcefn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector
)Determines if this Write
r has an efficient write_vectored
implementation. Read more
1.0.0 · sourcefn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
Attempts to write an entire buffer into this writer. Read more
sourcefn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
write_all_vectored
)Attempts to write multiple buffers into this writer. Read more
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> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Deserializable for T where
T: Default + Write,
impl<T> Deserializable for T where
T: Default + Write,
sourcefn from_bytes(bytes: &[u8]) -> Result<T, Error>
fn from_bytes(bytes: &[u8]) -> Result<T, Error>
Deserialization from variable length slices of bytes.