pub struct TransactionV1 { /* private fields */ }Expand description
A unit of work sent by a client to the network, which when executed can cause global state to be altered.
Implementations§
Source§impl TransactionV1
impl TransactionV1
Sourcepub fn new(
hash: TransactionV1Hash,
payload: TransactionV1Payload,
approvals: BTreeSet<Approval>,
) -> Self
pub fn new( hash: TransactionV1Hash, payload: TransactionV1Payload, approvals: BTreeSet<Approval>, ) -> Self
ctor
Sourcepub fn sign(&mut self, secret_key: &SecretKey)
pub fn sign(&mut self, secret_key: &SecretKey)
Adds a signature of this transaction’s hash to its approvals.
Sourcepub fn hash(&self) -> &TransactionV1Hash
pub fn hash(&self) -> &TransactionV1Hash
Returns the ApprovalsHash of this transaction’s approvals.
Sourcepub fn payload(&self) -> &TransactionV1Payload
pub fn payload(&self) -> &TransactionV1Payload
Returns the internal payload of this transaction.
Sourcepub fn initiator_addr(&self) -> &InitiatorAddr
pub fn initiator_addr(&self) -> &InitiatorAddr
Returns the address of the initiator of the transaction.
Sourcepub fn chain_name(&self) -> &str
pub fn chain_name(&self) -> &str
Returns the name of the chain the transaction should be executed on.
Sourcepub fn ttl(&self) -> TimeDiff
pub fn ttl(&self) -> TimeDiff
Returns the duration after the creation timestamp for which the transaction will stay valid.
After this duration has ended, the transaction will be considered expired.
Sourcepub fn expired(&self, current_instant: Timestamp) -> bool
pub fn expired(&self, current_instant: Timestamp) -> bool
Returns true if the transaction has expired.
Sourcepub fn pricing_mode(&self) -> &PricingMode
pub fn pricing_mode(&self) -> &PricingMode
Returns the pricing mode for the transaction.
Sourcepub fn compute_approvals_hash(&self) -> Result<ApprovalsHash, Error>
pub fn compute_approvals_hash(&self) -> Result<ApprovalsHash, Error>
Returns the ApprovalsHash of this transaction’s approvals.
pub fn apply_approvals(&mut self, approvals: Vec<Approval>)
std and testing only.Sourcepub fn payment_amount(&self) -> Option<u64>
Available on crate features std and testing only.
pub fn payment_amount(&self) -> Option<u64>
std and testing only.Returns the payment amount if the txn is using payment limited mode.
Sourcepub fn random(rng: &mut TestRng) -> Self
Available on crate features std and testing only.
pub fn random(rng: &mut TestRng) -> Self
std and testing only.Returns a random, valid but possibly expired transaction.
pub fn random_with_lane_and_timestamp_and_ttl( rng: &mut TestRng, lane: u8, maybe_timestamp: Option<Timestamp>, ttl: Option<TimeDiff>, ) -> Self
std and testing only.pub fn random_with_timestamp_and_ttl( rng: &mut TestRng, maybe_timestamp: Option<Timestamp>, ttl: Option<TimeDiff>, ) -> Self
std and testing only.Sourcepub fn random_transfer(
rng: &mut TestRng,
timestamp: Option<Timestamp>,
ttl: Option<TimeDiff>,
) -> Self
Available on crate features std and testing only.
pub fn random_transfer( rng: &mut TestRng, timestamp: Option<Timestamp>, ttl: Option<TimeDiff>, ) -> Self
std and testing only.Returns a random transaction with “transfer” category.
Sourcepub fn random_wasm(
rng: &mut TestRng,
timestamp: Option<Timestamp>,
ttl: Option<TimeDiff>,
) -> Self
Available on crate features std and testing only.
pub fn random_wasm( rng: &mut TestRng, timestamp: Option<Timestamp>, ttl: Option<TimeDiff>, ) -> Self
std and testing only.Returns a random transaction with “standard” category.
Sourcepub fn random_auction(
rng: &mut TestRng,
timestamp: Option<Timestamp>,
ttl: Option<TimeDiff>,
) -> Self
Available on crate features std and testing only.
pub fn random_auction( rng: &mut TestRng, timestamp: Option<Timestamp>, ttl: Option<TimeDiff>, ) -> Self
std and testing only.Returns a random transaction with “install/upgrade” category.
Sourcepub fn random_install_upgrade(
rng: &mut TestRng,
timestamp: Option<Timestamp>,
ttl: Option<TimeDiff>,
) -> Self
Available on crate features std and testing only.
pub fn random_install_upgrade( rng: &mut TestRng, timestamp: Option<Timestamp>, ttl: Option<TimeDiff>, ) -> Self
std and testing only.Returns a random transaction with “install/upgrade” category.
Sourcepub fn deserialize_field<T: FromBytes>(
&self,
index: u16,
) -> Result<T, FieldDeserializationError>
pub fn deserialize_field<T: FromBytes>( &self, index: u16, ) -> Result<T, FieldDeserializationError>
Returns result of attempting to deserailize a field from the amorphic fields container.
Sourcepub fn number_of_fields(&self) -> usize
pub fn number_of_fields(&self) -> usize
Returns number of fields in the amorphic fields container.
Sourcepub fn has_valid_hash(&self) -> Result<(), InvalidTransactionV1>
pub fn has_valid_hash(&self) -> Result<(), InvalidTransactionV1>
Checks if the declared hash of the transaction matches calculated hash.
Sourcepub fn verify(&self) -> Result<(), InvalidTransactionV1>
pub fn verify(&self) -> Result<(), InvalidTransactionV1>
Returns Ok if and only if:
- the transaction hash is correct (see
TransactionV1::has_valid_hashfor details) - approvals are non-empty, and
- all approvals are valid signatures of the signed hash
Sourcepub fn payload_hash(&self) -> Result<Digest, InvalidTransactionV1>
pub fn payload_hash(&self) -> Result<Digest, InvalidTransactionV1>
Returns the hash of the transaction’s payload.
Sourcepub fn invalidate(&mut self)
Available on crate features std and testing only.
pub fn invalidate(&mut self)
std and testing only.Turns self into an invalid TransactionV1 by clearing the chain_name, invalidating the
transaction hash
Sourcepub fn gas_price_tolerance(&self) -> u8
pub fn gas_price_tolerance(&self) -> u8
Returns the gas price tolerance for the given transaction.
Trait Implementations§
Source§impl Clone for TransactionV1
impl Clone for TransactionV1
Source§fn clone(&self) -> TransactionV1
fn clone(&self) -> TransactionV1
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl DataSize for TransactionV1
impl DataSize for TransactionV1
Source§const IS_DYNAMIC: bool = true
const IS_DYNAMIC: bool = true
true, the type has a heap size that can vary at runtime, depending on the actual value.Source§const STATIC_HEAP_SIZE: usize = 0usize
const STATIC_HEAP_SIZE: usize = 0usize
IS_DYNAMIC is false, this is
the total amount of heap memory occupied by the value. Otherwise this is a lower bound.Source§fn estimate_heap_size(&self) -> usize
fn estimate_heap_size(&self) -> usize
Source§impl Debug for TransactionV1
impl Debug for TransactionV1
Source§impl<'de> Deserialize<'de> for TransactionV1
impl<'de> Deserialize<'de> for TransactionV1
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>,
Source§impl Display for TransactionV1
impl Display for TransactionV1
Source§impl From<TransactionV1> for Transaction
impl From<TransactionV1> for Transaction
Source§fn from(txn: TransactionV1) -> Self
fn from(txn: TransactionV1) -> Self
Source§impl FromBytes for TransactionV1
impl FromBytes for TransactionV1
Source§impl Hash for TransactionV1
impl Hash for TransactionV1
Source§impl JsonSchema for TransactionV1
impl JsonSchema for TransactionV1
Source§fn schema_name() -> String
fn schema_name() -> String
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
$ref keyword. Read moreSource§impl Ord for TransactionV1
impl Ord for TransactionV1
Source§fn cmp(&self, other: &TransactionV1) -> Ordering
fn cmp(&self, other: &TransactionV1) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for TransactionV1
impl PartialEq for TransactionV1
Source§impl PartialOrd for TransactionV1
impl PartialOrd for TransactionV1
Source§impl Serialize for TransactionV1
impl Serialize for TransactionV1
Source§impl ToBytes for TransactionV1
impl ToBytes for TransactionV1
Source§fn serialized_length(&self) -> usize
fn serialized_length(&self) -> usize
Vec<u8> which would be returned from a successful call to
to_bytes() or into_bytes(). The data is not actually serialized, so this call is
relatively cheap.impl Eq for TransactionV1
Auto Trait Implementations§
impl !Freeze for TransactionV1
impl RefUnwindSafe for TransactionV1
impl Send for TransactionV1
impl Sync for TransactionV1
impl Unpin for TransactionV1
impl UnwindSafe for TransactionV1
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more