pub struct TapNodeHash(/* private fields */);Expand description
Tagged hash used in taproot trees.
See BIP-340 for tagging rules.
Implementations§
Source§impl TapNodeHash
impl TapNodeHash
Sourcepub fn from_raw_hash(inner: Hash<TapBranchTag>) -> TapNodeHash
pub fn from_raw_hash(inner: Hash<TapBranchTag>) -> TapNodeHash
Creates this wrapper type from the inner hash type.
Sourcepub fn to_raw_hash(self) -> Hash<TapBranchTag>
pub fn to_raw_hash(self) -> Hash<TapBranchTag>
Returns the inner hash (sha256, sh256d etc.).
Sourcepub fn as_raw_hash(&self) -> &Hash<TapBranchTag>
pub fn as_raw_hash(&self) -> &Hash<TapBranchTag>
Returns a reference to the inner hash (sha256, sh256d etc.).
Source§impl TapNodeHash
impl TapNodeHash
Sourcepub fn from_node_hashes(a: TapNodeHash, b: TapNodeHash) -> TapNodeHash
pub fn from_node_hashes(a: TapNodeHash, b: TapNodeHash) -> TapNodeHash
Computes branch hash given two hashes of the nodes underneath it.
Assumes the given 32 byte array as hidden TapNodeHash.
Similar to TapLeafHash::from_byte_array, but explicitly conveys that the
hash is constructed from a hidden node. This also has better ergonomics
because it does not require the caller to import the Hash trait.
Sourcepub fn from_script(script: &Script, ver: LeafVersion) -> TapNodeHash
pub fn from_script(script: &Script, ver: LeafVersion) -> TapNodeHash
Computes the TapNodeHash from a script and a leaf version.
Trait Implementations§
Source§impl AsRef<[u8]> for TapNodeHash
impl AsRef<[u8]> for TapNodeHash
Source§impl Borrow<[u8]> for TapNodeHash
impl Borrow<[u8]> for TapNodeHash
Source§impl Clone for TapNodeHash
impl Clone for TapNodeHash
Source§fn clone(&self) -> TapNodeHash
fn clone(&self) -> TapNodeHash
Returns a duplicate 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 TapNodeHash
impl Debug for TapNodeHash
Source§impl<'de> Deserialize<'de> for TapNodeHash
impl<'de> Deserialize<'de> for TapNodeHash
Source§fn deserialize<D>(d: D) -> Result<TapNodeHash, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(d: D) -> Result<TapNodeHash, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for TapNodeHash
impl Display for TapNodeHash
Source§impl From<&LeafNode> for TapNodeHash
impl From<&LeafNode> for TapNodeHash
Source§fn from(leaf: &LeafNode) -> TapNodeHash
fn from(leaf: &LeafNode) -> TapNodeHash
Converts to this type from the input type.
Source§impl From<Hash<TapBranchTag>> for TapNodeHash
impl From<Hash<TapBranchTag>> for TapNodeHash
Source§fn from(inner: Hash<TapBranchTag>) -> TapNodeHash
fn from(inner: Hash<TapBranchTag>) -> TapNodeHash
Converts to this type from the input type.
Source§impl From<LeafNode> for TapNodeHash
impl From<LeafNode> for TapNodeHash
Source§fn from(leaf: LeafNode) -> TapNodeHash
fn from(leaf: LeafNode) -> TapNodeHash
Converts to this type from the input type.
Source§impl From<TapLeafHash> for TapNodeHash
impl From<TapLeafHash> for TapNodeHash
Source§fn from(leaf: TapLeafHash) -> TapNodeHash
fn from(leaf: TapLeafHash) -> TapNodeHash
Converts to this type from the input type.
Source§impl From<TapNodeHash> for Hash<TapBranchTag>
impl From<TapNodeHash> for Hash<TapBranchTag>
Source§fn from(hashtype: TapNodeHash) -> Hash<TapBranchTag>
fn from(hashtype: TapNodeHash) -> Hash<TapBranchTag>
Converts to this type from the input type.
Source§impl FromStr for TapNodeHash
impl FromStr for TapNodeHash
Source§type Err = HexToArrayError
type Err = HexToArrayError
The associated error which can be returned from parsing.
Source§fn from_str(s: &str) -> Result<TapNodeHash, <TapNodeHash as FromStr>::Err>
fn from_str(s: &str) -> Result<TapNodeHash, <TapNodeHash as FromStr>::Err>
Parses a string
s to return a value of this type. Read moreSource§impl Hash for TapNodeHash
impl Hash for TapNodeHash
Source§impl Hash for TapNodeHash
impl Hash for TapNodeHash
Source§const DISPLAY_BACKWARD: bool = false
const DISPLAY_BACKWARD: bool = false
Flag indicating whether user-visible serializations of this hash
should be backward. For some reason Satoshi decided this should be
true for
Sha256dHash, so here we are.Source§type Engine = <Hash<TapBranchTag> as Hash>::Engine
type Engine = <Hash<TapBranchTag> as Hash>::Engine
A hashing engine which bytes can be serialized into. It is expected
to implement the
io::Write trait, and to never return errors under
any conditions.Source§type Bytes = <Hash<TapBranchTag> as Hash>::Bytes
type Bytes = <Hash<TapBranchTag> as Hash>::Bytes
The byte array that represents the hash internally.
Source§fn from_engine(e: <TapNodeHash as Hash>::Engine) -> TapNodeHash
fn from_engine(e: <TapNodeHash as Hash>::Engine) -> TapNodeHash
Produces a hash from the current state of a given engine.
Source§fn from_slice(sl: &[u8]) -> Result<TapNodeHash, FromSliceError>
fn from_slice(sl: &[u8]) -> Result<TapNodeHash, FromSliceError>
Copies a byte slice into a hash object.
Source§fn from_byte_array(bytes: <TapNodeHash as Hash>::Bytes) -> TapNodeHash
fn from_byte_array(bytes: <TapNodeHash as Hash>::Bytes) -> TapNodeHash
Constructs a hash from the underlying byte array.
Source§fn to_byte_array(self) -> <TapNodeHash as Hash>::Bytes
fn to_byte_array(self) -> <TapNodeHash as Hash>::Bytes
Returns the underlying byte array.
Source§fn as_byte_array(&self) -> &<TapNodeHash as Hash>::Bytes
fn as_byte_array(&self) -> &<TapNodeHash as Hash>::Bytes
Returns a reference to the underlying byte array.
Source§fn all_zeros() -> TapNodeHash
fn all_zeros() -> TapNodeHash
Returns an all zero hash. Read more
Source§fn hash_byte_chunks<B, I>(byte_slices: I) -> Self
fn hash_byte_chunks<B, I>(byte_slices: I) -> Self
Hashes all the byte slices retrieved from the iterator together.
Source§impl<I> Index<I> for TapNodeHashwhere
I: SliceIndex<[u8]>,
impl<I> Index<I> for TapNodeHashwhere
I: SliceIndex<[u8]>,
Source§impl LowerHex for TapNodeHash
impl LowerHex for TapNodeHash
Source§impl Ord for TapNodeHash
impl Ord for TapNodeHash
Source§fn cmp(&self, other: &TapNodeHash) -> Ordering
fn cmp(&self, other: &TapNodeHash) -> 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 for TapNodeHash
impl PartialEq for TapNodeHash
Source§impl PartialOrd for TapNodeHash
impl PartialOrd for TapNodeHash
Source§impl SerdeHash for TapNodeHash
impl SerdeHash for TapNodeHash
Source§fn from_slice_delegated(sl: &[u8]) -> Result<TapNodeHash, FromSliceError>
fn from_slice_delegated(sl: &[u8]) -> Result<TapNodeHash, FromSliceError>
Helper function to turn a deserialized slice into the correct hash type.
Source§fn serialize<S>(
&self,
s: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
s: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Do serde serialization.
Source§fn deserialize<'de, D>(d: D) -> Result<Self, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<'de, D>(d: D) -> Result<Self, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Do serde deserialization.
Source§impl Serialize for TapNodeHash
impl Serialize for TapNodeHash
Source§fn serialize<S>(
&self,
s: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
s: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
Source§impl StrictDecode for TapNodeHash
impl StrictDecode for TapNodeHash
fn strict_decode( reader: &mut impl TypedRead, ) -> Result<TapNodeHash, DecodeError>
fn strict_read(reader: impl ReadRaw) -> Result<Self, DecodeError>
Source§impl StrictDeserialize for TapNodeHash
impl StrictDeserialize for TapNodeHash
fn from_strict_serialized<const MAX: usize>( ast_data: Confined<Vec<u8>, 0, MAX>, ) -> Result<Self, DeserializeError>
fn strict_deserialize_from_file<const MAX: usize>( path: impl AsRef<Path>, ) -> Result<Self, DeserializeError>
Source§impl StrictDumb for TapNodeHash
impl StrictDumb for TapNodeHash
fn strict_dumb() -> TapNodeHash
Source§impl StrictEncode for TapNodeHash
impl StrictEncode for TapNodeHash
fn strict_encode<W>(&self, writer: W) -> Result<W, Error>where
W: TypedWrite,
fn strict_write(&self, writer: impl WriteRaw) -> Result<(), Error>
Source§impl StrictSerialize for TapNodeHash
impl StrictSerialize for TapNodeHash
fn strict_serialized_len<const MAX: usize>(&self) -> Result<usize, Error>
fn to_strict_serialized<const MAX: usize>( &self, ) -> Result<Confined<Vec<u8>, 0, MAX>, SerializeError>
fn strict_serialize_to_file<const MAX: usize>( &self, path: impl AsRef<Path>, ) -> Result<(), SerializeError>
Source§impl StrictTuple for TapNodeHash
impl StrictTuple for TapNodeHash
const FIELD_COUNT: u8 = 1u8
fn strict_check_fields()
fn strict_type_info() -> TypeInfo<Self>
Source§impl StrictType for TapNodeHash
impl StrictType for TapNodeHash
const STRICT_LIB_NAME: &'static str = LIB_NAME_BITCOIN
fn strict_name() -> Option<TypeName>
Source§impl UpperHex for TapNodeHash
impl UpperHex for TapNodeHash
impl Copy for TapNodeHash
impl Eq for TapNodeHash
impl StrictProduct for TapNodeHash
impl StructuralPartialEq for TapNodeHash
Auto Trait Implementations§
impl Freeze for TapNodeHash
impl RefUnwindSafe for TapNodeHash
impl Send for TapNodeHash
impl Sync for TapNodeHash
impl Unpin for TapNodeHash
impl UnwindSafe for TapNodeHash
Blanket Implementations§
Source§impl<T> Base32Len for T
impl<T> Base32Len for T
Source§fn base32_len(&self) -> usize
fn base32_len(&self) -> usize
Calculate the base32 serialized length
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
Mutably borrows from an owned value. Read more
Source§impl<T> CheckBase32<Vec<u5>> for T
impl<T> CheckBase32<Vec<u5>> for T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> ToBase32 for T
impl<T> ToBase32 for T
Source§fn write_base32<W>(&self, writer: &mut W) -> Result<(), <W as WriteBase32>::Err>where
W: WriteBase32,
fn write_base32<W>(&self, writer: &mut W) -> Result<(), <W as WriteBase32>::Err>where
W: WriteBase32,
Encode as base32 and write it to the supplied writer
Implementations shouldn’t allocate.
Source§impl<T> ToHex for T
impl<T> ToHex for T
Source§fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
Encode the hex strict representing
self into the result. Lower case
letters are used (e.g. f9b4ca)Source§fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
Encode the hex strict representing
self into the result. Upper case
letters are used (e.g. F9B4CA)