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

pub struct TransactionBody {
    pub inputs: Vec<Input>,
    pub outputs: Vec<Output>,
    pub kernels: Vec<TxKernel>,
}

TransactionBody is a common abstraction for transaction and block

Fields

inputs: Vec<Input>

List of inputs spent by the transaction.

outputs: Vec<Output>

List of outputs the transaction produces.

kernels: Vec<TxKernel>

List of kernels that make up this transaction (usually a single kernel).

Methods

impl TransactionBody[src]

pub fn empty() -> TransactionBody[src]

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

pub fn sort(&mut self)[src]

Sort the inputs|outputs|kernels.

pub fn init(
    inputs: Vec<Input>,
    outputs: Vec<Output>,
    kernels: Vec<TxKernel>,
    verify_sorted: bool
) -> Result<TransactionBody, Error>
[src]

Creates a new transaction body initialized with the provided inputs, outputs and kernels. Guarantees inputs, outputs, kernels are sorted lexicographically.

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

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

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

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

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

Builds a new TransactionBody with the provided kernel added. Existing kernels, if any, are kept intact. Sort order is maintained.

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

Calculate transaction weight

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

Calculate weight of transaction using block weighing

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

Calculate transaction weight from transaction details. This is non consensus critical and compared to block weight, incentivizes spending more outputs (to lower the fee).

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

Calculate transaction weight using block weighing from transaction details. Consensus critical and uses consensus weight values.

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

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

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

Verify we have no invalid outputs or kernels in the transaction due to invalid features. Specifically, a transaction cannot contain a coinbase output or a coinbase kernel.

pub fn validate_read(&self, weighting: Weighting) -> 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
  • kernel signature verification

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

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

Trait Implementations

impl Committed for TransactionBody[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 Writeable for TransactionBody[src]

Implementation of Writeable for a body, defines how to write the body as binary.

impl Readable for TransactionBody[src]

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

impl PartialEq<TransactionBody> for TransactionBody[src]

PartialEq

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

This method tests for !=.

impl Default for TransactionBody[src]

impl Into<TransactionBody> for Transaction[src]

impl Clone for TransactionBody[src]

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

Performs copy-assignment from source. Read more

impl Debug for TransactionBody[src]

impl Serialize for TransactionBody[src]

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

Auto Trait Implementations

Blanket Implementations

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