Struct bitcoin::TapNodeHash
source · 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 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 TapNodeHash
impl Debug for TapNodeHash
source§impl<'de> Deserialize<'de> for TapNodeHash
impl<'de> Deserialize<'de> for TapNodeHash
source§fn deserialize<D: Deserializer<'de>>(d: D) -> Result<TapNodeHash, D::Error>
fn deserialize<D: Deserializer<'de>>(d: D) -> Result<TapNodeHash, D::Error>
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§impl Hash for TapNodeHash
impl Hash for TapNodeHash
source§impl Hash for TapNodeHash
impl Hash for TapNodeHash
§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.§type Bytes = <Hash<TapBranchTag> as Hash>::Bytes
type Bytes = <Hash<TapBranchTag> as Hash>::Bytes
The byte array that represents the hash internally.
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§fn from_engine(e: Self::Engine) -> Self
fn from_engine(e: Self::Engine) -> Self
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: Self::Bytes) -> Self
fn from_byte_array(bytes: Self::Bytes) -> Self
Constructs a hash from the underlying byte array.
source§fn to_byte_array(self) -> Self::Bytes
fn to_byte_array(self) -> Self::Bytes
Returns the underlying byte array.
source§fn as_byte_array(&self) -> &Self::Bytes
fn as_byte_array(&self) -> &Self::Bytes
Returns a reference to the underlying byte array.
source§fn hash_byte_chunks<B, I>(byte_slices: I) -> Selfwhere
B: AsRef<[u8]>,
I: IntoIterator<Item = B>,
fn hash_byte_chunks<B, I>(byte_slices: I) -> Selfwhere B: AsRef<[u8]>, I: IntoIterator<Item = B>,
Hashes all the byte slices retrieved from the iterator together.
source§impl<I: SliceIndex<[u8]>> Index<I> for TapNodeHash
impl<I: SliceIndex<[u8]>> Index<I> for TapNodeHash
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<TapNodeHash> for TapNodeHash
impl PartialEq<TapNodeHash> for TapNodeHash
source§fn eq(&self, other: &TapNodeHash) -> bool
fn eq(&self, other: &TapNodeHash) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd<TapNodeHash> for TapNodeHash
impl PartialOrd<TapNodeHash> for TapNodeHash
source§fn partial_cmp(&self, other: &TapNodeHash) -> Option<Ordering>
fn partial_cmp(&self, other: &TapNodeHash) -> 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 SerdeHash for TapNodeHash
impl SerdeHash for TapNodeHash
source§fn from_slice_delegated(sl: &[u8]) -> Result<Self, FromSliceError>
fn from_slice_delegated(sl: &[u8]) -> Result<Self, 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§impl UpperHex for TapNodeHash
impl UpperHex for TapNodeHash
impl Copy for TapNodeHash
impl Eq for TapNodeHash
impl StructuralEq for TapNodeHash
impl StructuralPartialEq for TapNodeHash
Auto Trait Implementations§
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> 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