Merge rust-bitcoin/rust-bitcoin#1742: Use package in manifest and shorten import

fabcde036f Use package in manifest and shorten import (Tobin C. Harding)

Pull request description:

  We can use `package` to rename `bitcoin_hashes` to `hashes` and `bitcoin_internals` to `internals`. This makes imports more terse with no loss of meaning.

ACKs for top commit:
  apoelstra:
    ACK fabcde036f
  Kixunil:
    ACK fabcde036f

Tree-SHA512: bc5bff6f7f6bf3b68ba1e0644a83da014081d8c6c9d578c21cb54fdd56a018f68733dd1135d05b590ba193ed9efd12fa9019182c1fed347e604d8548f6ef9103
This commit is contained in:
Andrew Poelstra 2023-04-05 13:24:08 +00:00
commit e83a2d3422
No known key found for this signature in database
GPG Key ID: C588D63CE41B97C1
28 changed files with 47 additions and 50 deletions

View File

@ -16,7 +16,7 @@ exclude = ["tests", "contrib"]
default = [ "std", "secp-recovery" ] default = [ "std", "secp-recovery" ]
rand-std = ["secp256k1/rand-std"] rand-std = ["secp256k1/rand-std"]
rand = ["secp256k1/rand"] rand = ["secp256k1/rand"]
serde = ["actual-serde", "bitcoin_hashes/serde", "secp256k1/serde"] serde = ["actual-serde", "hashes/serde", "secp256k1/serde"]
secp-lowmemory = ["secp256k1/lowmemory"] secp-lowmemory = ["secp256k1/lowmemory"]
secp-recovery = ["secp256k1/recovery"] secp-recovery = ["secp256k1/recovery"]
bitcoinconsensus-std = ["bitcoinconsensus/std", "std"] 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. # 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. # Instead no-std enables additional features required for this crate to be usable without std.
# As a result, both can be enabled without conflict. # As a result, both can be enabled without conflict.
std = ["secp256k1/std", "bitcoin_hashes/std", "bech32/std", "bitcoin-internals/std"] std = ["secp256k1/std", "hashes/std", "bech32/std", "internals/std"]
no-std = ["core2", "bitcoin_hashes/alloc", "bitcoin_hashes/core2", "secp256k1/alloc"] no-std = ["core2", "hashes/alloc", "hashes/core2", "secp256k1/alloc"]
[package.metadata.docs.rs] [package.metadata.docs.rs]
all-features = true all-features = true
rustdoc-args = ["--cfg", "docsrs"] rustdoc-args = ["--cfg", "docsrs"]
[dependencies] [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 } 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"] } secp256k1 = { version = "0.27.0", default-features = false, features = ["bitcoin_hashes"] }
hex_lit = "0.1.1" hex_lit = "0.1.1"

View File

@ -33,8 +33,8 @@ use core::marker::PhantomData;
use core::str::FromStr; use core::str::FromStr;
use bech32; use bech32;
use bitcoin_internals::write_err;
use hashes::{sha256, Hash, HashEngine}; use hashes::{sha256, Hash, HashEngine};
use internals::write_err;
use secp256k1::{Secp256k1, Verification, XOnlyPublicKey}; use secp256k1::{Secp256k1, Verification, XOnlyPublicKey};
use crate::base58; use crate::base58;

View File

@ -10,8 +10,8 @@ use core::{convert, fmt, mem};
#[cfg(feature = "std")] #[cfg(feature = "std")]
use std::error; use std::error;
use bitcoin_internals::impl_array_newtype;
use hashes::{sha256, siphash24, Hash}; use hashes::{sha256, siphash24, Hash};
use internals::impl_array_newtype;
use crate::consensus::encode::{self, Decodable, Encodable, VarInt}; use crate::consensus::encode::{self, Decodable, Encodable, VarInt};
use crate::internal_macros::{impl_bytes_newtype, impl_consensus_encoding}; use crate::internal_macros::{impl_bytes_newtype, impl_consensus_encoding};

View File

