pub struct FinalTransaction { /* private fields */ }Expand description
A struct representing a final (but not yet signed) transaction.
Implementations§
Source§impl FinalTransaction
impl FinalTransaction
Sourcepub fn new() -> FinalTransaction
pub fn new() -> FinalTransaction
Creates a new instance of the final transaction with default values.
Sourcepub fn add_input(
&mut self,
partial_input: PartialInput,
required_sig: RequiredSignature,
)
pub fn add_input( &mut self, partial_input: PartialInput, required_sig: RequiredSignature, )
Adds a new input to the transaction.
§Panics
Panics if the requested signature is not NativeEcdsa or None.
(i.e. if required_sig is RequiredSignature::Witness or RequiredSignature::WitnessWithPath)
Sourcepub fn add_program_input(
&mut self,
partial_input: PartialInput,
program_input: ProgramInput,
required_sig: RequiredSignature,
)
pub fn add_program_input( &mut self, partial_input: PartialInput, program_input: ProgramInput, required_sig: RequiredSignature, )
Adds a new program input to the transaction.
§Panics
The function will panic if the required_sig parameter is of type RequiredSignature::NativeEcdsa,
as this type of signature is not applicable for program inputs.
Sourcepub fn add_issuance_input(
&mut self,
partial_input: PartialInput,
issuance_input: IssuanceInput,
required_sig: RequiredSignature,
) -> IssuanceDetails
pub fn add_issuance_input( &mut self, partial_input: PartialInput, issuance_input: IssuanceInput, required_sig: RequiredSignature, ) -> IssuanceDetails
Adds an issuance (or reissuance) input to the transaction.
§Panics
This function panics if the required_sig is of type Witness or
WitnessWithPath, as these signature types are not allowed in the current context.
Sourcepub fn add_program_issuance_input(
&mut self,
partial_input: PartialInput,
program_input: ProgramInput,
issuance_input: IssuanceInput,
required_sig: RequiredSignature,
) -> IssuanceDetails
pub fn add_program_issuance_input( &mut self, partial_input: PartialInput, program_input: ProgramInput, issuance_input: IssuanceInput, required_sig: RequiredSignature, ) -> IssuanceDetails
Adds an issuance program input to the transaction with the specified parameters.
§Panics
Panics if the required_sig parameter is of type RequiredSignature::NativeEcdsa.
Also panics if the populated input fails to return valid issuance details.
Sourcepub fn remove_input(&mut self, index: usize) -> Option<FinalInput>
pub fn remove_input(&mut self, index: usize) -> Option<FinalInput>
Removes an input from the list of inputs at the specified index.
Sourcepub fn add_output(&mut self, partial_output: PartialOutput)
pub fn add_output(&mut self, partial_output: PartialOutput)
Adds a partial output to the list of outputs.
Sourcepub fn remove_output(&mut self, index: usize) -> Option<PartialOutput>
pub fn remove_output(&mut self, index: usize) -> Option<PartialOutput>
Removes an output from the outputs list at the specified index.
§Panics
This function does not panic. If the index is invalid, it will return None instead of causing a panic.
Sourcepub fn inputs(&self) -> &[FinalInput]
pub fn inputs(&self) -> &[FinalInput]
Provides a slice reference to the collection of FinalInput elements.
Sourcepub fn inputs_mut(&mut self) -> &mut [FinalInput]
pub fn inputs_mut(&mut self) -> &mut [FinalInput]
Provides mutable access to the inputs field.
This method returns a mutable slice of FinalInput elements,
allowing the caller to modify the elements in the inputs field.
Sourcepub fn outputs(&self) -> &[PartialOutput]
pub fn outputs(&self) -> &[PartialOutput]
Returns a reference to the slice of PartialOutput elements contained within the struct.
Sourcepub fn outputs_mut(&mut self) -> &mut [PartialOutput]
pub fn outputs_mut(&mut self) -> &mut [PartialOutput]
Provides mutable access to the outputs field of the current struct.
Sourcepub fn n_inputs(&self) -> usize
pub fn n_inputs(&self) -> usize
Returns the number of inputs associated with the current instance.
Sourcepub fn needs_blinding(&self) -> bool
pub fn needs_blinding(&self) -> bool
Checks if any of the outputs require blinding, determines if at least one of them has a blinding_key specified.
Sourcepub fn calculate_fee_delta(&self, network: &SimplicityNetwork) -> i64
pub fn calculate_fee_delta(&self, network: &SimplicityNetwork) -> i64
Calculates the fee delta for a transaction based on the inputs and outputs.
The fee delta represents the net difference between the available asset amount from the transaction’s inputs and the consumed asset amount by its outputs. The function considers the network’s policy asset to determine which inputs and outputs contribute to the calculation.
§Panics
Function will panic if the asset doesn’t be unblinded correctly, and PST input asset and amount is confidential.
Sourcepub fn calculate_fee(&self, weight: usize, fee_rate: f32) -> u64
pub fn calculate_fee(&self, weight: usize, fee_rate: f32) -> u64
Computes the transaction fee based on the provided weight and fee rate.
Overall, the function calculates the virtual size (vsize) of the transaction as:
weight / WITNESS_SCALE_FACTOR, rounded up to the nearest whole number.
Then, the fee is computed as (vsize * fee_rate / 1000.0), also rounded up.
§Returns
The transaction fee in satoshis, rounded up to the nearest whole number.
Sourcepub fn extract_pst(
&self,
) -> (PartiallySignedTransaction, HashMap<usize, TxOutSecrets>)
pub fn extract_pst( &self, ) -> (PartiallySignedTransaction, HashMap<usize, TxOutSecrets>)
Extracts a partially signed transaction (PST) and a mapping of input secrets from the current state.
§Panics
Function will panic if the pst input is a confidential issuance.
Trait Implementations§
Source§impl Clone for FinalTransaction
impl Clone for FinalTransaction
Source§fn clone(&self) -> FinalTransaction
fn clone(&self) -> FinalTransaction
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for FinalTransaction
impl !RefUnwindSafe for FinalTransaction
impl !Send for FinalTransaction
impl !Sync for FinalTransaction
impl Unpin for FinalTransaction
impl UnsafeUnpin for FinalTransaction
impl !UnwindSafe for FinalTransaction
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more