Struct grin_core::core::transaction::TransactionBody
source · pub struct TransactionBody {
pub inputs: Inputs,
pub outputs: Vec<Output>,
pub kernels: Vec<TxKernel>,
}
Expand description
TransactionBody is a common abstraction for transaction and block
Fields§
§inputs: Inputs
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).
Implementations§
source§impl TransactionBody
impl TransactionBody
sourcepub fn empty() -> TransactionBody
pub fn empty() -> TransactionBody
Creates a new empty transaction (no inputs or outputs, zero fee).
sourcepub fn init(
inputs: Inputs,
outputs: &[Output],
kernels: &[TxKernel],
verify_sorted: bool
) -> Result<TransactionBody, Error>
pub fn init( inputs: Inputs, outputs: &[Output], kernels: &[TxKernel], verify_sorted: bool ) -> Result<TransactionBody, Error>
Creates a new transaction body initialized with the provided inputs, outputs and kernels. Guarantees inputs, outputs, kernels are sorted lexicographically.
sourcepub fn with_input(self, input: Input) -> TransactionBody
pub fn with_input(self, input: Input) -> TransactionBody
Builds a new body with the provided inputs added. Existing inputs, if any, are kept intact. Sort order is maintained.
sourcepub fn replace_inputs(self, inputs: Inputs) -> TransactionBody
pub fn replace_inputs(self, inputs: Inputs) -> TransactionBody
Fully replace inputs.
sourcepub fn with_output(self, output: Output) -> TransactionBody
pub fn with_output(self, output: Output) -> TransactionBody
Builds a new TransactionBody with the provided output added. Existing outputs, if any, are kept intact. Sort order is maintained.
sourcepub fn replace_outputs(self, outputs: &[Output]) -> TransactionBody
pub fn replace_outputs(self, outputs: &[Output]) -> TransactionBody
Fully replace outputs.
sourcepub fn with_kernel(self, kernel: TxKernel) -> TransactionBody
pub fn with_kernel(self, kernel: TxKernel) -> TransactionBody
Builds a new TransactionBody with the provided kernel added. Existing kernels, if any, are kept intact. Sort order is maintained.
sourcepub fn replace_kernel(self, kernel: TxKernel) -> TransactionBody
pub fn replace_kernel(self, kernel: TxKernel) -> TransactionBody
Builds a new TransactionBody replacing any existing kernels with the provided kernel.
sourcepub fn fee(&self) -> u64
pub fn fee(&self) -> u64
Total fee for a TransactionBody is the sum of fees of all fee carrying kernels.
sourcepub fn fee_shift(&self) -> u8
pub fn fee_shift(&self) -> u8
fee_shift for a TransactionBody is the maximum of fee_shifts of all fee carrying kernels.
sourcepub fn shifted_fee(&self) -> u64
pub fn shifted_fee(&self) -> u64
Shifted fee for a TransactionBody is the sum of fees shifted right by the maximum fee_shift this is used to determine whether a tx can be relayed or accepted in a mempool where transactions can specify a higher block-inclusion priority as a positive shift up to 15 but are required to overpay the minimum required fees by a factor of 2^priority
sourcepub fn aggregate_fee_fields(&self) -> Result<FeeFields, Error>
pub fn aggregate_fee_fields(&self) -> Result<FeeFields, Error>
aggregate fee_fields from all appropriate kernels in TransactionBody into one, if possible
sourcepub fn weight_by_iok(num_inputs: u64, num_outputs: u64, num_kernels: u64) -> u64
pub fn weight_by_iok(num_inputs: u64, num_outputs: u64, num_kernels: u64) -> u64
Calculate transaction weight using block weighing from transaction details. Consensus critical and uses consensus weight values.
sourcepub fn lock_height(&self) -> u64
pub fn lock_height(&self) -> u64
Lock height of a body is the max lock height of the kernels.
sourcepub fn verify_features(&self) -> Result<(), Error>
pub fn verify_features(&self) -> Result<(), Error>
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.
Trait Implementations§
source§impl Clone for TransactionBody
impl Clone for TransactionBody
source§fn clone(&self) -> TransactionBody
fn clone(&self) -> TransactionBody
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Committed for TransactionBody
impl Committed for TransactionBody
source§fn inputs_committed(&self) -> Vec<Commitment>
fn inputs_committed(&self) -> Vec<Commitment>
source§fn outputs_committed(&self) -> Vec<Commitment>
fn outputs_committed(&self) -> Vec<Commitment>
source§fn kernels_committed(&self) -> Vec<Commitment>
fn kernels_committed(&self) -> Vec<Commitment>
source§fn sum_kernel_excesses(
&self,
offset: &BlindingFactor
) -> Result<(Commitment, Commitment), Error>
fn sum_kernel_excesses( &self, offset: &BlindingFactor ) -> Result<(Commitment, Commitment), Error>
source§fn sum_commitments(&self, overage: i64) -> Result<Commitment, Error>
fn sum_commitments(&self, overage: i64) -> Result<Commitment, Error>
source§fn verify_kernel_sums(
&self,
overage: i64,
kernel_offset: BlindingFactor
) -> Result<(Commitment, Commitment), Error>
fn verify_kernel_sums( &self, overage: i64, kernel_offset: BlindingFactor ) -> Result<(Commitment, Commitment), Error>
source§impl Debug for TransactionBody
impl Debug for TransactionBody
source§impl Default for TransactionBody
impl Default for TransactionBody
source§fn default() -> TransactionBody
fn default() -> TransactionBody
source§impl<'de> Deserialize<'de> for TransactionBody
impl<'de> Deserialize<'de> for TransactionBody
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 From<Transaction> for TransactionBody
impl From<Transaction> for TransactionBody
source§fn from(tx: Transaction) -> Self
fn from(tx: Transaction) -> Self
source§impl PartialEq for TransactionBody
impl PartialEq for TransactionBody
source§fn eq(&self, other: &TransactionBody) -> bool
fn eq(&self, other: &TransactionBody) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl Readable for TransactionBody
impl Readable for TransactionBody
Implementation of Readable for a body, defines how to read a body from a binary stream.
source§impl Serialize for TransactionBody
impl Serialize for TransactionBody
source§impl Writeable for TransactionBody
impl Writeable for TransactionBody
Implementation of Writeable for a body, defines how to write the body as binary.