Struct bitcoin_scripts::WitnessScript
source · pub struct WitnessScript(_);Expand description
A content of the script from witness structure; en equivalent of
redeemScript for witness-based transaction inputs. However, unlike
RedeemScript, WitnessScript produce SHA256-based hashes of
WScriptHash type.
Witness script can be nested within the redeem script in legacy
P2WSH-in-P2SH schemes; for this purpose use RedeemScript::from method.
Implementations§
source§impl WitnessScript
impl WitnessScript
sourcepub fn script_hash(&self) -> WScriptHash
pub fn script_hash(&self) -> WScriptHash
Computes script commitment which participates in Witness or
RedeemScript.
sourcepub fn to_p2wsh(&self) -> PubkeyScript
pub fn to_p2wsh(&self) -> PubkeyScript
Generates PubkeyScript matching given witnessScript for native
SegWit outputs.
sourcepub fn to_p2sh_wsh(&self) -> PubkeyScript
pub fn to_p2sh_wsh(&self) -> PubkeyScript
Generates PubkeyScript matching given witnessScript for legacy
P2WSH-in-P2SH outputs.
Trait Implementations§
source§impl AsMut<<WitnessScript as Wrapper>::Inner> for WitnessScript
impl AsMut<<WitnessScript as Wrapper>::Inner> for WitnessScript
source§impl AsRef<<WitnessScript as Wrapper>::Inner> for WitnessScript
impl AsRef<<WitnessScript as Wrapper>::Inner> for WitnessScript
source§impl Borrow<<WitnessScript as Wrapper>::Inner> for WitnessScript
impl Borrow<<WitnessScript as Wrapper>::Inner> for WitnessScript
source§impl BorrowMut<<WitnessScript as Wrapper>::Inner> for WitnessScript
impl BorrowMut<<WitnessScript as Wrapper>::Inner> for WitnessScript
source§impl Clone for WitnessScript
impl Clone for WitnessScript
source§fn clone(&self) -> WitnessScript
fn clone(&self) -> WitnessScript
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresource§impl Debug for WitnessScript
impl Debug for WitnessScript
source§impl Default for WitnessScript
impl Default for WitnessScript
source§fn default() -> WitnessScript
fn default() -> WitnessScript
Returns the “default value” for a type. Read more
source§impl Deref for WitnessScript
impl Deref for WitnessScript
source§impl DerefMut for WitnessScript
impl DerefMut for WitnessScript
source§impl Display for WitnessScript
impl Display for WitnessScript
source§impl From<LockScript> for WitnessScript
impl From<LockScript> for WitnessScript
source§fn from(lock_script: LockScript) -> Self
fn from(lock_script: LockScript) -> Self
Converts to this type from the input type.
source§impl From<Script> for WitnessScript
impl From<Script> for WitnessScript
source§impl From<WitnessScript> for LockScript
impl From<WitnessScript> for LockScript
source§fn from(witness_script: WitnessScript) -> Self
fn from(witness_script: WitnessScript) -> Self
Converts to this type from the input type.
source§impl From<WitnessScript> for RedeemScript
impl From<WitnessScript> for RedeemScript
source§fn from(witness_script: WitnessScript) -> Self
fn from(witness_script: WitnessScript) -> Self
Converts to this type from the input type.
source§impl From<WitnessScript> for Script
impl From<WitnessScript> for Script
source§fn from(wrapped: WitnessScript) -> Self
fn from(wrapped: WitnessScript) -> Self
Converts to this type from the input type.
source§impl Hash for WitnessScript
impl Hash for WitnessScript
source§impl LowerHex for WitnessScript
impl LowerHex for WitnessScript
source§impl Ord for WitnessScript
impl Ord for WitnessScript
source§fn cmp(&self, other: &WitnessScript) -> Ordering
fn cmp(&self, other: &WitnessScript) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl PartialEq<WitnessScript> for WitnessScript
impl PartialEq<WitnessScript> for WitnessScript
source§fn eq(&self, other: &WitnessScript) -> bool
fn eq(&self, other: &WitnessScript) -> bool
This method tests for
self and other values to be equal, and is used
by ==.source§impl PartialOrd<WitnessScript> for WitnessScript
impl PartialOrd<WitnessScript> for WitnessScript
source§fn partial_cmp(&self, other: &WitnessScript) -> Option<Ordering>
fn partial_cmp(&self, other: &WitnessScript) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self and other) and is used by the <=
operator. Read moresource§impl Strategy for WitnessScript
impl Strategy for WitnessScript
source§impl ToPubkeyScript for WitnessScript
impl ToPubkeyScript for WitnessScript
source§fn to_pubkey_script(&self, strategy: ConvertInfo) -> Option<PubkeyScript>
fn to_pubkey_script(&self, strategy: ConvertInfo) -> Option<PubkeyScript>
Generates scriptPubkey for segwit non-taproot contexts. Fails by
returning None for the following contexts:
ConvertInfo::Baresince nowitnessstructure will be present in the output transaction;ConvertInfo::Hashedsince nowitnessstructure will be present in the output transactionConvertInfo::Taprootsince taproot does not have an associatedWitnessScript.
source§impl UpperHex for WitnessScript
impl UpperHex for WitnessScript
source§impl Wrapper for WitnessScript
impl Wrapper for WitnessScript
source§fn from_inner(inner: Self::Inner) -> Self
fn from_inner(inner: Self::Inner) -> Self
Instantiates wrapper type with the inner data
source§fn as_inner(&self) -> &Self::Inner
fn as_inner(&self) -> &Self::Inner
Returns reference to the inner representation for the wrapper type
source§fn as_inner_mut(&mut self) -> &mut Self::Inner
fn as_inner_mut(&mut self) -> &mut Self::Inner
Returns a mutable reference to the inner representation for the wrapper
type
source§fn into_inner(self) -> Self::Inner
fn into_inner(self) -> Self::Inner
Unwraps the wrapper returning the inner type