pub struct WScriptHash(/* private fields */);Expand description
SegWit (256-bit) version of a Bitcoin Script bytecode hash.
Note: there is another “script hash” object in bitcoin ecosystem (Electrum protocol) that looks similar to this one also being SHA256, however, they hash semantically different scripts and have reversed representations, so this type cannot be used for both.
Implementations§
Source§impl WScriptHash
impl WScriptHash
Sourcepub fn from_script(
witness_script: &WitnessScript,
) -> Result<Self, WitnessScriptSizeError>
pub fn from_script( witness_script: &WitnessScript, ) -> Result<Self, WitnessScriptSizeError>
Constructs a new WScriptHash after first checking the script size.
§10,000-byte limit on the witness script
The witnessScript (≤ 10,000 bytes) is popped off the initial witness stack. SHA256 of the witnessScript must match the 32-byte witness program.
ref: BIP-0141
§Errors
Returns an error if the script exceeds 10,000 bytes.
Sourcepub fn from_script_unchecked(script: &WitnessScript) -> Self
pub fn from_script_unchecked(script: &WitnessScript) -> Self
Constructs a new WScriptHash from any script irrespective of script size.
If you hash a script that exceeds 10,000 bytes in size and use it to create a Segwit output then the output will be unspendable (see [BIP-0141]).
ref: BIP-0141
§impl WScriptHash
impl WScriptHash
pub const fn from_byte_array(bytes: [u8; 32]) -> Self
pub const fn from_byte_array(bytes: [u8; 32]) -> Self
Constructs a new type from the underlying byte array.
pub const fn to_byte_array(self) -> [u8; 32]
pub const fn to_byte_array(self) -> [u8; 32]
Returns the underlying byte array.
pub const fn as_byte_array(&self) -> &[u8; 32]
pub const fn as_byte_array(&self) -> &[u8; 32]
Returns a reference to the underlying byte array.
Trait Implementations§
§impl<'a> Arbitrary<'a> for WScriptHash
Available on crate feature arbitrary only.
impl<'a> Arbitrary<'a> for WScriptHash
arbitrary only.§fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>
fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>
Self from the given unstructured data. Read moreSource§fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
Self from the entirety of the given
unstructured data. Read moreSource§fn size_hint(depth: usize) -> (usize, Option<usize>)
fn size_hint(depth: usize) -> (usize, Option<usize>)
Unstructured this type
needs to construct itself. Read moreSource§fn try_size_hint(
depth: usize,
) -> Result<(usize, Option<usize>), MaxRecursionReached>
fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>
Unstructured this type
needs to construct itself. Read more§impl AsRef<[u8]> for WScriptHash
impl AsRef<[u8]> for WScriptHash
§impl AsRef<[u8; 32]> for WScriptHash
impl AsRef<[u8; 32]> for WScriptHash
§impl Borrow<[u8]> for WScriptHash
impl Borrow<[u8]> for WScriptHash
§impl Borrow<[u8; 32]> for WScriptHash
impl Borrow<[u8; 32]> for WScriptHash
Source§impl Clone for WScriptHash
impl Clone for WScriptHash
Source§fn clone(&self) -> WScriptHash
fn clone(&self) -> WScriptHash
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for WScriptHash
impl Debug for WScriptHash
§impl<'de> Deserialize<'de> for WScriptHash
impl<'de> Deserialize<'de> for WScriptHash
§fn deserialize<D: Deserializer<'de>>(d: D) -> Result<WScriptHash, D::Error>
fn deserialize<D: Deserializer<'de>>(d: D) -> Result<WScriptHash, D::Error>
§impl Display for WScriptHash
Available on crate feature hex only.
impl Display for WScriptHash
hex only.§impl FromStr for WScriptHash
Available on crate feature hex only.
impl FromStr for WScriptHash
hex only.Source§impl Hash for WScriptHash
impl Hash for WScriptHash
§impl LowerHex for WScriptHash
Available on crate feature hex only.
impl LowerHex for WScriptHash
hex only.Source§impl Ord for WScriptHash
impl Ord for WScriptHash
Source§fn cmp(&self, other: &WScriptHash) -> Ordering
fn cmp(&self, other: &WScriptHash) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for WScriptHash
impl PartialEq for WScriptHash
Source§impl PartialOrd for WScriptHash
impl PartialOrd for WScriptHash
§impl Serialize for WScriptHash
impl Serialize for WScriptHash
Source§impl TryFrom<&Script<WitnessScriptTag>> for WScriptHash
impl TryFrom<&Script<WitnessScriptTag>> for WScriptHash
Source§type Error = WitnessScriptSizeError
type Error = WitnessScriptSizeError
Source§impl TryFrom<&ScriptBuf<WitnessScriptTag>> for WScriptHash
impl TryFrom<&ScriptBuf<WitnessScriptTag>> for WScriptHash
Source§type Error = WitnessScriptSizeError
type Error = WitnessScriptSizeError
Source§impl TryFrom<ScriptBuf<WitnessScriptTag>> for WScriptHash
impl TryFrom<ScriptBuf<WitnessScriptTag>> for WScriptHash
Source§type Error = WitnessScriptSizeError
type Error = WitnessScriptSizeError
§impl UpperHex for WScriptHash
Available on crate feature hex only.
impl UpperHex for WScriptHash
hex only.