Remove the `$len` argument from `hash_newtype`

Now that the `$len` argument is no longer used, remove it completely.
This commit is contained in:
Martin Habovstiak 2023-02-22 01:27:09 +01:00
parent 752817e20d
commit b018f3e90b
6 changed files with 23 additions and 23 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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")]

View File

@ -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() {

View File

@ -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);
};
}

View File

@ -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() {