Remove extern crate bitcoin_hashes

Now we have edition 2018 we do not need to use `macro_use` or `extern
crate`; `pub use` works with macros.

Remove the extern crate statement and replace it with a pub use
statement. Requires fixing up various imports statements and also
requires importing `sha256t_hash_newtype` macro directly instead of
using a qualified path to it.
This commit is contained in:
Tobin C. Harding 2022-06-07 12:57:09 +10:00
parent e2b038bf3d
commit 01a8cc6848
6 changed files with 12 additions and 13 deletions

View File

@ -998,7 +998,7 @@ impl<'de> serde::Deserialize<'de> for Script {
D: serde::Deserializer<'de>, D: serde::Deserializer<'de>,
{ {
use core::fmt::Formatter; use core::fmt::Formatter;
use hashes::hex::FromHex; use crate::hashes::hex::FromHex;
if deserializer.is_human_readable() { if deserializer.is_human_readable() {

View File

@ -281,7 +281,7 @@ impl serde::Serialize for Witness {
where where
S: serde::Serializer, S: serde::Serializer,
{ {
use hashes::hex::ToHex; use crate::hashes::hex::ToHex;
use serde::ser::SerializeSeq; use serde::ser::SerializeSeq;
let human_readable = serializer.is_human_readable(); let human_readable = serializer.is_human_readable();
@ -315,8 +315,8 @@ impl<'de> serde::Deserialize<'de> for Witness {
fn visit_seq<A: serde::de::SeqAccess<'de>>(self, mut a: A) -> Result<Self::Value, A::Error> fn visit_seq<A: serde::de::SeqAccess<'de>>(self, mut a: A) -> Result<Self::Value, A::Error>
{ {
use hashes::hex::FromHex; use crate::hashes::hex::FromHex;
use hashes::hex::Error::*; use crate::hashes::hex::Error::*;
use serde::de::{self, Unexpected}; use serde::de::{self, Unexpected};
let mut ret = match a.size_hint() { let mut ret = match a.size_hint() {

View File

@ -63,8 +63,7 @@ extern crate alloc;
extern crate core2; extern crate core2;
// Re-exported dependencies. // Re-exported dependencies.
#[macro_use] pub use bitcoin_hashes as hashes;
pub extern crate bitcoin_hashes as hashes;
pub extern crate bech32; pub extern crate bech32;
pub extern crate secp256k1; pub extern crate secp256k1;

View File

@ -235,7 +235,7 @@ pub mod hex_bytes {
//! Module for serialization of byte arrays as hex strings. //! Module for serialization of byte arrays as hex strings.
#![allow(missing_docs)] #![allow(missing_docs)]
use hashes::hex::{FromHex, ToHex}; use crate::hashes::hex::{FromHex, ToHex};
use serde; use serde;
pub fn serialize<T, S>(bytes: &T, s: S) -> Result<S::Ok, S::Error> pub fn serialize<T, S>(bytes: &T, s: S) -> Result<S::Ok, S::Error>

View File

@ -492,7 +492,7 @@ mod tests {
#[test] #[test]
fn test_serde_psbt() { fn test_serde_psbt() {
//! Create a full PSBT value with various fields filled and make sure it can be JSONized. //! Create a full PSBT value with various fields filled and make sure it can be JSONized.
use hashes::sha256d; use crate::hashes::sha256d;
use crate::util::psbt::map::Input; use crate::util::psbt::map::Input;
use crate::EcdsaSighashType; use crate::EcdsaSighashType;

View File

@ -13,7 +13,7 @@ use core::convert::TryFrom;
use core::fmt; use core::fmt;
use core::cmp::Reverse; use core::cmp::Reverse;
use crate::hashes::{sha256, Hash, HashEngine}; use crate::hashes::{sha256, sha256t_hash_newtype, Hash, HashEngine};
use crate::schnorr::{TweakedPublicKey, UntweakedPublicKey, TapTweak}; use crate::schnorr::{TweakedPublicKey, UntweakedPublicKey, TapTweak};
use crate::util::key::XOnlyPublicKey; use crate::util::key::XOnlyPublicKey;
use crate::Script; use crate::Script;
@ -49,16 +49,16 @@ const MIDSTATE_TAPSIGHASH: [u8; 32] = [
// f504a425d7f8783b1363868ae3e556586eee945dbc7888dd02a6e2c31873fe9f // f504a425d7f8783b1363868ae3e556586eee945dbc7888dd02a6e2c31873fe9f
// Taproot test vectors from BIP-341 state the hashes without any reversing // Taproot test vectors from BIP-341 state the hashes without any reversing
hashes::sha256t_hash_newtype!(TapLeafHash, TapLeafTag, MIDSTATE_TAPLEAF, 64, sha256t_hash_newtype!(TapLeafHash, TapLeafTag, MIDSTATE_TAPLEAF, 64,
doc="Taproot-tagged hash for tapscript Merkle tree leafs", false doc="Taproot-tagged hash for tapscript Merkle tree leafs", false
); );
hashes::sha256t_hash_newtype!(TapBranchHash, TapBranchTag, MIDSTATE_TAPBRANCH, 64, sha256t_hash_newtype!(TapBranchHash, TapBranchTag, MIDSTATE_TAPBRANCH, 64,
doc="Taproot-tagged hash for tapscript Merkle tree branches", false doc="Taproot-tagged hash for tapscript Merkle tree branches", false
); );
hashes::sha256t_hash_newtype!(TapTweakHash, TapTweakTag, MIDSTATE_TAPTWEAK, 64, sha256t_hash_newtype!(TapTweakHash, TapTweakTag, MIDSTATE_TAPTWEAK, 64,
doc="Taproot-tagged hash for public key tweaks", false doc="Taproot-tagged hash for public key tweaks", false
); );
hashes::sha256t_hash_newtype!(TapSighashHash, TapSighashTag, MIDSTATE_TAPSIGHASH, 64, sha256t_hash_newtype!(TapSighashHash, TapSighashTag, MIDSTATE_TAPSIGHASH, 64,
doc="Taproot-tagged hash for the taproot signature hash", false doc="Taproot-tagged hash for the taproot signature hash", false
); );