diff --git a/bitcoin/src/crypto/sighash.rs b/bitcoin/src/crypto/sighash.rs index 4b85e1b1..16806d56 100644 --- a/bitcoin/src/crypto/sighash.rs +++ b/bitcoin/src/crypto/sighash.rs @@ -48,12 +48,12 @@ macro_rules! impl_thirty_two_byte_hash { } #[rustfmt::skip] -hash_newtype!(LegacySighash, sha256d::Hash, 32, +hash_newtype!(LegacySighash, sha256d::Hash, doc="Hash of a transaction according to the legacy signature algorithm", false); impl_thirty_two_byte_hash!(LegacySighash); #[rustfmt::skip] -hash_newtype!(SegwitV0Sighash, sha256d::Hash, 32, +hash_newtype!(SegwitV0Sighash, sha256d::Hash, doc="Hash of a transaction according to the segwit version 0 signature algorithm", false); impl_thirty_two_byte_hash!(SegwitV0Sighash); diff --git a/bitcoin/src/hash_types.rs b/bitcoin/src/hash_types.rs index 31b7cb84..04a4478f 100644 --- a/bitcoin/src/hash_types.rs +++ b/bitcoin/src/hash_types.rs @@ -56,7 +56,7 @@ mod newtypes { use crate::hashes::{sha256, sha256d, hash160, hash_newtype}; hash_newtype!( - Txid, sha256d::Hash, 32, doc="A bitcoin transaction hash/transaction ID. + Txid, sha256d::Hash, doc="A bitcoin transaction hash/transaction ID. For compatibility with the existing Bitcoin infrastructure and historical and current versions of the Bitcoin Core software itself, this and @@ -64,21 +64,21 @@ other [`sha256d::Hash`] types, are serialized in reverse byte order when converted to a hex string via [`std::fmt::Display`] trait operations. See [`hashes::Hash::DISPLAY_BACKWARD`] for more details. "); - hash_newtype!(Wtxid, sha256d::Hash, 32, doc="A bitcoin witness transaction ID."); - hash_newtype!(BlockHash, sha256d::Hash, 32, doc="A bitcoin block hash."); + hash_newtype!(Wtxid, sha256d::Hash, doc="A bitcoin witness transaction ID."); + hash_newtype!(BlockHash, sha256d::Hash, doc="A bitcoin block hash."); - hash_newtype!(PubkeyHash, hash160::Hash, 20, doc="A hash of a public key."); - hash_newtype!(ScriptHash, hash160::Hash, 20, doc="A hash of Bitcoin Script bytecode."); - hash_newtype!(WPubkeyHash, hash160::Hash, 20, doc="SegWit version of a public key hash."); - hash_newtype!(WScriptHash, sha256::Hash, 32, doc="SegWit version of a Bitcoin Script bytecode hash."); + hash_newtype!(PubkeyHash, hash160::Hash, doc="A hash of a public key."); + hash_newtype!(ScriptHash, hash160::Hash, doc="A hash of Bitcoin Script bytecode."); + hash_newtype!(WPubkeyHash, hash160::Hash, doc="SegWit version of a public key hash."); + hash_newtype!(WScriptHash, sha256::Hash, doc="SegWit version of a Bitcoin Script bytecode hash."); - hash_newtype!(TxMerkleNode, sha256d::Hash, 32, doc="A hash of the Merkle tree branch or root for transactions"); - hash_newtype!(WitnessMerkleNode, sha256d::Hash, 32, doc="A hash corresponding to the Merkle tree root for witness data"); - hash_newtype!(WitnessCommitment, sha256d::Hash, 32, doc="A hash corresponding to the witness structure commitment in the coinbase transaction"); - hash_newtype!(XpubIdentifier, hash160::Hash, 20, doc="XpubIdentifier as defined in BIP-32."); + hash_newtype!(TxMerkleNode, sha256d::Hash, doc="A hash of the Merkle tree branch or root for transactions"); + hash_newtype!(WitnessMerkleNode, sha256d::Hash, doc="A hash corresponding to the Merkle tree root for witness data"); + hash_newtype!(WitnessCommitment, sha256d::Hash, doc="A hash corresponding to the witness structure commitment in the coinbase transaction"); + hash_newtype!(XpubIdentifier, hash160::Hash, doc="XpubIdentifier as defined in BIP-32."); - hash_newtype!(FilterHash, sha256d::Hash, 32, doc="Filter hash, as defined in BIP-157"); - hash_newtype!(FilterHeader, sha256d::Hash, 32, doc="Filter header, as defined in BIP-157"); + hash_newtype!(FilterHash, sha256d::Hash, doc="Filter hash, as defined in BIP-157"); + hash_newtype!(FilterHeader, sha256d::Hash, doc="Filter header, as defined in BIP-157"); impl_hashencode!(Txid); impl_hashencode!(Wtxid); diff --git a/hashes/embedded/src/main.rs b/hashes/embedded/src/main.rs index 22773ad2..ed36fc52 100644 --- a/hashes/embedded/src/main.rs +++ b/hashes/embedded/src/main.rs @@ -18,7 +18,7 @@ use cortex_m_rt::entry; use cortex_m_semihosting::{debug, hprintln}; use panic_halt as _; -hash_newtype!(TestType, sha256::Hash, 32, doc = "test"); +hash_newtype!(TestType, sha256::Hash, doc = "test"); // this is the allocator the application will use #[cfg(feature = "alloc")] diff --git a/hashes/src/lib.rs b/hashes/src/lib.rs index 66b3a75d..315bb4c0 100644 --- a/hashes/src/lib.rs +++ b/hashes/src/lib.rs @@ -220,8 +220,8 @@ pub trait Hash: Copy + Clone + PartialEq + Eq + PartialOrd + Ord + mod tests { use crate::{Hash, sha256d}; - hash_newtype!(TestNewtype, sha256d::Hash, 32, doc="A test newtype"); - hash_newtype!(TestNewtype2, sha256d::Hash, 32, doc="A test newtype"); + hash_newtype!(TestNewtype, sha256d::Hash, doc="A test newtype"); + hash_newtype!(TestNewtype2, sha256d::Hash, doc="A test newtype"); #[test] fn convert_newtypes() { diff --git a/hashes/src/sha256t.rs b/hashes/src/sha256t.rs index e52e0ae0..ec0991ff 100644 --- a/hashes/src/sha256t.rs +++ b/hashes/src/sha256t.rs @@ -115,7 +115,7 @@ macro_rules! sha256t_hash_newtype { } } - $crate::hash_newtype!($newtype, $crate::sha256t::Hash<$tag>, 32, $docs, $reverse); + $crate::hash_newtype!($newtype, $crate::sha256t::Hash<$tag>, $docs, $reverse); }; } diff --git a/hashes/src/util.rs b/hashes/src/util.rs index d9354d1a..f992c7ab 100644 --- a/hashes/src/util.rs +++ b/hashes/src/util.rs @@ -112,10 +112,10 @@ macro_rules! engine_input_impl( /// Creates a new newtype around a [`Hash`] type. #[macro_export] macro_rules! hash_newtype { - ($newtype:ident, $hash:ty, $len:expr, $docs:meta) => { - $crate::hash_newtype!($newtype, $hash, $len, $docs, <$hash as $crate::Hash>::DISPLAY_BACKWARD); + ($newtype:ident, $hash:ty, $docs:meta) => { + $crate::hash_newtype!($newtype, $hash, $docs, <$hash as $crate::Hash>::DISPLAY_BACKWARD); }; - ($newtype:ident, $hash:ty, $len:expr, $docs:meta, $reverse:expr) => { + ($newtype:ident, $hash:ty, $docs:meta, $reverse:expr) => { #[$docs] #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] #[repr(transparent)] @@ -276,7 +276,7 @@ mod test { assert_eq!(borrowed, hash.as_inner()); } - hash_newtype!(TestHash, crate::sha256d::Hash, 32, doc="Test hash."); + hash_newtype!(TestHash, crate::sha256d::Hash, doc="Test hash."); #[test] fn display() {