bitcoin_primitives/hash_types/ntxid.rs
1// SPDX-License-Identifier: CC0-1.0
2
3//! The `Txid` type.
4
5#[cfg(feature = "hex")]
6use core::{fmt, str};
7
8#[cfg(feature = "arbitrary")]
9use arbitrary::{Arbitrary, Unstructured};
10use hashes::sha256d;
11
12/// A "normalized TXID".
13///
14/// Computed on a transaction that has had the signatures removed.
15///
16/// This type is needed only for legacy (pre-Segwit or P2SH-wrapped segwit version 0)
17/// applications. This method clears the `script_sig` field of each input, which in Segwit
18/// transactions is already empty, so for Segwit transactions the ntxid will be equal to the
19/// txid, and you should simply use the latter.
20///
21/// This gives a way to identify a transaction that is "the same" as another in the sense of
22/// having the same inputs and outputs.
23#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
24pub struct Ntxid(sha256d::Hash);
25
26super::impl_debug!(Ntxid);
27
28// The new hash wrapper type.
29type HashType = Ntxid;
30// The inner hash type from `hashes`.
31type Inner = sha256d::Hash;
32
33include!("./generic.rs");