Struct bdk_chain::bitcoin::TapNodeHash
pub struct TapNodeHash(/* private fields */);
Expand description
Tagged hash used in taproot trees.
See BIP-340 for tagging rules.
Implementations§
§impl TapNodeHash
impl TapNodeHash
pub 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.
pub fn to_raw_hash(self) -> Hash<TapBranchTag>
pub fn to_raw_hash(self) -> Hash<TapBranchTag>
Returns the inner hash (sha256, sh256d etc.).
pub 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.).
§impl TapNodeHash
impl TapNodeHash
pub 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.
pub 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§
§impl AsRef<[u8]> for TapNodeHash
impl AsRef<[u8]> for TapNodeHash
§impl AsRef<[u8; 32]> for TapNodeHash
impl AsRef<[u8; 32]> for TapNodeHash
§impl Borrow<[u8]> for TapNodeHash
impl Borrow<[u8]> for TapNodeHash
§impl Clone for TapNodeHash
impl Clone for TapNodeHash
§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 more§impl Debug for TapNodeHash
impl Debug for TapNodeHash
§impl<'de> Deserialize<'de> for TapNodeHash
impl<'de> Deserialize<'de> for TapNodeHash
§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
§impl Display for TapNodeHash
impl Display for TapNodeHash
§impl From<&LeafNode> for TapNodeHash
impl From<&LeafNode> for TapNodeHash
§fn from(leaf: &LeafNode) -> TapNodeHash
fn from(leaf: &LeafNode) -> TapNodeHash
Converts to this type from the input type.
§impl From<Hash<TapBranchTag>> for TapNodeHash
impl From<Hash<TapBranchTag>> for TapNodeHash
§fn from(inner: Hash<TapBranchTag>) -> TapNodeHash
fn from(inner: Hash<TapBranchTag>) -> TapNodeHash
Converts to this type from the input type.
§impl From<LeafNode> for TapNodeHash
impl From<LeafNode> for TapNodeHash
§fn from(leaf: LeafNode) -> TapNodeHash
fn from(leaf: LeafNode) -> TapNodeHash
Converts to this type from the input type.
§impl From<TapLeafHash> for TapNodeHash
impl From<TapLeafHash> for TapNodeHash
§fn from(leaf: TapLeafHash) -> TapNodeHash
fn from(leaf: TapLeafHash) -> TapNodeHash
Converts to this type from the input type.
§impl From<TapNodeHash> for Hash<TapBranchTag>
impl From<TapNodeHash> for Hash<TapBranchTag>
§fn from(hashtype: TapNodeHash) -> Hash<TapBranchTag>
fn from(hashtype: TapNodeHash) -> Hash<TapBranchTag>
Converts to this type from the input type.
§impl FromStr for TapNodeHash
impl FromStr for TapNodeHash
§type Err = HexToArrayError
type Err = HexToArrayError
The associated error which can be returned from parsing.
§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 more§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.
§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.§fn engine() -> <TapNodeHash as Hash>::Engine
fn engine() -> <TapNodeHash as Hash>::Engine
Constructs a new engine.
§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.
§fn from_slice(sl: &[u8]) -> Result<TapNodeHash, FromSliceError>
fn from_slice(sl: &[u8]) -> Result<TapNodeHash, FromSliceError>
Copies a byte slice into a hash object.
§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.
§fn to_byte_array(self) -> <TapNodeHash as Hash>::Bytes
fn to_byte_array(self) -> <TapNodeHash as Hash>::Bytes
Returns the underlying byte array.
§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.
§fn all_zeros() -> TapNodeHash
fn all_zeros() -> TapNodeHash
Returns an all zero hash. Read more
§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.
§impl Hash for TapNodeHash
impl Hash for TapNodeHash
§impl<I> Index<I> for TapNodeHashwhere
I: SliceIndex<[u8]>,
impl<I> Index<I> for TapNodeHashwhere
I: SliceIndex<[u8]>,
§impl LowerHex for TapNodeHash
impl LowerHex for TapNodeHash
§impl Ord for TapNodeHash
impl Ord for TapNodeHash
§impl PartialEq for TapNodeHash
impl PartialEq for TapNodeHash
§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 ==
.§impl PartialOrd for TapNodeHash
impl PartialOrd for TapNodeHash
§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 more§impl SerdeHash for TapNodeHash
impl SerdeHash for TapNodeHash
§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.
§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.
§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.
§impl Serialize for TapNodeHash
impl Serialize for TapNodeHash
§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
§impl UpperHex for TapNodeHash
impl UpperHex for TapNodeHash
impl Copy for TapNodeHash
impl Eq 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> 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
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more