Struct Transaction

Source
pub struct Transaction {
    pub chain_tag: u8,
    pub block_ref: u64,
    pub expiration: u32,
    pub clauses: Vec<Clause>,
    pub gas_price_coef: u8,
    pub gas: u64,
    pub depends_on: Option<U256>,
    pub nonce: u64,
    pub reserved: Option<Reserved>,
    pub signature: Option<Bytes>,
}
Expand description

Represents a single VeChain transaction.

Fields§

§chain_tag: u8

Chain tag

§block_ref: u64

Previous block reference

First 4 bytes (BE) are block height, the rest is part of referred block ID.

§expiration: u32

Expiration (in blocks)

§clauses: Vec<Clause>

Vector of clauses

§gas_price_coef: u8

Coefficient to calculate the gas price.

§gas: u64

Maximal amount of gas to spend for transaction.

§depends_on: Option<U256>

Hash of transaction on which current transaction depends.

May be left unspecified if this functionality is not necessary.

§nonce: u64

Transaction nonce

§reserved: Option<Reserved>

Reserved fields.

§signature: Option<Bytes>

Signature. 65 bytes for regular transactions, 130 - for VIP-191.

Ignored when making a signing hash.

For VIP-191 transactions, this would be a simple concatenation of two signatures.

Implementations§

Source§

impl Transaction

Source

pub const TRANSACTION_GAS: u64 = 5_000u64

Gas cost for whole transaction execution.

Source

pub fn get_signing_hash(&self) -> [u8; 32]

Get a signing hash for this transaction.

Source

pub fn get_delegate_signing_hash(&self, delegate_for: &Address) -> [u8; 32]

Get a signing hash for this transaction with fee delegation.

VIP-191 <https://github.com/vechain/VIPs/blob/master/vips/VIP-191.md>

Source

pub fn sign(self, private_key: &PrivateKey) -> Self

Create a copy of transaction with a signature emplaced.

You can call .encode() on the result to get bytes ready to be sent over wire.

Source

pub fn with_signature(self, signature: Bytes) -> Result<Self, Error>

Set a signature for this transaction.

Source

pub fn sign_hash(hash: [u8; 32], private_key: &PrivateKey) -> [u8; 65]

Sign a hash obtained from Transaction::get_signing_hash.

Source

pub fn intrinsic_gas(&self) -> u64

Calculate the intrinsic gas amount required for this transaction.

This amount is always less than or equal to actual amount of gas necessary. More info <https://docs.vechain.org/core-concepts/transactions/transaction-calculation>

Source

pub fn origin(&self) -> Result<Option<PublicKey>, Error>

Recover origin public key using the signature.

Returns Ok(None) if signature is unset.

Source

pub fn delegator(&self) -> Result<Option<PublicKey>, Error>

Recover delegator public key using the signature.

Returns Ok(None) if signature is unset or transaction is not delegated.

Source

pub const fn is_delegated(&self) -> bool

Check if transaction is VIP-191 delegated.

Source

pub fn id(&self) -> Result<Option<[u8; 32]>, Error>

Calculate transaction ID using the signature.

Returns Ok(None) if signature is unset.

Source

pub fn has_valid_signature(&self) -> bool

Check wheter the signature is valid.

Source

pub fn to_broadcastable_bytes(&self) -> Result<Bytes, Error>

Create a binary representation.

Returns Err(secp256k1::Error::IncorrectSignature) if signature is not set.

Source

pub fn build(node: ThorNode) -> TransactionBuilder

Create a transaction builder.

Trait Implementations§

Source§

impl Clone for Transaction

Source§

fn clone(&self) -> Transaction

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Transaction

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Decodable for Transaction

Source§

fn decode(buf: &mut &[u8]) -> RLPResult<Self>

Source§

impl<'de> Deserialize<'de> for Transaction

Source§

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 Encodable for Transaction

Source§

fn encode(&self, out: &mut dyn BufMut)

Source§

fn length(&self) -> usize

Source§

impl PartialEq for Transaction

Source§

fn eq(&self, other: &Transaction) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Transaction

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for Transaction

Source§

impl StructuralPartialEq for Transaction

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,