9
9
//! hash).
10
10
//!
11
11
12
- use bitcoin_hashes:: { sha256, sha256d, hash160, hash_newtype} ;
13
-
14
12
macro_rules! impl_hashencode {
15
13
( $hashtype: ident) => {
16
14
impl $crate:: consensus:: Encodable for $hashtype {
@@ -28,40 +26,47 @@ macro_rules! impl_hashencode {
28
26
}
29
27
}
30
28
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.
33
38
34
39
For compatibility with the existing Bitcoin infrastructure and historical
35
40
and current versions of the Bitcoin Core software itself, this and
36
41
other [`sha256d::Hash`] types, are serialized in reverse
37
42
byte order when converted to a hex string via [`std::fmt::Display`] trait operations.
38
43
See [`hashes::Hash::DISPLAY_BACKWARD`] for more details.
39
44
" ) ;
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" ) ;
43
48
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." ) ;
48
53
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." ) ;
53
58
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" ) ;
56
61
62
+ impl_hashencode ! ( Txid ) ;
63
+ impl_hashencode ! ( Wtxid ) ;
64
+ impl_hashencode ! ( BlockHash ) ;
65
+ impl_hashencode ! ( Sighash ) ;
57
66
58
- impl_hashencode ! ( Txid ) ;
59
- impl_hashencode ! ( Wtxid ) ;
60
- impl_hashencode ! ( BlockHash ) ;
61
- impl_hashencode ! ( Sighash ) ;
67
+ impl_hashencode ! ( TxMerkleNode ) ;
68
+ impl_hashencode ! ( WitnessMerkleNode ) ;
62
69
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