pub struct ScriptHash(/* private fields */);Expand description
A 160-bit hash of Tidecoin script bytecode.
Implementations§
Source§impl ScriptHash
impl ScriptHash
Sourcepub fn from_script<T>(
redeem_script: &Script<T>,
) -> Result<Self, RedeemScriptSizeError>where
T: ScriptHashableTag,
pub fn from_script<T>(
redeem_script: &Script<T>,
) -> Result<Self, RedeemScriptSizeError>where
T: ScriptHashableTag,
Constructs a new ScriptHash after first checking the script size.
§520-byte limitation on serialized script size
Tidecoin P2SH evaluation hashes the serialized script and then pushes that script onto the stack for execution, so the serialized script is subject to the same rules as any other PUSHDATA operation. No pushed data item may exceed 520 bytes, so a P2SH output cannot be spent if the redemption script it refers to is larger than 520 bytes.
§Errors
Returns an error if the script exceeds 520 bytes.
Sourcepub fn from_script_unchecked<T>(script: &Script<T>) -> Self
pub fn from_script_unchecked<T>(script: &Script<T>) -> Self
Constructs a new ScriptHash from any script irrespective of script size.
If you hash a script that exceeds 520 bytes in size and use it to create a P2SH output then the output will be unspendable.
§impl ScriptHash
impl ScriptHash
pub const fn from_byte_array(bytes: [u8; 20]) -> Self
pub const fn from_byte_array(bytes: [u8; 20]) -> Self
Constructs a new type from the underlying byte array.
pub const fn to_byte_array(self) -> [u8; 20]
pub const fn to_byte_array(self) -> [u8; 20]
Returns the underlying byte array.
pub const fn as_byte_array(&self) -> &[u8; 20]
pub const fn as_byte_array(&self) -> &[u8; 20]
Returns a reference to the underlying byte array.
Trait Implementations§
§impl<'a> Arbitrary<'a> for ScriptHash
Available on crate feature arbitrary only.
impl<'a> Arbitrary<'a> for ScriptHash
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; 20]> for ScriptHash
impl AsRef<[u8; 20]> for ScriptHash
§impl AsRef<[u8]> for ScriptHash
impl AsRef<[u8]> for ScriptHash
§impl Borrow<[u8; 20]> for ScriptHash
impl Borrow<[u8; 20]> for ScriptHash
§impl Borrow<[u8]> for ScriptHash
impl Borrow<[u8]> for ScriptHash
Source§impl Clone for ScriptHash
impl Clone for ScriptHash
Source§fn clone(&self) -> ScriptHash
fn clone(&self) -> ScriptHash
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for ScriptHash
Source§impl Debug for ScriptHash
impl Debug for ScriptHash
§impl<'de> Deserialize<'de> for ScriptHash
impl<'de> Deserialize<'de> for ScriptHash
§fn deserialize<D: Deserializer<'de>>(d: D) -> Result<ScriptHash, D::Error>
fn deserialize<D: Deserializer<'de>>(d: D) -> Result<ScriptHash, D::Error>
§impl Display for ScriptHash
Available on crate feature hex only.
impl Display for ScriptHash
hex only.impl Eq for ScriptHash
§impl FromStr for ScriptHash
Available on crate feature hex only.
impl FromStr for ScriptHash
hex only.Source§impl Hash for ScriptHash
impl Hash for ScriptHash
§impl LowerHex for ScriptHash
Available on crate feature hex only.
impl LowerHex for ScriptHash
hex only.