diff --git a/bitcoin/src/address/mod.rs b/bitcoin/src/address/mod.rs index 7e634c595..89fb1ee1c 100644 --- a/bitcoin/src/address/mod.rs +++ b/bitcoin/src/address/mod.rs @@ -39,7 +39,6 @@ use hashes::{hash160, HashEngine}; use secp256k1::{Secp256k1, Verification, XOnlyPublicKey}; use crate::address::script_pubkey::ScriptBufExt as _; -use crate::consensus::Params; use crate::constants::{ PUBKEY_ADDRESS_PREFIX_MAIN, PUBKEY_ADDRESS_PREFIX_TEST, SCRIPT_ADDRESS_PREFIX_MAIN, SCRIPT_ADDRESS_PREFIX_TEST, @@ -47,7 +46,7 @@ use crate::constants::{ use crate::crypto::key::{ CompressedPublicKey, PubkeyHash, PublicKey, TweakedPublicKey, UntweakedPublicKey, }; -use crate::network::{Network, NetworkKind}; +use crate::network::{Network, NetworkKind, Params}; use crate::prelude::{String, ToOwned}; use crate::script::witness_program::WitnessProgram; use crate::script::witness_version::WitnessVersion; @@ -892,7 +891,7 @@ mod tests { use hex_lit::hex; use super::*; - use crate::consensus::params; + use crate::network::params; use crate::network::Network::{Bitcoin, Testnet}; fn roundtrips(addr: &Address, network: Network) { diff --git a/bitcoin/src/blockdata/block.rs b/bitcoin/src/blockdata/block.rs index 4c24fe259..109473bd0 100644 --- a/bitcoin/src/blockdata/block.rs +++ b/bitcoin/src/blockdata/block.rs @@ -13,9 +13,10 @@ use hashes::{sha256d, HashEngine}; use io::{BufRead, Write}; use super::Weight; -use crate::consensus::{encode, Decodable, Encodable, Params}; +use crate::consensus::{encode, Decodable, Encodable}; use crate::internal_macros::{impl_consensus_encoding, impl_hashencode}; use crate::merkle_tree::{MerkleNode as _, TxMerkleNode, WitnessMerkleNode}; +use crate::network::Params; use crate::pow::{CompactTarget, Target, Work}; use crate::prelude::Vec; use crate::transaction::{Transaction, Wtxid}; diff --git a/bitcoin/src/blockdata/constants.rs b/bitcoin/src/blockdata/constants.rs index 409e3f1fb..d54937097 100644 --- a/bitcoin/src/blockdata/constants.rs +++ b/bitcoin/src/blockdata/constants.rs @@ -10,10 +10,9 @@ use hashes::sha256d; use internals::impl_array_newtype; use crate::block::{self, Block}; -use crate::consensus::Params; use crate::internal_macros::impl_array_newtype_stringify; use crate::locktime::absolute; -use crate::network::Network; +use crate::network::{Network, Params}; use crate::opcodes::all::*; use crate::pow::CompactTarget; use crate::transaction::{self, OutPoint, Transaction, TxIn, TxOut}; @@ -216,7 +215,7 @@ mod test { use super::*; use crate::consensus::encode::serialize; - use crate::consensus::params; + use crate::network::params; use crate::Txid; #[test] diff --git a/bitcoin/src/blockdata/transaction.rs b/bitcoin/src/blockdata/transaction.rs index b9af14983..3002776ce 100644 --- a/bitcoin/src/blockdata/transaction.rs +++ b/bitcoin/src/blockdata/transaction.rs @@ -113,9 +113,8 @@ impl OutPoint { /// # Examples /// /// ```rust - /// use bitcoin::consensus::params; /// use bitcoin::constants::genesis_block; - /// use bitcoin::Network; + /// use bitcoin::{params, Network}; /// /// let block = genesis_block(¶ms::MAINNET); /// let tx = &block.txdata[0]; diff --git a/bitcoin/src/consensus/mod.rs b/bitcoin/src/consensus/mod.rs index daef74f9b..8c9d9083b 100644 --- a/bitcoin/src/consensus/mod.rs +++ b/bitcoin/src/consensus/mod.rs @@ -6,7 +6,6 @@ //! conform to Bitcoin consensus. pub mod encode; -pub mod params; #[cfg(feature = "serde")] pub mod serde; #[cfg(feature = "bitcoinconsensus")] @@ -23,7 +22,6 @@ use crate::consensus; #[doc(inline)] pub use self::{ encode::{deserialize, deserialize_partial, serialize, Decodable, Encodable, ReadExt, WriteExt}, - params::Params, }; #[cfg(feature = "bitcoinconsensus")] diff --git a/bitcoin/src/lib.rs b/bitcoin/src/lib.rs index fa45b34b7..d909b8cc8 100644 --- a/bitcoin/src/lib.rs +++ b/bitcoin/src/lib.rs @@ -123,12 +123,12 @@ pub use crate::{ blockdata::weight::Weight, blockdata::witness::{self, Witness}, consensus::encode::VarInt, - consensus::params, crypto::ecdsa, crypto::key::{self, PrivateKey, PubkeyHash, PublicKey, CompressedPublicKey, WPubkeyHash, XOnlyPublicKey}, crypto::sighash::{self, LegacySighash, SegwitV0Sighash, TapSighash, TapSighashTag}, merkle_tree::{MerkleBlock, TxMerkleNode, WitnessMerkleNode}, network::{Network, NetworkKind}, + network::params::{self, Params}, pow::{CompactTarget, Target, Work}, psbt::Psbt, sighash::{EcdsaSighashType, TapSighashType}, diff --git a/bitcoin/src/network.rs b/bitcoin/src/network/mod.rs similarity index 99% rename from bitcoin/src/network.rs rename to bitcoin/src/network/mod.rs index 9ecce282e..ea244fbf5 100644 --- a/bitcoin/src/network.rs +++ b/bitcoin/src/network/mod.rs @@ -18,6 +18,8 @@ //! assert_eq!(&bytes[..], &[0xF9, 0xBE, 0xB4, 0xD9]); //! ``` +pub mod params; + use core::fmt; use core::str::FromStr; @@ -25,11 +27,14 @@ use internals::write_err; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; -use crate::consensus::Params; use crate::constants::ChainHash; use crate::p2p::Magic; use crate::prelude::{String, ToOwned}; +#[rustfmt::skip] // Keep public re-exports separate. +#[doc(inline)] +pub use self::params::Params; + /// What kind of network we are on. #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] pub enum NetworkKind { diff --git a/bitcoin/src/consensus/params.rs b/bitcoin/src/network/params.rs similarity index 99% rename from bitcoin/src/consensus/params.rs rename to bitcoin/src/network/params.rs index 203e95de4..9d9cc5f56 100644 --- a/bitcoin/src/consensus/params.rs +++ b/bitcoin/src/network/params.rs @@ -11,7 +11,7 @@ //! custom type that can be used is such places you might want to do the following: //! //! ``` -//! use bitcoin::consensus::Params; +//! use bitcoin::network::Params; //! use bitcoin::{p2p, Script, ScriptBuf, Network, Target}; //! //! const POW_TARGET_SPACING: u64 = 120; // Two minutes. diff --git a/bitcoin/src/p2p/mod.rs b/bitcoin/src/p2p/mod.rs index 8507af733..aa58fa577 100644 --- a/bitcoin/src/p2p/mod.rs +++ b/bitcoin/src/p2p/mod.rs @@ -28,9 +28,8 @@ use internals::{debug_from_display, write_err}; use io::{BufRead, Write}; use crate::consensus::encode::{self, Decodable, Encodable}; -use crate::consensus::Params; +use crate::network::{Network, Params}; use crate::prelude::{Borrow, BorrowMut, String, ToOwned}; -use crate::Network; #[rustfmt::skip] #[doc(inline)] diff --git a/bitcoin/src/pow.rs b/bitcoin/src/pow.rs index b8c66a058..deb2b8289 100644 --- a/bitcoin/src/pow.rs +++ b/bitcoin/src/pow.rs @@ -15,7 +15,7 @@ use units::parse::{self, ParseIntError, PrefixedHexError, UnprefixedHexError}; use crate::block::{BlockHash, Header}; use crate::consensus::encode::{self, Decodable, Encodable}; -use crate::consensus::Params; +use crate::network::Params; /// Implement traits and methods shared by `Target` and `Work`. macro_rules! do_impl {