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 or using other
associated constants/methods.
Implementations§
Source§impl InputWeightPrediction
impl InputWeightPrediction
Sourcepub const P2WPKH_MAX: Self = _
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.
Sourcepub const P2PKH_COMPRESSED_MAX: Self = _
pub const P2PKH_COMPRESSED_MAX: Self = _
Input weight prediction corresponding to spending of a P2PKH output with the largest possible DER-encoded signature, and a compressed public key.
If the input in your transaction uses P2PKH with a compressed key, 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_p2pkh_compressed
if you do use
signature grinding.
Sourcepub const P2PKH_UNCOMPRESSED_MAX: Self = _
pub const P2PKH_UNCOMPRESSED_MAX: Self = _
Input weight prediction corresponding to spending of a P2PKH output with the largest possible DER-encoded signature, and an uncompressed public key.
If the input in your transaction uses P2PKH with an uncompressed key, you can use this instead of
InputWeightPrediction::new
.
Sourcepub const P2TR_KEY_DEFAULT_SIGHASH: Self = _
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
.
Sourcepub const P2TR_KEY_NON_DEFAULT_SIGHASH: Self = _
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
.
Sourcepub const fn ground_p2wpkh(bytes_to_grind: usize) -> Self
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.
Sourcepub const fn ground_p2pkh_compressed(bytes_to_grind: usize) -> Self
pub const fn ground_p2pkh_compressed(bytes_to_grind: usize) -> Self
Input weight prediction corresponding to spending of a P2PKH output using signature grinding, and a compressed public key.
If the input in your transaction uses compressed P2PKH and you use signature grinding you
can use this instead of InputWeightPrediction::new
. See
P2PKH_COMPRESSED_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.
Sourcepub fn new<T>(input_script_len: usize, witness_element_lengths: T) -> Self
pub fn new<T>(input_script_len: usize, witness_element_lengths: T) -> Self
Computes the prediction for a single input.
Sourcepub const fn from_slice(
input_script_len: usize,
witness_element_lengths: &[usize],
) -> Self
pub const fn from_slice( input_script_len: usize, witness_element_lengths: &[usize], ) -> Self
Computes the prediction for a single input in const
context.
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
impl Clone for InputWeightPrediction
Source§fn clone(&self) -> InputWeightPrediction
fn clone(&self) -> InputWeightPrediction
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for InputWeightPrediction
impl Debug for InputWeightPrediction
impl Copy for InputWeightPrediction
Auto Trait Implementations§
impl Freeze for InputWeightPrediction
impl RefUnwindSafe for InputWeightPrediction
impl Send for InputWeightPrediction
impl Sync for InputWeightPrediction
impl Unpin for InputWeightPrediction
impl UnwindSafe for InputWeightPrediction
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)