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: InputsList 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§impl Readable for TransactionBody
Implementation of Readable for a body, defines how to read a
body from a binary stream.
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
Implementation of Writeable for a body, defines how to
write the body as binary.
impl Writeable for TransactionBody
Implementation of Writeable for a body, defines how to write the body as binary.