From ffd2466ad19463ee059afe3a050a4399c62dbefb Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Tue, 22 Aug 2023 09:27:17 +1000 Subject: [PATCH] Move XpubIdentifier to the bip32 module As we have recently been doing, move the declaration of the hash type to where it is used. Move the `XpubIdentifier` hash declaration to the `bip32` module. This is an API breaking change. --- bitcoin/src/bip32.rs | 8 ++++++-- bitcoin/src/hash_types.rs | 4 +--- bitcoin/src/lib.rs | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/bitcoin/src/bip32.rs b/bitcoin/src/bip32.rs index 95958da1..48ee85cb 100644 --- a/bitcoin/src/bip32.rs +++ b/bitcoin/src/bip32.rs @@ -12,7 +12,7 @@ use core::ops::Index; use core::str::FromStr; use core::{fmt, slice}; -use hashes::{sha512, Hash, HashEngine, Hmac, HmacEngine}; +use hashes::{hash160, hash_newtype, sha512, Hash, HashEngine, Hmac, HmacEngine}; use internals::{impl_array_newtype, write_err}; use secp256k1::{self, Secp256k1, XOnlyPublicKey}; #[cfg(feature = "serde")] @@ -20,7 +20,6 @@ use serde; use crate::base58; use crate::crypto::key::{self, KeyPair, PrivateKey, PublicKey}; -use crate::hash_types::XpubIdentifier; use crate::internal_macros::impl_bytes_newtype; use crate::io::Write; use crate::network::Network; @@ -53,6 +52,11 @@ pub struct Fingerprint([u8; 4]); impl_array_newtype!(Fingerprint, u8, 4); impl_bytes_newtype!(Fingerprint, 4); +hash_newtype! { + /// XpubIdentifier as defined in BIP-32. + pub struct XpubIdentifier(hash160::Hash); +} + /// Extended private key #[derive(Copy, Clone, PartialEq, Eq)] #[cfg_attr(feature = "std", derive(Debug))] diff --git a/bitcoin/src/hash_types.rs b/bitcoin/src/hash_types.rs index 54e0d636..ccbc4faa 100644 --- a/bitcoin/src/hash_types.rs +++ b/bitcoin/src/hash_types.rs @@ -52,7 +52,7 @@ pub use newtypes::*; #[rustfmt::skip] mod newtypes { - use hashes::{sha256d, hash160, hash_newtype}; + use hashes::{sha256d, hash_newtype}; hash_newtype! { /// A bitcoin transaction hash/transaction ID. @@ -75,8 +75,6 @@ mod newtypes { pub struct WitnessMerkleNode(sha256d::Hash); /// A hash corresponding to the witness structure commitment in the coinbase transaction pub struct WitnessCommitment(sha256d::Hash); - /// XpubIdentifier as defined in BIP-32. - pub struct XpubIdentifier(hash160::Hash); /// Filter hash, as defined in BIP-157 pub struct FilterHash(sha256d::Hash); diff --git a/bitcoin/src/lib.rs b/bitcoin/src/lib.rs index 8879e257..212d60cb 100644 --- a/bitcoin/src/lib.rs +++ b/bitcoin/src/lib.rs @@ -129,6 +129,7 @@ use core2::io; pub use crate::address::{Address, AddressType}; pub use crate::amount::{Amount, Denomination, SignedAmount}; +pub use crate::bip32::XpubIdentifier; pub use crate::blockdata::block::{self, Block}; pub use crate::blockdata::fee_rate::FeeRate; pub use crate::blockdata::locktime::{self, absolute, relative}; @@ -147,7 +148,6 @@ pub use crate::crypto::key::{ pub use crate::crypto::sighash::{self, LegacySighash, SegwitV0Sighash, TapSighash, TapSighashTag}; pub use crate::hash_types::{ BlockHash, FilterHash, FilterHeader, TxMerkleNode, Txid, WitnessCommitment, Wtxid, - XpubIdentifier, }; pub use crate::merkle_tree::MerkleBlock; pub use crate::network::Network;