@ -43,8 +43,8 @@ use core::cmp::{self, Ordering};
use core::convert::TryInto; use core::convert::TryInto;
use core::fmt::{self, Display, Formatter}; use core::fmt::{self, Display, Formatter};
use bitcoin_internals::write_err;
use hashes::{siphash24, Hash}; use hashes::{siphash24, Hash};
use internals::write_err;
use crate::blockdata::block::Block; use crate::blockdata::block::Block;
use crate::blockdata::script::Script; use crate::blockdata::script::Script;

View File

@ -13,8 +13,8 @@ use core::fmt;
use core::ops::Index; use core::ops::Index;
use core::str::FromStr; use core::str::FromStr;
use bitcoin_internals::{impl_array_newtype, write_err};
use hashes::{hex, sha512, Hash, HashEngine, Hmac, HmacEngine}; use hashes::{hex, sha512, Hash, HashEngine, Hmac, HmacEngine};
use internals::{impl_array_newtype, write_err};
use secp256k1::{self, Secp256k1, XOnlyPublicKey}; use secp256k1::{self, Secp256k1, XOnlyPublicKey};
#[cfg(feature = "serde")] #[cfg(feature = "serde")]
use serde; use serde;

View File

@ -10,9 +10,9 @@
use core::default::Default; use core::default::Default;
use bitcoin_internals::impl_array_newtype;
use hashes::{sha256d, Hash}; use hashes::{sha256d, Hash};
use hex_lit::hex; use hex_lit::hex;
use internals::impl_array_newtype;
use crate::blockdata::block::{self, Block}; use crate::blockdata::block::{self, Block};
use crate::blockdata::locktime::absolute; use crate::blockdata::locktime::absolute;

View File

@ -10,7 +10,7 @@
use core::cmp::{Ordering, PartialOrd}; use core::cmp::{Ordering, PartialOrd};
use core::{fmt, mem}; use core::{fmt, mem};
use bitcoin_internals::write_err; use internals::write_err;
#[cfg(all(test, mutate))] #[cfg(all(test, mutate))]
use mutagen::mutate; use mutagen::mutate;

View File

@ -12,7 +12,7 @@
use core::convert::From; use core::convert::From;
use core::fmt; use core::fmt;
use bitcoin_internals::debug_from_display; use internals::debug_from_display;
#[cfg(feature = "serde")] #[cfg(feature = "serde")]
use serde; use serde;

View File

@ -148,4 +148,4 @@ impl fmt::Display for Builder {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { self.0.fmt_asm(f) } 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);

View File

