diff --git a/bitcoin/Cargo.toml b/bitcoin/Cargo.toml index e429b9d0..c58792e1 100644 --- a/bitcoin/Cargo.toml +++ b/bitcoin/Cargo.toml @@ -16,7 +16,7 @@ exclude = ["tests", "contrib"] default = [ "std", "secp-recovery" ] rand-std = ["secp256k1/rand-std"] rand = ["secp256k1/rand"] -serde = ["actual-serde", "bitcoin_hashes/serde", "secp256k1/serde"] +serde = ["actual-serde", "hashes/serde", "secp256k1/serde"] secp-lowmemory = ["secp256k1/lowmemory"] secp-recovery = ["secp256k1/recovery"] bitcoinconsensus-std = ["bitcoinconsensus/std", "std"] @@ -26,17 +26,17 @@ bitcoinconsensus-std = ["bitcoinconsensus/std", "std"] # The no-std feature doesn't disable std - you need to turn off the std feature for that by disabling default. # Instead no-std enables additional features required for this crate to be usable without std. # As a result, both can be enabled without conflict. -std = ["secp256k1/std", "bitcoin_hashes/std", "bech32/std", "bitcoin-internals/std"] -no-std = ["core2", "bitcoin_hashes/alloc", "bitcoin_hashes/core2", "secp256k1/alloc"] +std = ["secp256k1/std", "hashes/std", "bech32/std", "internals/std"] +no-std = ["core2", "hashes/alloc", "hashes/core2", "secp256k1/alloc"] [package.metadata.docs.rs] all-features = true rustdoc-args = ["--cfg", "docsrs"] [dependencies] -bitcoin-internals = { path = "../internals", package = "bitcoin-private", version = "0.1.0" } +internals = { package = "bitcoin-private", version = "0.1.0", path = "../internals" } bech32 = { version = "0.9.0", default-features = false } -bitcoin_hashes = { version = "0.12.0", default-features = false } +hashes = { package = "bitcoin_hashes", version = "0.12.0", default-features = false } secp256k1 = { version = "0.27.0", default-features = false, features = ["bitcoin_hashes"] } hex_lit = "0.1.1" diff --git a/bitcoin/src/address.rs b/bitcoin/src/address.rs index d75ba11a..533a83ef 100644 --- a/bitcoin/src/address.rs +++ b/bitcoin/src/address.rs @@ -33,8 +33,8 @@ use core::marker::PhantomData; use core::str::FromStr; use bech32; -use bitcoin_internals::write_err; use hashes::{sha256, Hash, HashEngine}; +use internals::write_err; use secp256k1::{Secp256k1, Verification, XOnlyPublicKey}; use crate::base58; diff --git a/bitcoin/src/bip152.rs b/bitcoin/src/bip152.rs index 66625fe8..05e6a2bc 100644 --- a/bitcoin/src/bip152.rs +++ b/bitcoin/src/bip152.rs @@ -10,8 +10,8 @@ use core::{convert, fmt, mem}; #[cfg(feature = "std")] use std::error; -use bitcoin_internals::impl_array_newtype; use hashes::{sha256, siphash24, Hash}; +use internals::impl_array_newtype; use crate::consensus::encode::{self, Decodable, Encodable, VarInt}; use crate::internal_macros::{impl_bytes_newtype, impl_consensus_encoding}; diff --git a/bitcoin/src/bip158.rs b/bitcoin/src/bip158.rs index 9bc22c25..b7009fe8 100644 --- a/bitcoin/src/bip158.rs +++ b/bitcoin/src/bip158.rs @@ -43,8 +43,8 @@ use core::cmp::{self, Ordering}; use core::convert::TryInto; use core::fmt::{self, Display, Formatter}; -use bitcoin_internals::write_err; use hashes::{siphash24, Hash}; +use internals::write_err; use crate::blockdata::block::Block; use crate::blockdata::script::Script; diff --git a/bitcoin/src/bip32.rs b/bitcoin/src/bip32.rs index b3d6d70d..f30f0d03 100644 --- a/bitcoin/src/bip32.rs +++ b/bitcoin/src/bip32.rs @@ -13,8 +13,8 @@ use core::fmt; use core::ops::Index; use core::str::FromStr; -use bitcoin_internals::{impl_array_newtype, write_err}; use hashes::{hex, sha512, Hash, HashEngine, Hmac, HmacEngine}; +use internals::{impl_array_newtype, write_err}; use secp256k1::{self, Secp256k1, XOnlyPublicKey}; #[cfg(feature = "serde")] use serde; diff --git a/bitcoin/src/blockdata/constants.rs b/bitcoin/src/blockdata/constants.rs index 7a737d38..b88eeb12 100644 --- a/bitcoin/src/blockdata/constants.rs +++ b/bitcoin/src/blockdata/constants.rs @@ -10,9 +10,9 @@ use core::default::Default; -use bitcoin_internals::impl_array_newtype; use hashes::{sha256d, Hash}; use hex_lit::hex; +use internals::impl_array_newtype; use crate::blockdata::block::{self, Block}; use crate::blockdata::locktime::absolute; diff --git a/bitcoin/src/blockdata/locktime/absolute.rs b/bitcoin/src/blockdata/locktime/absolute.rs index c6869c10..a755d065 100644 --- a/bitcoin/src/blockdata/locktime/absolute.rs +++ b/bitcoin/src/blockdata/locktime/absolute.rs @@ -10,7 +10,7 @@ use core::cmp::{Ordering, PartialOrd}; use core::{fmt, mem}; -use bitcoin_internals::write_err; +use internals::write_err; #[cfg(all(test, mutate))] use mutagen::mutate; diff --git a/bitcoin/src/blockdata/opcodes.rs b/bitcoin/src/blockdata/opcodes.rs index d976283f..296e8a65 100644 --- a/bitcoin/src/blockdata/opcodes.rs +++ b/bitcoin/src/blockdata/opcodes.rs @@ -12,7 +12,7 @@ use core::convert::From; use core::fmt; -use bitcoin_internals::debug_from_display; +use internals::debug_from_display; #[cfg(feature = "serde")] use serde; diff --git a/bitcoin/src/blockdata/script/builder.rs b/bitcoin/src/blockdata/script/builder.rs index eaa672a8..56f4fef0 100644 --- a/bitcoin/src/blockdata/script/builder.rs +++ b/bitcoin/src/blockdata/script/builder.rs @@ -148,4 +148,4 @@ impl fmt::Display for Builder { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { self.0.fmt_asm(f) } } -bitcoin_internals::debug_from_display!(Builder); +internals::debug_from_display!(Builder); diff --git a/bitcoin/src/blockdata/script/mod.rs b/bitcoin/src/blockdata/script/mod.rs index 52bc3b81..596f8918 100644 --- a/bitcoin/src/blockdata/script/mod.rs +++ b/bitcoin/src/blockdata/script/mod.rs @@ -729,7 +729,7 @@ mod bitcoinconsensus_hack { impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { #[cfg(feature = "bitcoinconsensus")] - use bitcoin_internals::write_err; + use internals::write_err; match *self { Error::NonMinimalPush => f.write_str("non-minimal datapush"), diff --git a/bitcoin/src/blockdata/transaction.rs b/bitcoin/src/blockdata/transaction.rs index 31d79b65..c87c5698 100644 --- a/bitcoin/src/blockdata/transaction.rs +++ b/bitcoin/src/blockdata/transaction.rs @@ -16,8 +16,8 @@ use core::convert::TryFrom; use core::default::Default; use core::{cmp, fmt, str}; -use bitcoin_internals::write_err; use hashes::{self, sha256d, Hash}; +use internals::write_err; use super::Weight; use crate::blockdata::constants::WITNESS_SCALE_FACTOR; @@ -548,9 +548,9 @@ impl EncodeSigningDataResult { /// /// ```rust /// # use bitcoin::consensus::deserialize; + /// # use bitcoin::hashes::{Hash, hex::FromHex}; /// # use bitcoin::sighash::{LegacySighash, SighashCache}; /// # use bitcoin::Transaction; - /// # use bitcoin_hashes::{Hash, hex::FromHex}; /// # let mut writer = LegacySighash::engine(); /// # let input_index = 0; /// # let script_pubkey = bitcoin::ScriptBuf::new(); diff --git a/bitcoin/src/consensus/encode.rs b/bitcoin/src/consensus/encode.rs index 982bb9fe..c89ff27c 100644 --- a/bitcoin/src/consensus/encode.rs +++ b/bitcoin/src/consensus/encode.rs @@ -19,8 +19,8 @@ use core::convert::From; use core::{fmt, mem, u32}; -use bitcoin_internals::write_err; use hashes::{sha256, sha256d, Hash}; +use internals::write_err; use crate::bip152::{PrefilledTransaction, ShortId}; use crate::blockdata::transaction::{Transaction, TxIn, TxOut}; diff --git a/bitcoin/src/consensus/serde.rs b/bitcoin/src/consensus/serde.rs index fe18aea5..01f3de07 100644 --- a/bitcoin/src/consensus/serde.rs +++ b/bitcoin/src/consensus/serde.rs @@ -36,7 +36,6 @@ pub mod hex { use core::fmt; use core::marker::PhantomData; - use bitcoin_internals as internals; use internals::hex::BufEncoder; /// Marker for upper/lower case type-level flags ("type-level enum"). @@ -51,8 +50,6 @@ pub mod hex { pub enum Upper {} mod sealed { - use bitcoin_internals as internals; - pub trait Case { /// Internal detail, don't depend on it!!! const INTERNAL_CASE: internals::hex::Case; @@ -103,18 +100,18 @@ pub mod hex { /// Error returned when a hex string decoder can't be created. #[derive(Debug)] - pub struct DecodeInitError(bitcoin_hashes::hex::Error); + pub struct DecodeInitError(hashes::hex::Error); /// Error returned when a hex string contains invalid characters. #[derive(Debug)] - pub struct DecodeError(bitcoin_hashes::hex::Error); + pub struct DecodeError(hashes::hex::Error); /// Hex decoder state. - pub struct Decoder<'a>(bitcoin_hashes::hex::HexIterator<'a>); + pub struct Decoder<'a>(hashes::hex::HexIterator<'a>); impl<'a> Decoder<'a> { fn new(s: &'a str) -> Result { - match bitcoin_hashes::hex::HexIterator::new(s) { + match hashes::hex::HexIterator::new(s) { Ok(iter) => Ok(Decoder(iter)), Err(error) => Err(DecodeInitError(error)), } @@ -139,7 +136,7 @@ pub mod hex { impl super::IntoDeError for DecodeInitError { fn into_de_error(self) -> E { - use bitcoin_hashes::hex::Error; + use hashes::hex::Error; match self.0 { Error::OddLengthString(len) => @@ -151,7 +148,7 @@ pub mod hex { impl super::IntoDeError for DecodeError { fn into_de_error(self) -> E { - use bitcoin_hashes::hex::Error; + use hashes::hex::Error; use serde::de::Unexpected; const EXPECTED_CHAR: &str = "an ASCII-encoded hex digit"; diff --git a/bitcoin/src/crypto/ecdsa.rs b/bitcoin/src/crypto/ecdsa.rs index cdc17c15..68743ee3 100644 --- a/bitcoin/src/crypto/ecdsa.rs +++ b/bitcoin/src/crypto/ecdsa.rs @@ -8,9 +8,9 @@ use core::str::FromStr; use core::{fmt, iter}; -use bitcoin_internals::hex::display::DisplayHex; -use bitcoin_internals::write_err; use hashes::hex::{self, FromHex}; +use internals::hex::display::DisplayHex; +use internals::write_err; use secp256k1; use crate::prelude::*; diff --git a/bitcoin/src/crypto/key.rs b/bitcoin/src/crypto/key.rs index 07405b30..14f23e1b 100644 --- a/bitcoin/src/crypto/key.rs +++ b/bitcoin/src/crypto/key.rs @@ -10,9 +10,9 @@ use core::fmt::{self, Write}; use core::ops; use core::str::FromStr; -use bitcoin_internals::write_err; use hashes::hex::FromHex; use hashes::{hash160, hex, Hash}; +use internals::write_err; pub use secp256k1::{self, constants, KeyPair, Parity, Secp256k1, Verification, XOnlyPublicKey}; use crate::hash_types::{PubkeyHash, WPubkeyHash}; diff --git a/bitcoin/src/crypto/taproot.rs b/bitcoin/src/crypto/taproot.rs index 98aa8df5..eddc911d 100644 --- a/bitcoin/src/crypto/taproot.rs +++ b/bitcoin/src/crypto/taproot.rs @@ -8,7 +8,7 @@ use core::fmt; -use bitcoin_internals::write_err; +use internals::write_err; pub use secp256k1::{self, constants, KeyPair, Parity, Secp256k1, Verification, XOnlyPublicKey}; use crate::prelude::*; diff --git a/bitcoin/src/error.rs b/bitcoin/src/error.rs index cab73814..3d3fb4c8 100644 --- a/bitcoin/src/error.rs +++ b/bitcoin/src/error.rs @@ -2,7 +2,7 @@ use core::fmt; -use bitcoin_internals::write_err; +use internals::write_err; use crate::consensus::encode; pub use crate::parse::ParseIntError; diff --git a/bitcoin/src/internal_macros.rs b/bitcoin/src/internal_macros.rs index 1c398f30..c48893f8 100644 --- a/bitcoin/src/internal_macros.rs +++ b/bitcoin/src/internal_macros.rs @@ -84,14 +84,14 @@ macro_rules! impl_bytes_newtype { impl core::fmt::LowerHex for $t { fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { - use bitcoin_internals::hex::{display, Case}; + use internals::hex::{display, Case}; display::fmt_hex_exact!(f, $len, &self.0, Case::Lower) } } impl core::fmt::UpperHex for $t { fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { - use bitcoin_internals::hex::{display, Case}; + use internals::hex::{display, Case}; display::fmt_hex_exact!(f, $len, &self.0, Case::Upper) } } diff --git a/bitcoin/src/lib.rs b/bitcoin/src/lib.rs index 6bc3c080..6013d45a 100644 --- a/bitcoin/src/lib.rs +++ b/bitcoin/src/lib.rs @@ -59,9 +59,9 @@ extern crate alloc; #[cfg(feature = "base64")] pub extern crate base64; pub extern crate bech32; -pub extern crate bitcoin_hashes as hashes; #[cfg(feature = "bitcoinconsensus")] pub extern crate bitcoinconsensus; +pub extern crate hashes; pub extern crate secp256k1; #[cfg(feature = "serde")] @@ -175,7 +175,7 @@ mod prelude { #[cfg(not(feature = "std"))] pub use crate::io_extras::sink; - pub use bitcoin_internals::hex::display::DisplayHex; + pub use internals::hex::display::DisplayHex; } #[cfg(bench)] diff --git a/bitcoin/src/network/constants.rs b/bitcoin/src/network/constants.rs index 1600fb5e..1259cb5a 100644 --- a/bitcoin/src/network/constants.rs +++ b/bitcoin/src/network/constants.rs @@ -32,8 +32,8 @@ use core::fmt::Display; use core::str::FromStr; use core::{fmt, ops}; -use bitcoin_internals::{debug_from_display, write_err}; use hashes::hex::{Error, FromHex}; +use internals::{debug_from_display, write_err}; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; @@ -317,7 +317,7 @@ impl TryFrom for Network { impl fmt::Display for Magic { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - bitcoin_internals::fmt_hex_exact!(f, 4, &self.0, bitcoin_internals::hex::Case::Lower)?; + internals::fmt_hex_exact!(f, 4, &self.0, internals::hex::Case::Lower)?; Ok(()) } } @@ -325,14 +325,14 @@ debug_from_display!(Magic); impl fmt::LowerHex for Magic { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - bitcoin_internals::fmt_hex_exact!(f, 4, &self.0, bitcoin_internals::hex::Case::Lower)?; + internals::fmt_hex_exact!(f, 4, &self.0, internals::hex::Case::Lower)?; Ok(()) } } impl fmt::UpperHex for Magic { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - bitcoin_internals::fmt_hex_exact!(f, 4, &self.0, bitcoin_internals::hex::Case::Upper)?; + internals::fmt_hex_exact!(f, 4, &self.0, internals::hex::Case::Upper)?; Ok(()) } } diff --git a/bitcoin/src/parse.rs b/bitcoin/src/parse.rs index 5c997562..4da00428 100644 --- a/bitcoin/src/parse.rs +++ b/bitcoin/src/parse.rs @@ -2,7 +2,7 @@ use core::convert::TryFrom; use core::fmt; use core::str::FromStr; -use bitcoin_internals::write_err; +use internals::write_err; use crate::error::impl_std_error; use crate::prelude::*; diff --git a/bitcoin/src/pow.rs b/bitcoin/src/pow.rs index b9482a65..7feb8f3f 100644 --- a/bitcoin/src/pow.rs +++ b/bitcoin/src/pow.rs @@ -774,13 +774,13 @@ macro_rules! impl_hex { ($hex:ident, $case:expr) => { impl $hex for U256 { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - bitcoin_internals::hex::display::fmt_hex_exact!(f, 32, &self.to_be_bytes(), $case) + internals::hex::display::fmt_hex_exact!(f, 32, &self.to_be_bytes(), $case) } } }; } -impl_hex!(LowerHex, bitcoin_internals::hex::Case::Lower); -impl_hex!(UpperHex, bitcoin_internals::hex::Case::Upper); +impl_hex!(LowerHex, internals::hex::Case::Lower); +impl_hex!(UpperHex, internals::hex::Case::Upper); #[cfg(feature = "serde")] impl crate::serde::Serialize for U256 { diff --git a/bitcoin/src/psbt/error.rs b/bitcoin/src/psbt/error.rs index 76337ee5..e55c2c4e 100644 --- a/bitcoin/src/psbt/error.rs +++ b/bitcoin/src/psbt/error.rs @@ -2,7 +2,7 @@ use core::fmt; -use bitcoin_internals::write_err; +use internals::write_err; use crate::bip32::ExtendedPubKey; use crate::blockdata::transaction::Transaction; diff --git a/bitcoin/src/psbt/mod.rs b/bitcoin/src/psbt/mod.rs index 99b96f74..5af2317c 100644 --- a/bitcoin/src/psbt/mod.rs +++ b/bitcoin/src/psbt/mod.rs @@ -11,7 +11,7 @@ use core::{cmp, fmt}; #[cfg(feature = "std")] use std::collections::{HashMap, HashSet}; -use bitcoin_internals::write_err; +use internals::write_err; use secp256k1::{Message, Secp256k1, Signing}; use crate::bip32::{self, ExtendedPrivKey, ExtendedPubKey, KeySource}; @@ -754,7 +754,7 @@ mod display_from_str { use core::str::FromStr; use base64::display::Base64Display; - use bitcoin_internals::write_err; + use internals::write_err; use super::{Error, PartiallySignedTransaction}; diff --git a/bitcoin/src/serde_utils.rs b/bitcoin/src/serde_utils.rs index 1cbc07f4..e3cdee7a 100644 --- a/bitcoin/src/serde_utils.rs +++ b/bitcoin/src/serde_utils.rs @@ -12,7 +12,7 @@ impl<'a> serde::Serialize for SerializeBytesAsHex<'a> { where S: serde::Serializer, { - use bitcoin_internals::hex::display::DisplayHex; + use internals::hex::display::DisplayHex; serializer.collect_str(&format_args!("{:x}", self.0.as_hex())) } diff --git a/bitcoin/src/sign_message.rs b/bitcoin/src/sign_message.rs index 553e701d..e4cba47f 100644 --- a/bitcoin/src/sign_message.rs +++ b/bitcoin/src/sign_message.rs @@ -20,8 +20,8 @@ pub const BITCOIN_SIGNED_MSG_PREFIX: &[u8] = b"\x18Bitcoin Signed Message:\n"; mod message_signing { use core::fmt; - use bitcoin_internals::write_err; use hashes::sha256d; + use internals::write_err; use secp256k1; use secp256k1::ecdsa::{RecoverableSignature, RecoveryId}; diff --git a/bitcoin/src/string.rs b/bitcoin/src/string.rs index abcaccb3..1afbeea4 100644 --- a/bitcoin/src/string.rs +++ b/bitcoin/src/string.rs @@ -7,7 +7,7 @@ use core::fmt; -use bitcoin_internals::write_err; +use internals::write_err; use crate::prelude::String; diff --git a/bitcoin/src/taproot.rs b/bitcoin/src/taproot.rs index 3a38fcd0..2cdce7ec 100644 --- a/bitcoin/src/taproot.rs +++ b/bitcoin/src/taproot.rs @@ -10,8 +10,8 @@ use core::convert::TryFrom; use core::fmt; use core::iter::FusedIterator; -use bitcoin_internals::write_err; use hashes::{sha256t_hash_newtype, Hash, HashEngine}; +use internals::write_err; use secp256k1::{self, Scalar, Secp256k1}; use crate::consensus::Encodable;