Skip to main content

FinalTransaction

Struct FinalTransaction 

Source
pub struct FinalTransaction { /* private fields */ }
Expand description

A struct representing a final (but not yet signed) transaction.

Implementations§

Source§

impl FinalTransaction

Source

pub fn new() -> FinalTransaction

Creates a new instance of the final transaction with default values.

Source

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)

Source

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.

Source

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.

Source

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.

Source

pub fn remove_input(&mut self, index: usize) -> Option<FinalInput>

Removes an input from the list of inputs at the specified index.

Source

pub fn add_output(&mut self, partial_output: PartialOutput)

Adds a partial output to the list of outputs.

Source

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.

Source

pub fn inputs(&self) -> &[FinalInput]

Provides a slice reference to the collection of FinalInput elements.

Source

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.

Source

pub fn outputs(&self) -> &[PartialOutput]

Returns a reference to the slice of PartialOutput elements contained within the struct.

Source

pub fn outputs_mut(&mut self) -> &mut [PartialOutput]

Provides mutable access to the outputs field of the current struct.

Source

pub fn n_inputs(&self) -> usize

Returns the number of inputs associated with the current instance.

Source

pub fn n_outputs(&self) -> usize

Returns the number of outputs associated with the object.

Source

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.

Source

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.

Source

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.

Source

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

Source§

fn clone(&self) -> FinalTransaction

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<'src, T> IntoMaybe<'src, T> for T
where T: 'src,

Source§

type Proj<U: 'src> = U

Source§

fn map_maybe<R>( self, _f: impl FnOnce(&'src T) -> &'src R, g: impl FnOnce(T) -> R, ) -> <T as IntoMaybe<'src, T>>::Proj<R>
where R: 'src,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<'p, T> Seq<'p, T> for T
where T: Clone,

Source§

type Item<'a> = &'a T where T: 'a

The item yielded by the iterator.
Source§

type Iter<'a> = Once<&'a T> where T: 'a

An iterator over the items within this container, by reference.
Source§

fn seq_iter(&self) -> <T as Seq<'p, T>>::Iter<'_>

Iterate over the elements of the container.
Source§

fn contains(&self, val: &T) -> bool
where T: PartialEq,

Check whether an item is contained within this sequence.
Source§

fn to_maybe_ref<'b>(item: <T as Seq<'p, T>>::Item<'b>) -> Maybe<T, &'p T>
where 'p: 'b,

Convert an item of the sequence into a MaybeRef.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> OrderedSeq<'_, T> for T
where T: Clone,