pub struct InputWeightPrediction { /* private fields */ }
Expand description

Weight prediction of an individual input.

This helper type collects information about an input to be used in predict_weight function. It can only be created using the new function.

Implementations§

source§

impl InputWeightPrediction

source

pub const P2WPKH_MAX: Self = _

Input weight prediction corresponding to spending of P2WPKH output with the largest possible DER-encoded signature.

If the input in your transaction uses P2WPKH you can use this instead of InputWeightPrediction::new.

This is useful when you do not use signature grinding and want to ensure you are not under-paying. See ground_p2wpkh if you do use signature grinding.

source

pub const P2TR_KEY_DEFAULT_SIGHASH: Self = _

Input weight prediction corresponding to spending of taproot output using the key and default sighash.

If the input in your transaction uses Taproot key spend you can use this instead of InputWeightPrediction::new.

source

pub const P2TR_KEY_NON_DEFAULT_SIGHASH: Self = _

Input weight prediction corresponding to spending of taproot output using the key and non-default sighash.

If the input in your transaction uses Taproot key spend you can use this instead of InputWeightPrediction::new.

source

pub const fn ground_p2wpkh(bytes_to_grind: usize) -> Self

Input weight prediction corresponding to spending of P2WPKH output using signature grinding.

If the input in your transaction uses P2WPKH and you use signature grinding you can use this instead of InputWeightPrediction::new. See P2WPKH_MAX if you don’t use signature grinding.

Note: bytes_to_grind is usually 1 because of exponential cost of higher values.

Panics

The funcion panics in const context and debug builds if bytes_to_grind is higher than 62.

source

pub fn new<T>(input_script_len: usize, witness_element_lengths: T) -> Selfwhere T: IntoIterator, T::Item: Borrow<usize>,

Computes the prediction for a single input.

source

pub const fn from_slice( input_script_len: usize, witness_element_lengths: &[usize] ) -> Self

Computes the prediction for a single input in const context.

Important: only available in Rust 1.46+

This is a const version of new which only allows slices due to current Rust limitations around const fn. Because of these limitations it may be less efficient than new and thus is intended to be only used in const context.

Trait Implementations§

source§

impl Clone for InputWeightPrediction

source§

fn clone(&self) -> InputWeightPrediction

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for InputWeightPrediction

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Copy for InputWeightPrediction

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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> ToOwned for Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.
§

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

§

fn vzip(self) -> V