@ -729,7 +729,7 @@ mod bitcoinconsensus_hack {
impl fmt::Display for Error { impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
#[cfg(feature = "bitcoinconsensus")] #[cfg(feature = "bitcoinconsensus")]
use bitcoin_internals::write_err; use internals::write_err;
match *self { match *self {
Error::NonMinimalPush => f.write_str("non-minimal datapush"), Error::NonMinimalPush => f.write_str("non-minimal datapush"),

View File

@ -16,8 +16,8 @@ use core::convert::TryFrom;
use core::default::Default; use core::default::Default;
use core::{cmp, fmt, str}; use core::{cmp, fmt, str};
use bitcoin_internals::write_err;
use hashes::{self, sha256d, Hash}; use hashes::{self, sha256d, Hash};
use internals::write_err;
use super::Weight; use super::Weight;
use crate::blockdata::constants::WITNESS_SCALE_FACTOR; use crate::blockdata::constants::WITNESS_SCALE_FACTOR;
@ -548,9 +548,9 @@ impl<E> EncodeSigningDataResult<E> {
/// ///
/// ```rust /// ```rust
/// # use bitcoin::consensus::deserialize; /// # use bitcoin::consensus::deserialize;
/// # use bitcoin::hashes::{Hash, hex::FromHex};
/// # use bitcoin::sighash::{LegacySighash, SighashCache}; /// # use bitcoin::sighash::{LegacySighash, SighashCache};
/// # use bitcoin::Transaction; /// # use bitcoin::Transaction;
/// # use bitcoin_hashes::{Hash, hex::FromHex};
/// # let mut writer = LegacySighash::engine(); /// # let mut writer = LegacySighash::engine();
/// # let input_index = 0; /// # let input_index = 0;
/// # let script_pubkey = bitcoin::ScriptBuf::new(); /// # let script_pubkey = bitcoin::ScriptBuf::new();

View File

@ -19,8 +19,8 @@
use core::convert::From; use core::convert::From;
use core::{fmt, mem, u32}; use core::{fmt, mem, u32};
use bitcoin_internals::write_err;
use hashes::{sha256, sha256d, Hash}; use hashes::{sha256, sha256d, Hash};
use internals::write_err;
use crate::bip152::{PrefilledTransaction, ShortId}; use crate::bip152::{PrefilledTransaction, ShortId};
use crate::blockdata::transaction::{Transaction, TxIn, TxOut}; use crate::blockdata::transaction::{Transaction, TxIn, TxOut};

View File

@ -36,7 +36,6 @@ pub mod hex {
use core::fmt; use core::fmt;
use core::marker::PhantomData; use core::marker::PhantomData;
use bitcoin_internals as internals;
use internals::hex::BufEncoder; use internals::hex::BufEncoder;
/// Marker for upper/lower case type-level flags ("type-level enum"). /// Marker for upper/lower case type-level flags ("type-level enum").
@ -51,8 +50,6 @@ pub mod hex {
pub enum Upper {} pub enum Upper {}
mod sealed { mod sealed {
use bitcoin_internals as internals;
pub trait Case { pub trait Case {
/// Internal detail, don't depend on it!!! /// Internal detail, don't depend on it!!!
const INTERNAL_CASE: internals::hex::Case; const INTERNAL_CASE: internals::hex::Case;
@ -103,18 +100,18 @@ pub mod hex {
/// Error returned when a hex string decoder can't be created. /// Error returned when a hex string decoder can't be created.
#[derive(Debug)] #[derive(Debug)]
pub struct DecodeInitError(bitcoin_hashes::hex::Error); pub struct DecodeInitError(hashes::hex::Error);
/// Error returned when a hex string contains invalid characters. /// Error returned when a hex string contains invalid characters.
#[derive(Debug)] #[derive(Debug)]
pub struct DecodeError(bitcoin_hashes::hex::Error); pub struct DecodeError(hashes::hex::Error);
/// Hex decoder state. /// Hex decoder state.
pub struct Decoder<'a>(bitcoin_hashes::hex::HexIterator<'a>); pub struct Decoder<'a>(hashes::hex::HexIterator<'a>);
impl<'a> Decoder<'a> { impl<'a> Decoder<'a> {
fn new(s: &'a str) -> Result<Self, DecodeInitError> { fn new(s: &'a str) -> Result<Self, DecodeInitError> {
match bitcoin_hashes::hex::HexIterator::new(s) { match hashes::hex::HexIterator::new(s) {
Ok(iter) => Ok(Decoder(iter)), Ok(iter) => Ok(Decoder(iter)),
Err(error) => Err(DecodeInitError(error)), Err(error) => Err(DecodeInitError(error)),
} }
@ -139,7 +136,7 @@ pub mod hex {
impl super::IntoDeError for DecodeInitError { impl super::IntoDeError for DecodeInitError {
fn into_de_error<E: serde::de::Error>(self) -> E { fn into_de_error<E: serde::de::Error>(self) -> E {
use bitcoin_hashes::hex::Error; use hashes::hex::Error;
match self.0 { match self.0 {
Error::OddLengthString(len) => Error::OddLengthString(len) =>
@ -151,7 +148,7 @@ pub mod hex {
impl super::IntoDeError for DecodeError { impl super::IntoDeError for DecodeError {
fn into_de_error<E: serde::de::Error>(self) -> E { fn into_de_error<E: serde::de::Error>(self) -> E {
use bitcoin_hashes::hex::Error; use hashes::hex::Error;
use serde::de::Unexpected; use serde::de::Unexpected;
const EXPECTED_CHAR: &str = "an ASCII-encoded hex digit"; const EXPECTED_CHAR: &str = "an ASCII-encoded hex digit";

View File

@ -8,9 +8,9 @@
use core::str::FromStr; use core::str::FromStr;
use core::{fmt, iter}; use core::{fmt, iter};
use bitcoin_internals::hex::display::DisplayHex;
use bitcoin_internals::write_err;
use hashes::hex::{self, FromHex}; use hashes::hex::{self, FromHex};
use internals::hex::display::DisplayHex;
use internals::write_err;
use secp256k1; use secp256k1;
use crate::prelude::*; use crate::prelude::*;

View File

@ -10,9 +10,9 @@ use core::fmt::{self, Write};
use core::ops; use core::ops;
use core::str::FromStr; use core::str::FromStr;
use bitcoin_internals::write_err;
use hashes::hex::FromHex; use hashes::hex::FromHex;
use hashes::{hash160, hex, Hash}; use hashes::{hash160, hex, Hash};
use internals::write_err;
pub use secp256k1::{self, constants, KeyPair, Parity, Secp256k1, Verification, XOnlyPublicKey}; pub use secp256k1::{self, constants, KeyPair, Parity, Secp256k1, Verification, XOnlyPublicKey};
use crate::hash_types::{PubkeyHash, WPubkeyHash}; use crate::hash_types::{PubkeyHash, WPubkeyHash};

View File

@ -8,7 +8,7 @@
use core::fmt; use core::fmt;
use bitcoin_internals::write_err; use internals::write_err;
pub use secp256k1::{self, constants, KeyPair, Parity, Secp256k1, Verification, XOnlyPublicKey}; pub use secp256k1::{self, constants, KeyPair, Parity, Secp256k1, Verification, XOnlyPublicKey};
use crate::prelude::*; use crate::prelude::*;

View File

@ -2,7 +2,7 @@
use core::fmt; use core::fmt;
use bitcoin_internals::write_err; use internals::write_err;
use crate::consensus::encode; use crate::consensus::encode;
pub use crate::parse::ParseIntError; pub use crate::parse::ParseIntError;

View File

@ -84,14 +84,14 @@ macro_rules! impl_bytes_newtype {
impl core::fmt::LowerHex for $t { impl core::fmt::LowerHex for $t {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { 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) display::fmt_hex_exact!(f, $len, &self.0, Case::Lower)
} }
} }
impl core::fmt::UpperHex for $t { impl core::fmt::UpperHex for $t {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { 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) display::fmt_hex_exact!(f, $len, &self.0, Case::Upper)
} }
} }

View File

@ -59,9 +59,9 @@ extern crate alloc;
#[cfg(feature = "base64")] #[cfg(feature = "base64")]
pub extern crate base64; pub extern crate base64;
pub extern crate bech32; pub extern crate bech32;
pub extern crate bitcoin_hashes as hashes;
#[cfg(feature = "bitcoinconsensus")] #[cfg(feature = "bitcoinconsensus")]
pub extern crate bitcoinconsensus; pub extern crate bitcoinconsensus;
pub extern crate hashes;
pub extern crate secp256k1; pub extern crate secp256k1;
#[cfg(feature = "serde")] #[cfg(feature = "serde")]
@ -175,7 +175,7 @@ mod prelude {
#[cfg(not(feature = "std"))] #[cfg(not(feature = "std"))]
pub use crate::io_extras::sink; pub use crate::io_extras::sink;
pub use bitcoin_internals::hex::display::DisplayHex; pub use internals::hex::display::DisplayHex;
} }
#[cfg(bench)] #[cfg(bench)]

View File

@ -32,8 +32,8 @@ use core::fmt::Display;
use core::str::FromStr; use core::str::FromStr;
use core::{fmt, ops}; use core::{fmt, ops};
use bitcoin_internals::{debug_from_display, write_err};
use hashes::hex::{Error, FromHex}; use hashes::hex::{Error, FromHex};
use internals::{debug_from_display, write_err};
#[cfg(feature = "serde")] #[cfg(feature = "serde")]
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@ -317,7 +317,7 @@ impl TryFrom<Magic> for Network {
impl fmt::Display for Magic { impl fmt::Display for Magic {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { 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(()) Ok(())
} }
} }
@ -325,14 +325,14 @@ debug_from_display!(Magic);
impl fmt::LowerHex for Magic { impl fmt::LowerHex for Magic {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { 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(()) Ok(())
} }
} }
impl fmt::UpperHex for Magic { impl fmt::UpperHex for Magic {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { 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(()) Ok(())
} }
} }

View File

@ -2,7 +2,7 @@ use core::convert::TryFrom;
use core::fmt; use core::fmt;
use core::str::FromStr; use core::str::FromStr;
use bitcoin_internals::write_err; use internals::write_err;
use crate::error::impl_std_error; use crate::error::impl_std_error;
use crate::prelude::*; use crate::prelude::*;

View File

@ -774,13 +774,13 @@ macro_rules! impl_hex {
($hex:ident, $case:expr) => { ($hex:ident, $case:expr) => {
impl $hex for U256 { impl $hex for U256 {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 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!(LowerHex, internals::hex::Case::Lower);
impl_hex!(UpperHex, bitcoin_internals::hex::Case::Upper); impl_hex!(UpperHex, internals::hex::Case::Upper);
#[cfg(feature = "serde")] #[cfg(feature = "serde")]
impl crate::serde::Serialize for U256 { impl crate::serde::Serialize for U256 {

View File

@ -2,7 +2,7 @@
use core::fmt; use core::fmt;
use bitcoin_internals::write_err; use internals::write_err;
use crate::bip32::ExtendedPubKey; use crate::bip32::ExtendedPubKey;
use crate::blockdata::transaction::Transaction; use crate::blockdata::transaction::Transaction;

View File

@ -11,7 +11,7 @@ use core::{cmp, fmt};
#[cfg(feature = "std")] #[cfg(feature = "std")]
use std::collections::{HashMap, HashSet}; use std::collections::{HashMap, HashSet};
use bitcoin_internals::write_err; use internals::write_err;
use secp256k1::{Message, Secp256k1, Signing}; use secp256k1::{Message, Secp256k1, Signing};
use crate::bip32::{self, ExtendedPrivKey, ExtendedPubKey, KeySource}; use crate::bip32::{self, ExtendedPrivKey, ExtendedPubKey, KeySource};
@ -754,7 +754,7 @@ mod display_from_str {
use core::str::FromStr; use core::str::FromStr;
use base64::display::Base64Display; use base64::display::Base64Display;
use bitcoin_internals::write_err; use internals::write_err;
use super::{Error, PartiallySignedTransaction}; use super::{Error, PartiallySignedTransaction};

View File

@ -12,7 +12,7 @@ impl<'a> serde::Serialize for SerializeBytesAsHex<'a> {
where where
S: serde::Serializer, S: serde::Serializer,
{ {
use bitcoin_internals::hex::display::DisplayHex; use internals::hex::display::DisplayHex;
serializer.collect_str(&format_args!("{:x}", self.0.as_hex())) serializer.collect_str(&format_args!("{:x}", self.0.as_hex()))
} }

View File

@ -20,8 +20,8 @@ pub const BITCOIN_SIGNED_MSG_PREFIX: &[u8] = b"\x18Bitcoin Signed Message:\n";
mod message_signing { mod message_signing {
use core::fmt; use core::fmt;
use bitcoin_internals::write_err;
use hashes::sha256d; use hashes::sha256d;
use internals::write_err;
use secp256k1; use secp256k1;
use secp256k1::ecdsa::{RecoverableSignature, RecoveryId}; use secp256k1::ecdsa::{RecoverableSignature, RecoveryId};

View File

@ -7,7 +7,7 @@
use core::fmt; use core::fmt;
use bitcoin_internals::write_err; use internals::write_err;
use crate::prelude::String; use crate::prelude::String;

View File

@ -10,8 +10,8 @@ use core::convert::TryFrom;
use core::fmt; use core::fmt;
use core::iter::FusedIterator; use core::iter::FusedIterator;
use bitcoin_internals::write_err;
use hashes::{sha256t_hash_newtype, Hash, HashEngine}; use hashes::{sha256t_hash_newtype, Hash, HashEngine};
use internals::write_err;
use secp256k1::{self, Scalar, Secp256k1}; use secp256k1::{self, Scalar, Secp256k1};
use crate::consensus::Encodable; use crate::consensus::Encodable;