Struct bdk_chain::bitcoin::blockdata::transaction::InputWeightPrediction
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§
§impl InputWeightPrediction
impl InputWeightPrediction
pub const P2WPKH_MAX: InputWeightPrediction = _
pub const P2WPKH_MAX: InputWeightPrediction = _
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.
pub const P2PKH_COMPRESSED_MAX: InputWeightPrediction = _
pub const P2PKH_COMPRESSED_MAX: InputWeightPrediction = _
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.
pub const P2PKH_UNCOMPRESSED_MAX: InputWeightPrediction = _
pub const P2PKH_UNCOMPRESSED_MAX: InputWeightPrediction = _
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
.
pub const P2TR_KEY_DEFAULT_SIGHASH: InputWeightPrediction = _
pub const P2TR_KEY_DEFAULT_SIGHASH: InputWeightPrediction = _
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
.
pub const P2TR_KEY_NON_DEFAULT_SIGHASH: InputWeightPrediction = _
pub const P2TR_KEY_NON_DEFAULT_SIGHASH: InputWeightPrediction = _
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
.
pub const fn ground_p2wpkh(bytes_to_grind: usize) -> InputWeightPrediction
pub const fn ground_p2wpkh(bytes_to_grind: usize) -> InputWeightPrediction
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.
pub const fn ground_p2pkh_compressed(
bytes_to_grind: usize
) -> InputWeightPrediction
pub const fn ground_p2pkh_compressed( bytes_to_grind: usize ) -> InputWeightPrediction
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.
pub fn new<T>(
input_script_len: usize,
witness_element_lengths: T
) -> InputWeightPrediction
pub fn new<T>( input_script_len: usize, witness_element_lengths: T ) -> InputWeightPrediction
Computes the prediction for a single input.
pub const fn from_slice(
input_script_len: usize,
witness_element_lengths: &[usize]
) -> InputWeightPrediction
pub const fn from_slice( input_script_len: usize, witness_element_lengths: &[usize] ) -> InputWeightPrediction
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§
§impl Clone for InputWeightPrediction
impl Clone for InputWeightPrediction
§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 more