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 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 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.

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]) -> Result<Self, RLPError>

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method 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 StructuralEq 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
§

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

§

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

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

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

§

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.

§

impl<T> Instrument for T

§

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

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

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> Same for T

§

type Output = T

Should always be Self
source§

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

§

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>,

§

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>,

§

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.
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

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>,

§

impl<T> JsonSchemaMaybe for T