[][src]Struct grin_core::core::transaction::Transaction

pub struct Transaction {
    pub offset: BlindingFactor,
    pub body: TransactionBody,
}

A transaction

Fields

offset: BlindingFactor

The kernel "offset" k2 excess is k1G after splitting the key k = k1 + k2

body: TransactionBody

The transaction body - inputs/outputs/kernels

Methods

impl Transaction[src]

pub fn empty() -> Transaction[src]

Creates a new empty transaction (no inputs or outputs, zero fee).

pub fn new(
    inputs: Vec<Input>,
    outputs: Vec<Output>,
    kernels: Vec<TxKernel>
) -> Transaction
[src]

Creates a new transaction initialized with the provided inputs, outputs, kernels

pub fn with_offset(self, offset: BlindingFactor) -> Transaction[src]

Creates a new transaction using this transaction as a template and with the specified offset.

pub fn with_input(self, input: Input) -> Transaction[src]

Builds a new transaction with the provided inputs added. Existing inputs, if any, are kept intact. Sort order is maintained.

pub fn with_output(self, output: Output) -> Transaction[src]

Builds a new transaction with the provided output added. Existing outputs, if any, are kept intact. Sort order is maintained.

pub fn with_kernel(self, kernel: TxKernel) -> Transaction[src]

Builds a new transaction with the provided output added. Existing outputs, if any, are kept intact. Sort order is maintained.

pub fn inputs(&self) -> &Vec<Input>[src]

Get inputs

pub fn inputs_mut(&mut self) -> &mut Vec<Input>[src]

Get inputs mutable

pub fn outputs(&self) -> &Vec<Output>[src]

Get outputs

pub fn outputs_mut(&mut self) -> &mut Vec<Output>[src]

Get outputs mutable

pub fn kernels(&self) -> &Vec<TxKernel>[src]

Get kernels

pub fn kernels_mut(&mut self) -> &mut Vec<TxKernel>[src]

Get kernels mut

pub fn fee(&self) -> u64[src]

Total fee for a transaction is the sum of fees of all kernels.

pub fn overage(&self) -> i64[src]

Total overage across all kernels.

pub fn lock_height(&self) -> u64[src]

Lock height of a transaction is the max lock height of the kernels.

pub fn validate_read(&self) -> Result<(), Error>[src]

"Lightweight" validation that we can perform quickly during read/deserialization. Subset of full validation that skips expensive verification steps, specifically -

  • rangeproof verification (on the body)
  • kernel signature verification (on the body)
  • kernel sum verification

pub fn validate(
    &self,
    weighting: Weighting,
    verifier: Arc<RwLock<dyn VerifierCache>>
) -> Result<(), Error>
[src]

Validates all relevant parts of a fully built transaction. Checks the excess value against the signature as well as range proofs for each output.

pub fn fee_to_weight(&self) -> u64[src]

Can be used to compare txs by their fee/weight ratio. Don't use these values for anything else though due to precision multiplier.

pub fn tx_weight(&self) -> usize[src]

Calculate transaction weight

pub fn tx_weight_as_block(&self) -> usize[src]

Calculate transaction weight as a block

pub fn weight(input_len: usize, output_len: usize, kernel_len: usize) -> usize[src]

Calculate transaction weight from transaction details

Trait Implementations

impl Committed for Transaction[src]

fn sum_kernel_excesses(
    &self,
    offset: &BlindingFactor
) -> Result<(Commitment, Commitment), Error>
[src]

Gather the kernel excesses and sum them.

fn sum_commitments(&self, overage: i64) -> Result<Commitment, Error>[src]

Gathers commitments and sum them.

fn verify_kernel_sums(
    &self,
    overage: i64,
    kernel_offset: BlindingFactor
) -> Result<(Commitment, Commitment), Error>
[src]

Verify the sum of the kernel excesses equals the sum of the outputs, taking into account both the kernel_offset and overage. Read more

impl DefaultHashable for Transaction[src]

impl Writeable for Transaction[src]

Implementation of Writeable for a fully blinded transaction, defines how to write the transaction as binary.

impl Readable for Transaction[src]

Implementation of Readable for a transaction, defines how to read a full transaction from a binary stream.

impl PartialEq<Transaction> for Transaction[src]

PartialEq

#[must_use] fn ne(&self, other: &Rhs) -> bool1.0.0[src]

This method tests for !=.

impl Default for Transaction[src]

impl Into<TransactionBody> for Transaction[src]

impl Clone for Transaction[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for Transaction[src]

impl Serialize for Transaction[src]

impl<'de> Deserialize<'de> for Transaction[src]

Auto Trait Implementations

Blanket Implementations

impl<D> Hashed for D where
    D: DefaultHashable
[src]

impl<H> ShortIdentifiable for H where
    H: Hashed
[src]

fn short_id(&Self, &Hash, u64) -> ShortId[src]

Generate a short_id via the following -

  • extract k0/k1 from block_hash hashed with the nonce (first two u64 values) * initialize a siphasher24 with k0/k1
    • self.hash() passing in the siphasher24 instance
    • drop the 2 most significant bytes (to return a 6 byte short_id)

impl<T> PMMRIndexHashable for T where
    T: DefaultHashable
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

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

impl<T> DebugAny for T where
    T: Any + Debug

impl<T> CloneAny for T where
    T: Clone + Any

impl<T> UnsafeAny for T where
    T: Any

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> Erased for T