Skip to main content

bitcoin_primitives/hash_types/
wtxid.rs

1// SPDX-License-Identifier: CC0-1.0
2
3//! The `Txid` type.
4//!
5//! In order to print and parse txids enable the "hex" feature.
6
7#[cfg(feature = "hex")]
8use core::{fmt, str};
9
10#[cfg(feature = "arbitrary")]
11use arbitrary::{Arbitrary, Unstructured};
12use hashes::sha256d;
13
14/// A bitcoin witness transaction ID.
15#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
16pub struct Wtxid(sha256d::Hash);
17
18super::impl_debug!(Wtxid);
19
20impl Wtxid {
21    /// The `Wtxid` of a coinbase transaction.
22    ///
23    /// This is used as the wTXID for the coinbase transaction when constructing blocks (in the
24    /// witness commitment tree) since the coinbase transaction contains a commitment to all
25    /// transactions' wTXIDs but naturally cannot commit to its own.
26    pub const COINBASE: Self = Self::from_byte_array([0; 32]);
27}
28
29// The new hash wrapper type.
30type HashType = Wtxid;
31// The inner hash type from `hashes`.
32type Inner = sha256d::Hash;
33
34include!("./generic.rs");