99//! hash).
1010//!
1111
12- use bitcoin_hashes:: { sha256, sha256d, hash160, hash_newtype} ;
13-
1412macro_rules! impl_hashencode {
1513 ( $hashtype: ident) => {
1614 impl $crate:: consensus:: Encodable for $hashtype {
@@ -28,40 +26,47 @@ macro_rules! impl_hashencode {
2826 }
2927}
3028
31- hash_newtype ! (
32- Txid , sha256d:: Hash , 32 , doc="A bitcoin transaction hash/transaction ID.
29+ // newtypes module is solely here so we can rustfmt::skip.
30+ pub use newtypes:: * ;
31+
32+ #[ rustfmt:: skip]
33+ mod newtypes {
34+ use crate :: hashes:: { sha256, sha256d, hash160, hash_newtype} ;
35+
36+ hash_newtype ! (
37+ Txid , sha256d:: Hash , 32 , doc="A bitcoin transaction hash/transaction ID.
3338
3439For compatibility with the existing Bitcoin infrastructure and historical
3540and current versions of the Bitcoin Core software itself, this and
3641other [`sha256d::Hash`] types, are serialized in reverse
3742byte order when converted to a hex string via [`std::fmt::Display`] trait operations.
3843See [`hashes::Hash::DISPLAY_BACKWARD`] for more details.
3944" ) ;
40- hash_newtype ! ( Wtxid , sha256d:: Hash , 32 , doc="A bitcoin witness transaction ID." ) ;
41- hash_newtype ! ( BlockHash , sha256d:: Hash , 32 , doc="A bitcoin block hash." ) ;
42- hash_newtype ! ( Sighash , sha256d:: Hash , 32 , doc="Hash of the transaction according to the signature algorithm" ) ;
45+ hash_newtype ! ( Wtxid , sha256d:: Hash , 32 , doc="A bitcoin witness transaction ID." ) ;
46+ hash_newtype ! ( BlockHash , sha256d:: Hash , 32 , doc="A bitcoin block hash." ) ;
47+ hash_newtype ! ( Sighash , sha256d:: Hash , 32 , doc="Hash of the transaction according to the signature algorithm" ) ;
4348
44- hash_newtype ! ( PubkeyHash , hash160:: Hash , 20 , doc="A hash of a public key." ) ;
45- hash_newtype ! ( ScriptHash , hash160:: Hash , 20 , doc="A hash of Bitcoin Script bytecode." ) ;
46- hash_newtype ! ( WPubkeyHash , hash160:: Hash , 20 , doc="SegWit version of a public key hash." ) ;
47- hash_newtype ! ( WScriptHash , sha256:: Hash , 32 , doc="SegWit version of a Bitcoin Script bytecode hash." ) ;
49+ hash_newtype ! ( PubkeyHash , hash160:: Hash , 20 , doc="A hash of a public key." ) ;
50+ hash_newtype ! ( ScriptHash , hash160:: Hash , 20 , doc="A hash of Bitcoin Script bytecode." ) ;
51+ hash_newtype ! ( WPubkeyHash , hash160:: Hash , 20 , doc="SegWit version of a public key hash." ) ;
52+ hash_newtype ! ( WScriptHash , sha256:: Hash , 32 , doc="SegWit version of a Bitcoin Script bytecode hash." ) ;
4853
49- hash_newtype ! ( TxMerkleNode , sha256d:: Hash , 32 , doc="A hash of the Merkle tree branch or root for transactions" ) ;
50- hash_newtype ! ( WitnessMerkleNode , sha256d:: Hash , 32 , doc="A hash corresponding to the Merkle tree root for witness data" ) ;
51- hash_newtype ! ( WitnessCommitment , sha256d:: Hash , 32 , doc="A hash corresponding to the witness structure commitment in the coinbase transaction" ) ;
52- hash_newtype ! ( XpubIdentifier , hash160:: Hash , 20 , doc="XpubIdentifier as defined in BIP-32." ) ;
54+ hash_newtype ! ( TxMerkleNode , sha256d:: Hash , 32 , doc="A hash of the Merkle tree branch or root for transactions" ) ;
55+ hash_newtype ! ( WitnessMerkleNode , sha256d:: Hash , 32 , doc="A hash corresponding to the Merkle tree root for witness data" ) ;
56+ hash_newtype ! ( WitnessCommitment , sha256d:: Hash , 32 , doc="A hash corresponding to the witness structure commitment in the coinbase transaction" ) ;
57+ hash_newtype ! ( XpubIdentifier , hash160:: Hash , 20 , doc="XpubIdentifier as defined in BIP-32." ) ;
5358
54- hash_newtype ! ( FilterHash , sha256d:: Hash , 32 , doc="Filter hash, as defined in BIP-157" ) ;
55- hash_newtype ! ( FilterHeader , sha256d:: Hash , 32 , doc="Filter header, as defined in BIP-157" ) ;
59+ hash_newtype ! ( FilterHash , sha256d:: Hash , 32 , doc="Filter hash, as defined in BIP-157" ) ;
60+ hash_newtype ! ( FilterHeader , sha256d:: Hash , 32 , doc="Filter header, as defined in BIP-157" ) ;
5661
62+ impl_hashencode ! ( Txid ) ;
63+ impl_hashencode ! ( Wtxid ) ;
64+ impl_hashencode ! ( BlockHash ) ;
65+ impl_hashencode ! ( Sighash ) ;
5766
58- impl_hashencode ! ( Txid ) ;
59- impl_hashencode ! ( Wtxid ) ;
60- impl_hashencode ! ( BlockHash ) ;
61- impl_hashencode ! ( Sighash ) ;
67+ impl_hashencode ! ( TxMerkleNode ) ;
68+ impl_hashencode ! ( WitnessMerkleNode ) ;
6269
63- impl_hashencode ! ( TxMerkleNode ) ;
64- impl_hashencode ! ( WitnessMerkleNode ) ;
65-
66- impl_hashencode ! ( FilterHash ) ;
67- impl_hashencode ! ( FilterHeader ) ;
70+ impl_hashencode ! ( FilterHash ) ;
71+ impl_hashencode ! ( FilterHeader ) ;
72+ }
0 commit comments