Skip to content

Commit 6d31685

Browse files
committed
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.
1 parent ac9976a commit 6d31685

File tree

6 files changed

+12
-13
lines changed

6 files changed

+12
-13
lines changed

src/blockdata/script.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -998,7 +998,7 @@ impl<'de> serde::Deserialize<'de> for Script {
998998
D: serde::Deserializer<'de>,
999999
{
10001000
use core::fmt::Formatter;
1001-
use hashes::hex::FromHex;
1001+
use crate::hashes::hex::FromHex;
10021002

10031003
if deserializer.is_human_readable() {
10041004

src/blockdata/witness.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ impl serde::Serialize for Witness {
281281
where
282282
S: serde::Serializer,
283283
{
284-
use hashes::hex::ToHex;
284+
use crate::hashes::hex::ToHex;
285285
use serde::ser::SerializeSeq;
286286

287287
let human_readable = serializer.is_human_readable();
@@ -315,8 +315,8 @@ impl<'de> serde::Deserialize<'de> for Witness {
315315

316316
fn visit_seq<A: serde::de::SeqAccess<'de>>(self, mut a: A) -> Result<Self::Value, A::Error>
317317
{
318-
use hashes::hex::FromHex;
319-
use hashes::hex::Error::*;
318+
use crate::hashes::hex::FromHex;
319+
use crate::hashes::hex::Error::*;
320320
use serde::de::{self, Unexpected};
321321

322322
let mut ret = match a.size_hint() {

src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,7 @@ extern crate alloc;
6363
extern crate core2;
6464

6565
// Re-exported dependencies.
66-
#[macro_use]
67-
pub extern crate bitcoin_hashes as hashes;
66+
pub use bitcoin_hashes as hashes;
6867
pub extern crate bech32;
6968
pub extern crate secp256k1;
7069

src/serde_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ pub mod hex_bytes {
235235
//! Module for serialization of byte arrays as hex strings.
236236
#![allow(missing_docs)]
237237

238-
use hashes::hex::{FromHex, ToHex};
238+
use crate::hashes::hex::{FromHex, ToHex};
239239
use serde;
240240

241241
pub fn serialize<T, S>(bytes: &T, s: S) -> Result<S::Ok, S::Error>

src/util/psbt/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ mod tests {
492492
#[test]
493493
fn test_serde_psbt() {
494494
//! Create a full PSBT value with various fields filled and make sure it can be JSONized.
495-
use hashes::sha256d;
495+
use crate::hashes::sha256d;
496496
use crate::util::psbt::map::Input;
497497
use crate::EcdsaSighashType;
498498

src/util/taproot.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use core::convert::TryFrom;
1313
use core::fmt;
1414
use core::cmp::Reverse;
1515

16-
use crate::hashes::{sha256, Hash, HashEngine};
16+
use crate::hashes::{sha256, sha256t_hash_newtype, Hash, HashEngine};
1717
use crate::schnorr::{TweakedPublicKey, UntweakedPublicKey, TapTweak};
1818
use crate::util::key::XOnlyPublicKey;
1919
use crate::Script;
@@ -49,16 +49,16 @@ const MIDSTATE_TAPSIGHASH: [u8; 32] = [
4949
// f504a425d7f8783b1363868ae3e556586eee945dbc7888dd02a6e2c31873fe9f
5050

5151
// Taproot test vectors from BIP-341 state the hashes without any reversing
52-
hashes::sha256t_hash_newtype!(TapLeafHash, TapLeafTag, MIDSTATE_TAPLEAF, 64,
52+
sha256t_hash_newtype!(TapLeafHash, TapLeafTag, MIDSTATE_TAPLEAF, 64,
5353
doc="Taproot-tagged hash for tapscript Merkle tree leafs", false
5454
);
55-
hashes::sha256t_hash_newtype!(TapBranchHash, TapBranchTag, MIDSTATE_TAPBRANCH, 64,
55+
sha256t_hash_newtype!(TapBranchHash, TapBranchTag, MIDSTATE_TAPBRANCH, 64,
5656
doc="Taproot-tagged hash for tapscript Merkle tree branches", false
5757
);
58-
hashes::sha256t_hash_newtype!(TapTweakHash, TapTweakTag, MIDSTATE_TAPTWEAK, 64,
58+
sha256t_hash_newtype!(TapTweakHash, TapTweakTag, MIDSTATE_TAPTWEAK, 64,
5959
doc="Taproot-tagged hash for public key tweaks", false
6060
);
61-
hashes::sha256t_hash_newtype!(TapSighashHash, TapSighashTag, MIDSTATE_TAPSIGHASH, 64,
61+
sha256t_hash_newtype!(TapSighashHash, TapSighashTag, MIDSTATE_TAPSIGHASH, 64,
6262
doc="Taproot-tagged hash for the taproot signature hash", false
6363
);
6464

0 commit comments

Comments
 (0)