diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index ea74fb993f..c33bd02734 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -24,7 +24,7 @@ jobs: DO_BENCH: true AS_DEPENDENCY: true DO_NO_STD: true - - rust: 1.29.0 + - rust: 1.36.0 env: AS_DEPENDENCY: true PIN_VERSIONS: true diff --git a/Cargo.toml b/Cargo.toml index 1340806046..2dd872740e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,6 +9,7 @@ documentation = "https://docs.rs/bitcoin/" description = "General purpose library for using and interoperating with Bitcoin and other cryptocurrencies." keywords = [ "crypto", "bitcoin" ] readme = "README.md" +edition = "2018" [features] diff --git a/README.md b/README.md index b3079f4545..b6c1b480b3 100644 --- a/README.md +++ b/README.md @@ -51,25 +51,10 @@ please join us in [libera.chat](https://libera.chat). ## Minimum Supported Rust Version (MSRV) -This library should always compile with any combination of features on **Rust 1.29**. +This library should always compile with any combination of features on **Rust 1.36**. -Because some dependencies have broken the build in minor/patch releases, to -compile with 1.29.0 you will need to run the following version-pinning command: -``` -cargo update -p cc --precise "1.0.41" --verbose -``` - -In order to use the `use-serde` feature or to build the unit tests with 1.29.0, -the following version-pinning commands are also needed: -``` -cargo update --package "serde" --precise "1.0.98" -cargo update --package "serde_derive" --precise "1.0.98" -``` - -For the feature `base64` to work with 1.29.0 we also need to pin `byteorder`: -``` -cargo update -p byteorder --precise "1.3.4" -``` +No pinning of dependencies is currently required but it may change in the future. +Please report if you find such case. ## Installing Rust Rust can be installed using your package manager of choice or diff --git a/contrib/test.sh b/contrib/test.sh index 5f61ccc7bb..bb56feb756 100755 --- a/contrib/test.sh +++ b/contrib/test.sh @@ -10,15 +10,10 @@ fi pin_common_verions() { cargo generate-lockfile --verbose - cargo update -p cc --precise "1.0.41" --verbose - cargo update -p serde --precise "1.0.98" --verbose - cargo update -p serde_derive --precise "1.0.98" --verbose } -# Pin `cc` for Rust 1.29 if [ "$PIN_VERSIONS" = true ]; then pin_common_verions - cargo update -p byteorder --precise "1.3.4" fi if [ "$DO_COV" = true ] @@ -90,7 +85,6 @@ then cd dep_test echo 'bitcoin = { path = "..", features = ["use-serde"] }' >> Cargo.toml - # Pin `cc` for Rust 1.29 if [ -n "$PIN_VERSIONS" ]; then pin_common_verions fi diff --git a/examples/bip32.rs b/examples/bip32.rs index 0b0d1f27ef..65819af3c0 100644 --- a/examples/bip32.rs +++ b/examples/bip32.rs @@ -1,5 +1,3 @@ -extern crate bitcoin; - use std::{env, process}; use std::str::FromStr; diff --git a/examples/handshake.rs b/examples/handshake.rs index 036d4223e7..4624cff6f5 100644 --- a/examples/handshake.rs +++ b/examples/handshake.rs @@ -1,5 +1,3 @@ -extern crate bitcoin; - use std::net::{IpAddr, Ipv4Addr, Shutdown, SocketAddr, TcpStream}; use std::time::{SystemTime, UNIX_EPOCH}; use std::{env, process}; diff --git a/src/blockdata/block.rs b/src/blockdata/block.rs index 0c53ed42ec..c276f5cdee 100644 --- a/src/blockdata/block.rs +++ b/src/blockdata/block.rs @@ -20,22 +20,22 @@ //! these blocks and the blockchain. //! -use prelude::*; +use crate::prelude::*; use core::fmt; -use util; -use util::Error::{BlockBadTarget, BlockBadProofOfWork}; -use util::hash::bitcoin_merkle_root; -use hashes::{Hash, HashEngine}; -use hash_types::{Wtxid, BlockHash, TxMerkleNode, WitnessMerkleNode, WitnessCommitment}; -use util::uint::Uint256; -use consensus::encode::Encodable; -use network::constants::Network; -use blockdata::transaction::Transaction; -use blockdata::constants::{max_target, WITNESS_SCALE_FACTOR}; -use blockdata::script; -use VarInt; +use crate::util; +use crate::util::Error::{BlockBadTarget, BlockBadProofOfWork}; +use crate::util::hash::bitcoin_merkle_root; +use crate::hashes::{Hash, HashEngine}; +use crate::hash_types::{Wtxid, BlockHash, TxMerkleNode, WitnessMerkleNode, WitnessCommitment}; +use crate::util::uint::Uint256; +use crate::consensus::encode::Encodable; +use crate::network::constants::Network; +use crate::blockdata::transaction::Transaction; +use crate::blockdata::constants::{max_target, WITNESS_SCALE_FACTOR}; +use crate::blockdata::script; +use crate::VarInt; /// A block header, which contains all the block's information except /// the actual transactions @@ -299,7 +299,7 @@ pub enum Bip34Error { } impl fmt::Display for Bip34Error { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { Bip34Error::Unsupported => write!(f, "block doesn't support BIP34"), Bip34Error::NotPresent => write!(f, "BIP34 push not present in block's coinbase"), @@ -311,17 +311,17 @@ impl fmt::Display for Bip34Error { } #[cfg(feature = "std")] -impl ::std::error::Error for Bip34Error {} +impl std::error::Error for Bip34Error {} #[cfg(test)] mod tests { - use hashes::hex::FromHex; + use crate::hashes::hex::FromHex; - use blockdata::block::{Block, BlockHeader}; - use consensus::encode::{deserialize, serialize}; - use util::uint::Uint256; - use util::Error::{BlockBadTarget, BlockBadProofOfWork}; - use network::constants::Network; + use crate::blockdata::block::{Block, BlockHeader}; + use crate::consensus::encode::{deserialize, serialize}; + use crate::util::uint::Uint256; + use crate::util::Error::{BlockBadTarget, BlockBadProofOfWork}; + use crate::network::constants::Network; #[test] fn test_coinbase_and_bip34() { @@ -462,8 +462,8 @@ mod tests { #[cfg(all(test, feature = "unstable"))] mod benches { use super::Block; - use EmptyWrite; - use consensus::{deserialize, Encodable}; + use crate::EmptyWrite; + use crate::consensus::{deserialize, Encodable}; use hashes::hex::FromHex; use test::{black_box, Bencher}; diff --git a/src/blockdata/constants.rs b/src/blockdata/constants.rs index af639f41bd..e612691b5e 100644 --- a/src/blockdata/constants.rs +++ b/src/blockdata/constants.rs @@ -19,18 +19,16 @@ //! single transaction //! -use prelude::*; +use crate::prelude::*; -use core::default::Default; - -use hashes::hex::{HexIterator, Error as HexError}; -use hashes::sha256d; -use blockdata::opcodes; -use blockdata::script; -use blockdata::transaction::{OutPoint, Transaction, TxOut, TxIn}; -use blockdata::block::{Block, BlockHeader}; -use network::constants::Network; -use util::uint::Uint256; +use crate::hashes::hex::{HexIterator, Error as HexError}; +use crate::hashes::sha256d; +use crate::blockdata::opcodes; +use crate::blockdata::script; +use crate::blockdata::transaction::{OutPoint, Transaction, TxOut, TxIn}; +use crate::blockdata::block::{Block, BlockHeader}; +use crate::network::constants::Network; +use crate::util::uint::Uint256; /// The maximum allowable sequence number pub const MAX_SEQUENCE: u32 = 0xFFFFFFFF; @@ -165,13 +163,12 @@ pub fn genesis_block(network: Network) -> Block { #[cfg(test)] mod test { - use core::default::Default; - use hashes::hex::FromHex; + use crate::hashes::hex::FromHex; - use network::constants::Network; - use consensus::encode::serialize; - use blockdata::constants::{genesis_block, bitcoin_genesis_tx}; - use blockdata::constants::{MAX_SEQUENCE, COIN_VALUE}; + use crate::network::constants::Network; + use crate::consensus::encode::serialize; + use crate::blockdata::constants::{genesis_block, bitcoin_genesis_tx}; + use crate::blockdata::constants::{MAX_SEQUENCE, COIN_VALUE}; #[test] fn bitcoin_genesis_first_transaction() { diff --git a/src/blockdata/opcodes.rs b/src/blockdata/opcodes.rs index bf1be28a85..b97b1fa675 100644 --- a/src/blockdata/opcodes.rs +++ b/src/blockdata/opcodes.rs @@ -22,7 +22,7 @@ #[cfg(feature = "serde")] use serde; -#[cfg(feature = "serde")] use prelude::*; +#[cfg(feature = "serde")] use crate::prelude::*; use core::{fmt, convert::From}; @@ -560,7 +560,7 @@ pub mod all { } impl fmt::Debug for All { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str("OP_")?; match *self { All {code: x} if x <= 75 => write!(f, "PUSHBYTES_{}", self.code), diff --git a/src/blockdata/script.rs b/src/blockdata/script.rs index 42ecab584c..8494b5d457 100644 --- a/src/blockdata/script.rs +++ b/src/blockdata/script.rs @@ -24,23 +24,23 @@ //! This module provides the structures and functions needed to support scripts. //! -use prelude::*; +use crate::prelude::*; -use io; -use core::{fmt, default::Default}; +use crate::io; +use core::fmt; #[cfg(feature = "serde")] use serde; -use hash_types::{PubkeyHash, WPubkeyHash, ScriptHash, WScriptHash}; -use blockdata::opcodes; -use consensus::{encode, Decodable, Encodable}; -use hashes::{Hash, hex}; -use policy::DUST_RELAY_TX_FEE; +use crate::hash_types::{PubkeyHash, WPubkeyHash, ScriptHash, WScriptHash}; +use crate::blockdata::opcodes; +use crate::consensus::{encode, Decodable, Encodable}; +use crate::hashes::{Hash, hex}; +use crate::policy::DUST_RELAY_TX_FEE; #[cfg(feature="bitcoinconsensus")] use bitcoinconsensus; #[cfg(feature="bitcoinconsensus")] use core::convert::From; -#[cfg(feature="bitcoinconsensus")] use OutPoint; +#[cfg(feature="bitcoinconsensus")] use crate::OutPoint; -use util::ecdsa::PublicKey; +use crate::util::ecdsa::PublicKey; #[derive(Clone, Default, PartialOrd, Ord, PartialEq, Eq, Hash)] /// A Bitcoin script @@ -53,7 +53,7 @@ impl AsRef<[u8]> for Script { } impl fmt::Debug for Script { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str("Script(")?; self.fmt_asm(f)?; f.write_str(")") @@ -61,13 +61,13 @@ impl fmt::Debug for Script { } impl fmt::Display for Script { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Debug::fmt(self, f) } } impl fmt::LowerHex for Script { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { for &ch in self.0.iter() { write!(f, "{:02x}", ch)?; } @@ -76,7 +76,7 @@ impl fmt::LowerHex for Script { } impl fmt::UpperHex for Script { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { for &ch in self.0.iter() { write!(f, "{:02X}", ch)?; } @@ -94,7 +94,7 @@ impl hex::FromHex for Script { } } -impl ::core::str::FromStr for Script { +impl core::str::FromStr for Script { type Err = hex::Error; fn from_str(s: &str) -> Result { hex::FromHex::from_hex(s) @@ -130,7 +130,7 @@ pub enum Error { } impl fmt::Display for Error { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let str = match *self { Error::NonMinimalPush => "non-minimal datapush", Error::EarlyEndOfScript => "unexpected end of script", @@ -147,7 +147,7 @@ impl fmt::Display for Error { } #[cfg(feature = "std")] -impl ::std::error::Error for Error {} +impl std::error::Error for Error {} #[cfg(feature="bitcoinconsensus")] #[doc(hidden)] @@ -268,16 +268,16 @@ impl Script { /// Generates P2WPKH-type of scriptPubkey pub fn new_v0_wpkh(pubkey_hash: &WPubkeyHash) -> Script { - Script::new_witness_program(::bech32::u5::try_from_u8(0).unwrap(), &pubkey_hash.to_vec()) + Script::new_witness_program(bech32::u5::try_from_u8(0).unwrap(), &pubkey_hash.to_vec()) } /// Generates P2WSH-type of scriptPubkey with a given hash of the redeem script pub fn new_v0_wsh(script_hash: &WScriptHash) -> Script { - Script::new_witness_program(::bech32::u5::try_from_u8(0).unwrap(), &script_hash.to_vec()) + Script::new_witness_program(bech32::u5::try_from_u8(0).unwrap(), &script_hash.to_vec()) } /// Generates P2WSH-type of scriptPubkey with a given hash of the redeem script - pub fn new_witness_program(ver: ::bech32::u5, program: &[u8]) -> Script { + pub fn new_witness_program(ver: bech32::u5, program: &[u8]) -> Script { let mut verop = ver.to_u8(); assert!(verop <= 16, "incorrect witness version provided: {}", verop); if verop > 0 { @@ -413,7 +413,7 @@ impl Script { /// Gets the minimum value an output with this script should have in order to be /// broadcastable on today's bitcoin network. - pub fn dust_value(&self) -> ::Amount { + pub fn dust_value(&self) -> crate::Amount { // This must never be lower than Bitcoin Core's GetDustThreshold() (as of v0.21) as it may // otherwise allow users to create transactions which likely can never be // broadcasted/confirmed. @@ -430,7 +430,7 @@ impl Script { self.consensus_encode(&mut sink()).unwrap() as u64 // The serialized size of this script_pubkey }; - ::Amount::from_sat(sats) + crate::Amount::from_sat(sats) } /// Iterate over the script in the form of `Instruction`s, which are an enum covering @@ -439,7 +439,7 @@ impl Script { /// it as a slice using `script[..]` or convert it to a vector using `into_bytes()`. /// /// To force minimal pushes, use [Self::instructions_minimal]. - pub fn instructions(&self) -> Instructions { + pub fn instructions(&self) -> Instructions<'_> { Instructions { data: &self.0[..], enforce_minimal: false, @@ -448,7 +448,7 @@ impl Script { /// Iterate over the script in the form of `Instruction`s while enforcing /// minimal pushes. - pub fn instructions_minimal(&self) -> Instructions { + pub fn instructions_minimal(&self) -> Instructions<'_> { Instructions { data: &self.0[..], enforce_minimal: true, @@ -458,7 +458,7 @@ impl Script { #[cfg(feature="bitcoinconsensus")] /// Shorthand for [Self::verify_with_flags] with flag [bitcoinconsensus::VERIFY_ALL] pub fn verify (&self, index: usize, amount: u64, spending: &[u8]) -> Result<(), Error> { - self.verify_with_flags(index, ::Amount::from_sat(amount), spending, ::bitcoinconsensus::VERIFY_ALL) + self.verify_with_flags(index, crate::Amount::from_sat(amount), spending, bitcoinconsensus::VERIFY_ALL) } #[cfg(feature="bitcoinconsensus")] @@ -468,7 +468,7 @@ impl Script { /// * `amount` - the amount this script guards /// * `spending` - the transaction that attempts to spend the output holding this script /// * `flags` - verification flags, see [bitcoinconsensus::VERIFY_ALL] and similar - pub fn verify_with_flags>(&self, index: usize, amount: ::Amount, spending: &[u8], flags: F) -> Result<(), Error> { + pub fn verify_with_flags>(&self, index: usize, amount: crate::Amount, spending: &[u8], flags: F) -> Result<(), Error> { Ok(bitcoinconsensus::verify_with_flags (&self.0[..], amount.as_sat(), spending, index, flags.into())?) } @@ -827,13 +827,13 @@ impl<'de> serde::Deserialize<'de> for Script { D: serde::Deserializer<'de>, { use core::fmt::Formatter; - use hashes::hex::FromHex; + use crate::hashes::hex::FromHex; struct Visitor; impl<'de> serde::de::Visitor<'de> for Visitor { type Value = Script; - fn expecting(&self, formatter: &mut Formatter) -> fmt::Result { + fn expecting(&self, formatter: &mut Formatter<'_>) -> fmt::Result { formatter.write_str("a script") } @@ -900,11 +900,11 @@ mod test { use super::*; use super::build_scriptint; - use hashes::hex::{FromHex, ToHex}; - use consensus::encode::{deserialize, serialize}; - use blockdata::opcodes; - use util::ecdsa::PublicKey; - use util::psbt::serialize::Serialize; + use crate::hashes::hex::{FromHex, ToHex}; + use crate::consensus::encode::{deserialize, serialize}; + use crate::blockdata::opcodes; + use crate::util::ecdsa::PublicKey; + use crate::util::psbt::serialize::Serialize; #[test] fn script() { @@ -1183,15 +1183,15 @@ mod test { let minimal = hex_script!("0169b2"); // minimal let nonminimal_alt = hex_script!("026900b2"); // non-minimal number but minimal push (should be OK) - let v_zero: Result, Error> = zero.instructions_minimal().collect(); - let v_zeropush: Result, Error> = zeropush.instructions_minimal().collect(); + let v_zero: Result>, Error> = zero.instructions_minimal().collect(); + let v_zeropush: Result>, Error> = zeropush.instructions_minimal().collect(); - let v_min: Result, Error> = minimal.instructions_minimal().collect(); - let v_nonmin: Result, Error> = nonminimal.instructions_minimal().collect(); - let v_nonmin_alt: Result, Error> = nonminimal_alt.instructions_minimal().collect(); - let slop_v_min: Result, Error> = minimal.instructions().collect(); - let slop_v_nonmin: Result, Error> = nonminimal.instructions().collect(); - let slop_v_nonmin_alt: Result, Error> = nonminimal_alt.instructions().collect(); + let v_min: Result>, Error> = minimal.instructions_minimal().collect(); + let v_nonmin: Result>, Error> = nonminimal.instructions_minimal().collect(); + let v_nonmin_alt: Result>, Error> = nonminimal_alt.instructions_minimal().collect(); + let slop_v_min: Result>, Error> = minimal.instructions().collect(); + let slop_v_nonmin: Result>, Error> = nonminimal.instructions().collect(); + let slop_v_nonmin_alt: Result>, Error> = nonminimal_alt.instructions().collect(); assert_eq!( v_zero.unwrap(), @@ -1266,7 +1266,7 @@ mod test { // well-known scriptPubKey types. let script_p2wpkh = Builder::new().push_int(0).push_slice(&[42; 20]).into_script(); assert!(script_p2wpkh.is_v0_p2wpkh()); - assert_eq!(script_p2wpkh.dust_value(), ::Amount::from_sat(294)); + assert_eq!(script_p2wpkh.dust_value(), crate::Amount::from_sat(294)); let script_p2pkh = Builder::new() .push_opcode(opcodes::all::OP_DUP) @@ -1276,7 +1276,7 @@ mod test { .push_opcode(opcodes::all::OP_CHECKSIG) .into_script(); assert!(script_p2pkh.is_p2pkh()); - assert_eq!(script_p2pkh.dust_value(), ::Amount::from_sat(546)); + assert_eq!(script_p2pkh.dust_value(), crate::Amount::from_sat(546)); } } diff --git a/src/blockdata/transaction.rs b/src/blockdata/transaction.rs index 4ecac18a21..34d16c0f25 100644 --- a/src/blockdata/transaction.rs +++ b/src/blockdata/transaction.rs @@ -23,23 +23,23 @@ //! This module provides the structures and functions needed to support transactions. //! -use prelude::*; +use crate::prelude::*; -use io; -use core::{fmt, str, default::Default}; +use crate::io; +use core::fmt; #[cfg(feature = "std")] use std::error; -use hashes::{self, Hash, sha256d}; -use hashes::hex::FromHex; +use crate::hashes::{self, Hash, sha256d}; +use crate::hashes::hex::FromHex; -use util::endian; -use blockdata::constants::WITNESS_SCALE_FACTOR; -#[cfg(feature="bitcoinconsensus")] use blockdata::script; -use blockdata::script::Script; -use consensus::{encode, Decodable, Encodable}; -use consensus::encode::MAX_VEC_SIZE; -use hash_types::{SigHash, Txid, Wtxid}; -use VarInt; +use crate::util::endian; +use crate::blockdata::constants::WITNESS_SCALE_FACTOR; +#[cfg(feature="bitcoinconsensus")] use crate::blockdata::script; +use crate::blockdata::script::Script; +use crate::consensus::{encode, Decodable, Encodable}; +use crate::consensus::encode::MAX_VEC_SIZE; +use crate::hash_types::{SigHash, Txid, Wtxid}; +use crate::VarInt; /// A reference to a transaction output #[derive(Copy, Clone, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)] @@ -100,7 +100,7 @@ impl Default for OutPoint { } impl fmt::Display for OutPoint { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}:{}", self.txid, self.vout) } } @@ -111,7 +111,7 @@ pub enum ParseOutPointError { /// Error in TXID part. Txid(hashes::hex::Error), /// Error in vout part. - Vout(::core::num::ParseIntError), + Vout(core::num::ParseIntError), /// Error in general format. Format, /// Size exceeds max. @@ -121,7 +121,7 @@ pub enum ParseOutPointError { } impl fmt::Display for ParseOutPointError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { ParseOutPointError::Txid(ref e) => write!(f, "error parsing TXID: {}", e), ParseOutPointError::Vout(ref e) => write!(f, "error parsing vout: {}", e), @@ -155,7 +155,7 @@ fn parse_vout(s: &str) -> Result { Ok(s.parse().map_err(ParseOutPointError::Vout)?) } -impl ::core::str::FromStr for OutPoint { +impl core::str::FromStr for OutPoint { type Err = ParseOutPointError; fn from_str(s: &str) -> Result { @@ -471,7 +471,7 @@ impl Transaction { /// Shorthand for [Self::verify_with_flags] with flag [bitcoinconsensus::VERIFY_ALL] pub fn verify(&self, spent: S) -> Result<(), script::Error> where S: FnMut(&OutPoint) -> Option { - self.verify_with_flags(spent, ::bitcoinconsensus::VERIFY_ALL) + self.verify_with_flags(spent, bitcoinconsensus::VERIFY_ALL) } #[cfg(feature="bitcoinconsensus")] @@ -483,7 +483,7 @@ impl Transaction { let flags: u32 = flags.into(); for (idx, input) in self.input.iter().enumerate() { if let Some(output) = spent(&input.previous_output) { - output.script_pubkey.verify_with_flags(idx, ::Amount::from_sat(output.value), tx.as_slice(), flags)?; + output.script_pubkey.verify_with_flags(idx, crate::Amount::from_sat(output.value), tx.as_slice(), flags)?; } else { return Err(script::Error::UnknownSpentOutput(input.previous_output.clone())); } @@ -628,7 +628,7 @@ impl Decodable for Transaction { pub struct NonStandardSigHashType; impl fmt::Display for NonStandardSigHashType { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "Non standard sighash type") } } @@ -672,7 +672,7 @@ impl fmt::Display for SigHashType { } } -impl str::FromStr for SigHashType { +impl core::str::FromStr for SigHashType { type Err = String; fn from_str(s: &str) -> Result { @@ -761,16 +761,16 @@ mod tests { use super::{OutPoint, ParseOutPointError, Transaction, TxIn, NonStandardSigHashType}; use core::str::FromStr; - use blockdata::constants::WITNESS_SCALE_FACTOR; - use blockdata::script::Script; - use consensus::encode::serialize; - use consensus::encode::deserialize; + use crate::blockdata::constants::WITNESS_SCALE_FACTOR; + use crate::blockdata::script::Script; + use crate::consensus::encode::serialize; + use crate::consensus::encode::deserialize; - use hashes::Hash; - use hashes::hex::FromHex; + use crate::hashes::Hash; + use crate::hashes::hex::FromHex; - use hash_types::*; - use SigHashType; + use crate::hash_types::*; + use crate::SigHashType; #[test] fn test_outpoint() { @@ -823,8 +823,8 @@ mod tests { #[test] fn test_is_coinbase () { - use network::constants::Network; - use blockdata::constants; + use crate::network::constants::Network; + use crate::blockdata::constants; let genesis = constants::genesis_block(Network::Bitcoin); assert! (genesis.txdata[0].is_coin_base()); @@ -1363,7 +1363,7 @@ mod tests { fn test_transaction_verify () { use hashes::hex::FromHex; use std::collections::HashMap; - use blockdata::script; + use crate::blockdata::script; // a random recent segwit transaction from blockchain using both old and segwit inputs let mut spending: Transaction = deserialize(Vec::from_hex("020000000001031cfbc8f54fbfa4a33a30068841371f80dbfe166211242213188428f437445c91000000006a47304402206fbcec8d2d2e740d824d3d36cc345b37d9f65d665a99f5bd5c9e8d42270a03a8022013959632492332200c2908459547bf8dbf97c65ab1a28dec377d6f1d41d3d63e012103d7279dfb90ce17fe139ba60a7c41ddf605b25e1c07a4ddcb9dfef4e7d6710f48feffffff476222484f5e35b3f0e43f65fc76e21d8be7818dd6a989c160b1e5039b7835fc00000000171600140914414d3c94af70ac7e25407b0689e0baa10c77feffffffa83d954a62568bbc99cc644c62eb7383d7c2a2563041a0aeb891a6a4055895570000000017160014795d04cc2d4f31480d9a3710993fbd80d04301dffeffffff06fef72f000000000017a91476fd7035cd26f1a32a5ab979e056713aac25796887a5000f00000000001976a914b8332d502a529571c6af4be66399cd33379071c588ac3fda0500000000001976a914fc1d692f8de10ae33295f090bea5fe49527d975c88ac522e1b00000000001976a914808406b54d1044c429ac54c0e189b0d8061667e088ac6eb68501000000001976a914dfab6085f3a8fb3e6710206a5a959313c5618f4d88acbba20000000000001976a914eb3026552d7e3f3073457d0bee5d4757de48160d88ac0002483045022100bee24b63212939d33d513e767bc79300051f7a0d433c3fcf1e0e3bf03b9eb1d70220588dc45a9ce3a939103b4459ce47500b64e23ab118dfc03c9caa7d6bfc32b9c601210354fd80328da0f9ae6eef2b3a81f74f9a6f66761fadf96f1d1d22b1fd6845876402483045022100e29c7e3a5efc10da6269e5fc20b6a1cb8beb92130cc52c67e46ef40aaa5cac5f0220644dd1b049727d991aece98a105563416e10a5ac4221abac7d16931842d5c322012103960b87412d6e169f30e12106bdf70122aabb9eb61f455518322a18b920a4dfa887d30700") @@ -1418,8 +1418,8 @@ mod tests { #[cfg(all(test, feature = "unstable"))] mod benches { use super::Transaction; - use EmptyWrite; - use consensus::{deserialize, Encodable}; + use crate::EmptyWrite; + use crate::consensus::{deserialize, Encodable}; use hashes::hex::FromHex; use test::{black_box, Bencher}; diff --git a/src/consensus/encode.rs b/src/consensus/encode.rs index a2f5bcf538..5b8cdaf42b 100644 --- a/src/consensus/encode.rs +++ b/src/consensus/encode.rs @@ -29,23 +29,23 @@ //! big-endian decimals, etc.) //! -use prelude::*; +use crate::prelude::*; use core::{fmt, mem, u32, convert::From}; #[cfg(feature = "std")] use std::error; -use hashes::{sha256d, Hash}; -use hash_types::{BlockHash, FilterHash, TxMerkleNode, FilterHeader}; +use crate::hashes::{sha256d, Hash}; +use crate::hash_types::{BlockHash, FilterHash, TxMerkleNode, FilterHeader}; -use io::{self, Cursor, Read}; +use crate::io::{self, Cursor, Read}; -use util::endian; -use util::psbt; -use hashes::hex::ToHex; +use crate::util::endian; +use crate::util::psbt; +use crate::hashes::hex::ToHex; -use blockdata::transaction::{TxOut, Transaction, TxIn}; +use crate::blockdata::transaction::{TxOut, Transaction, TxIn}; #[cfg(feature = "std")] -use network::{message_blockdata::Inventory, address::{Address, AddrV2Message}}; +use crate::network::{message_blockdata::Inventory, address::{Address, AddrV2Message}}; /// Encoding error #[derive(Debug)] @@ -86,7 +86,7 @@ pub enum Error { } impl fmt::Display for Error { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { Error::Io(ref e) => write!(f, "I/O error: {}", e), Error::Psbt(ref e) => write!(f, "PSBT error: {}", e), @@ -106,7 +106,7 @@ impl fmt::Display for Error { } #[cfg(feature = "std")] -impl ::std::error::Error for Error { +impl std::error::Error for Error { fn cause(&self) -> Option<&dyn error::Error> { match *self { Error::Io(ref e) => Some(e), @@ -242,7 +242,7 @@ macro_rules! decoder_fn { ($name:ident, $val_type:ty, $readfn:ident, $byte_len: expr) => { #[inline] fn $name(&mut self) -> Result<$val_type, Error> { - debug_assert_eq!(::core::mem::size_of::<$val_type>(), $byte_len); // size_of isn't a constfn in 1.22 + debug_assert_eq!(core::mem::size_of::<$val_type>(), $byte_len); // size_of isn't a constfn in 1.22 let mut val = [0; $byte_len]; self.read_exact(&mut val[..]).map_err(Error::Io)?; Ok(endian::$readfn(&val)) @@ -763,11 +763,11 @@ mod tests { use core::{mem::{self, discriminant}, fmt}; use super::{deserialize, serialize, Error, CheckedData, VarInt}; use super::{Transaction, BlockHash, FilterHash, TxMerkleNode, TxOut, TxIn}; - use consensus::{Encodable, deserialize_partial, Decodable}; - use util::endian::{u64_to_array_le, u32_to_array_le, u16_to_array_le}; + use crate::consensus::{Encodable, deserialize_partial, Decodable}; + use crate::util::endian::{u64_to_array_le, u32_to_array_le, u16_to_array_le}; use secp256k1::rand::{thread_rng, Rng}; #[cfg(feature = "std")] - use network::{Address, message_blockdata::Inventory}; + use crate::network::{Address, message_blockdata::Inventory}; #[test] fn serialize_int_test() { diff --git a/src/consensus/params.rs b/src/consensus/params.rs index b3f62f4542..5545c19315 100644 --- a/src/consensus/params.rs +++ b/src/consensus/params.rs @@ -17,8 +17,8 @@ //! This module provides predefined set of parameters for different chains. //! -use network::constants::Network; -use util::uint::Uint256; +use crate::network::constants::Network; +use crate::util::uint::Uint256; /// Lowest possible difficulty for Mainnet. See comment on Params::pow_limit for more info. const MAX_BITS_BITCOIN: Uint256 = Uint256([ diff --git a/src/hash_types.rs b/src/hash_types.rs index 058106deb8..22616a1bde 100644 --- a/src/hash_types.rs +++ b/src/hash_types.rs @@ -16,7 +16,7 @@ //! to avoid mixing data of the same hash format (like SHA256d) but of different meaning //! (transaction id, block hash etc). -use hashes::{Hash, sha256, sha256d, hash160}; +use crate::hashes::{Hash, sha256, sha256d, hash160}; macro_rules! impl_hashencode { ($hashtype:ident) => { diff --git a/src/internal_macros.rs b/src/internal_macros.rs index 3aaf500859..de31f493f3 100644 --- a/src/internal_macros.rs +++ b/src/internal_macros.rs @@ -83,7 +83,7 @@ macro_rules! impl_array_newtype { pub fn into_bytes(self) -> [$ty; $len] { self.0 } } - impl<'a> ::core::convert::From<&'a [$ty]> for $thing { + impl<'a> core::convert::From<&'a [$ty]> for $thing { fn from(data: &'a [$ty]) -> $thing { assert_eq!(data.len(), $len); let mut ret = [0; $len]; @@ -100,7 +100,7 @@ macro_rules! impl_array_newtype { macro_rules! impl_index_newtype { ($thing:ident, $ty:ty) => { - impl ::core::ops::Index for $thing { + impl core::ops::Index for $thing { type Output = $ty; #[inline] @@ -109,38 +109,38 @@ macro_rules! impl_index_newtype { } } - impl ::core::ops::Index<::core::ops::Range> for $thing { + impl core::ops::Index> for $thing { type Output = [$ty]; #[inline] - fn index(&self, index: ::core::ops::Range) -> &[$ty] { + fn index(&self, index: core::ops::Range) -> &[$ty] { &self.0[index] } } - impl ::core::ops::Index<::core::ops::RangeTo> for $thing { + impl core::ops::Index> for $thing { type Output = [$ty]; #[inline] - fn index(&self, index: ::core::ops::RangeTo) -> &[$ty] { + fn index(&self, index: core::ops::RangeTo) -> &[$ty] { &self.0[index] } } - impl ::core::ops::Index<::core::ops::RangeFrom> for $thing { + impl core::ops::Index> for $thing { type Output = [$ty]; #[inline] - fn index(&self, index: ::core::ops::RangeFrom) -> &[$ty] { + fn index(&self, index: core::ops::RangeFrom) -> &[$ty] { &self.0[index] } } - impl ::core::ops::Index<::core::ops::RangeFull> for $thing { + impl core::ops::Index for $thing { type Output = [$ty]; #[inline] - fn index(&self, _: ::core::ops::RangeFull) -> &[$ty] { + fn index(&self, _: core::ops::RangeFull) -> &[$ty] { &self.0[..] } } @@ -150,16 +150,16 @@ macro_rules! impl_index_newtype { macro_rules! display_from_debug { ($thing:ident) => { - impl ::core::fmt::Display for $thing { - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> Result<(), ::core::fmt::Error> { - ::core::fmt::Debug::fmt(self, f) + impl core::fmt::Display for $thing { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> Result<(), core::fmt::Error> { + core::fmt::Debug::fmt(self, f) } } } } #[cfg(test)] -macro_rules! hex_script (($s:expr) => (<$crate::Script as ::core::str::FromStr>::from_str($s).unwrap())); +macro_rules! hex_script (($s:expr) => (<$crate::Script as core::str::FromStr>::from_str($s).unwrap())); #[cfg(test)] macro_rules! hex_hash (($h:ident, $s:expr) => ($h::from_slice(&<$crate::prelude::Vec as $crate::hashes::hex::FromHex>::from_hex($s).unwrap()).unwrap())); @@ -172,14 +172,14 @@ macro_rules! serde_string_impl { where D: $crate::serde::de::Deserializer<'de>, { - use ::core::fmt::{self, Formatter}; - use ::core::str::FromStr; + use core::fmt::{self, Formatter}; + use core::str::FromStr; struct Visitor; impl<'de> $crate::serde::de::Visitor<'de> for Visitor { type Value = $name; - fn expecting(&self, formatter: &mut Formatter) -> fmt::Result { + fn expecting(&self, formatter: &mut Formatter<'_>) -> fmt::Result { formatter.write_str($expecting) } @@ -232,14 +232,14 @@ macro_rules! serde_struct_human_string_impl { D: $crate::serde::de::Deserializer<'de>, { if deserializer.is_human_readable() { - use ::core::fmt::{self, Formatter}; - use ::core::str::FromStr; + use core::fmt::{self, Formatter}; + use core::str::FromStr; struct Visitor; impl<'de> $crate::serde::de::Visitor<'de> for Visitor { type Value = $name; - fn expecting(&self, formatter: &mut Formatter) -> fmt::Result { + fn expecting(&self, formatter: &mut Formatter<'_>) -> fmt::Result { formatter.write_str($expecting) } @@ -267,7 +267,7 @@ macro_rules! serde_struct_human_string_impl { deserializer.deserialize_str(Visitor) } else { - use ::core::fmt::{self, Formatter}; + use core::fmt::{self, Formatter}; use $crate::serde::de::IgnoredAny; #[allow(non_camel_case_types)] @@ -277,7 +277,7 @@ macro_rules! serde_struct_human_string_impl { impl<'de> $crate::serde::de::Visitor<'de> for EnumVisitor { type Value = Enum; - fn expecting(&self, formatter: &mut Formatter) -> fmt::Result { + fn expecting(&self, formatter: &mut Formatter<'_>) -> fmt::Result { formatter.write_str("a field name") } @@ -308,7 +308,7 @@ macro_rules! serde_struct_human_string_impl { impl<'de> $crate::serde::de::Visitor<'de> for Visitor { type Value = $name; - fn expecting(&self, formatter: &mut Formatter) -> fmt::Result { + fn expecting(&self, formatter: &mut Formatter<'_>) -> fmt::Result { formatter.write_str("a struct") } @@ -415,8 +415,8 @@ macro_rules! serde_struct_human_string_impl { macro_rules! impl_bytes_newtype { ($t:ident, $len:expr) => ( - impl ::core::fmt::LowerHex for $t { - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { + impl core::fmt::LowerHex for $t { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { for &ch in self.0.iter() { write!(f, "{:02x}", ch)?; } @@ -424,23 +424,23 @@ macro_rules! impl_bytes_newtype { } } - impl ::core::fmt::Display for $t { - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { + impl core::fmt::Display for $t { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { fmt::LowerHex::fmt(self, f) } } - impl ::core::fmt::Debug for $t { - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { + impl core::fmt::Debug for $t { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { fmt::LowerHex::fmt(self, f) } } impl $crate::hashes::hex::FromHex for $t { fn from_byte_iter(iter: I) -> Result - where I: ::core::iter::Iterator> + - ::core::iter::ExactSizeIterator + - ::core::iter::DoubleEndedIterator, + where I: core::iter::Iterator> + + core::iter::ExactSizeIterator + + core::iter::DoubleEndedIterator, { if iter.len() == $len { let mut ret = [0; $len]; @@ -454,7 +454,7 @@ macro_rules! impl_bytes_newtype { } } - impl ::core::str::FromStr for $t { + impl core::str::FromStr for $t { type Err = $crate::hashes::hex::Error; fn from_str(s: &str) -> Result { $crate::hashes::hex::FromHex::from_hex(s) @@ -481,7 +481,7 @@ macro_rules! impl_bytes_newtype { impl<'de> $crate::serde::de::Visitor<'de> for HexVisitor { type Value = $t; - fn expecting(&self, formatter: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { + fn expecting(&self, formatter: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { formatter.write_str("an ASCII hex string") } @@ -489,7 +489,7 @@ macro_rules! impl_bytes_newtype { where E: $crate::serde::de::Error, { - if let Ok(hex) = ::core::str::from_utf8(v) { + if let Ok(hex) = core::str::from_utf8(v) { $crate::hashes::hex::FromHex::from_hex(hex).map_err(E::custom) } else { return Err(E::invalid_value($crate::serde::de::Unexpected::Bytes(v), &self)); @@ -511,7 +511,7 @@ macro_rules! impl_bytes_newtype { impl<'de> $crate::serde::de::Visitor<'de> for BytesVisitor { type Value = $t; - fn expecting(&self, formatter: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { + fn expecting(&self, formatter: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { formatter.write_str("a bytestring") } @@ -549,15 +549,15 @@ macro_rules! user_enum { $(#[$doc] $elem),* } - impl ::core::fmt::Display for $name { - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { + impl core::fmt::Display for $name { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { f.pad(match *self { $($name::$elem => $txt),* }) } } - impl ::core::str::FromStr for $name { + impl core::str::FromStr for $name { type Err = $crate::io::Error; #[inline] fn from_str(s: &str) -> Result { @@ -582,13 +582,13 @@ macro_rules! user_enum { where D: $crate::serde::Deserializer<'de>, { - use ::core::fmt::{self, Formatter}; + use core::fmt::{self, Formatter}; struct Visitor; impl<'de> $crate::serde::de::Visitor<'de> for Visitor { type Value = $name; - fn expecting(&self, formatter: &mut Formatter) -> fmt::Result { + fn expecting(&self, formatter: &mut Formatter<'_>) -> fmt::Result { formatter.write_str("an enum value") } diff --git a/src/lib.rs b/src/lib.rs index 5d04b32ad7..74a88091e6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -46,27 +46,15 @@ compile_error!("at least one of the `std` or `no-std` features must be enabled") #[cfg(feature = "no-std")] #[macro_use] extern crate alloc; -#[cfg(feature = "no-std")] -extern crate core2; - -#[cfg(any(feature = "std", test))] -extern crate core; // for Rust 1.29 and no-std tests // Re-exported dependencies. #[macro_use] pub extern crate bitcoin_hashes as hashes; pub extern crate secp256k1; pub extern crate bech32; -#[cfg(feature = "no-std")] -extern crate hashbrown; - #[cfg(feature = "base64")] pub extern crate base64; -#[cfg(feature="bitcoinconsensus")] extern crate bitcoinconsensus; #[cfg(feature = "serde")] #[macro_use] extern crate serde; -#[cfg(all(test, feature = "serde"))] extern crate serde_json; -#[cfg(all(test, feature = "serde"))] extern crate serde_test; -#[cfg(all(test, feature = "serde"))] extern crate bincode; #[cfg(all(test, feature = "unstable"))] extern crate test; #[cfg(target_pointer_width = "16")] @@ -88,31 +76,31 @@ pub mod consensus; pub mod hash_types; pub mod policy; -pub use hash_types::*; -pub use blockdata::block::Block; -pub use blockdata::block::BlockHeader; -pub use blockdata::script::Script; -pub use blockdata::transaction::Transaction; -pub use blockdata::transaction::TxIn; -pub use blockdata::transaction::TxOut; -pub use blockdata::transaction::OutPoint; -pub use blockdata::transaction::SigHashType; -pub use consensus::encode::VarInt; -pub use network::constants::Network; -pub use util::Error; -pub use util::address::Address; -pub use util::address::AddressType; -pub use util::amount::Amount; -pub use util::amount::Denomination; -pub use util::amount::SignedAmount; -pub use util::merkleblock::MerkleBlock; - -pub use util::ecdsa; -pub use util::schnorr; +pub use crate::hash_types::*; +pub use crate::blockdata::block::Block; +pub use crate::blockdata::block::BlockHeader; +pub use crate::blockdata::script::Script; +pub use crate::blockdata::transaction::Transaction; +pub use crate::blockdata::transaction::TxIn; +pub use crate::blockdata::transaction::TxOut; +pub use crate::blockdata::transaction::OutPoint; +pub use crate::blockdata::transaction::SigHashType; +pub use crate::consensus::encode::VarInt; +pub use crate::network::constants::Network; +pub use crate::util::Error; +pub use crate::util::address::Address; +pub use crate::util::address::AddressType; +pub use crate::util::amount::Amount; +pub use crate::util::amount::Denomination; +pub use crate::util::amount::SignedAmount; +pub use crate::util::merkleblock::MerkleBlock; + +pub use crate::util::ecdsa; +pub use crate::util::schnorr; #[deprecated(since = "0.26.1", note = "Please use `ecdsa::PrivateKey` instead")] -pub use util::ecdsa::PrivateKey; +pub use crate::util::ecdsa::PrivateKey; #[deprecated(since = "0.26.1", note = "Please use `ecdsa::PublicKey` instead")] -pub use util::ecdsa::PublicKey; +pub use crate::util::ecdsa::PublicKey; #[cfg(feature = "std")] use std::io; @@ -161,7 +149,7 @@ mod prelude { pub use std::io::sink; #[cfg(not(feature = "std"))] - pub use io_extras::sink; + pub use crate::io_extras::sink; #[cfg(feature = "hashbrown")] pub use hashbrown::HashSet; @@ -175,7 +163,7 @@ mod prelude { #[cfg(all(test, feature = "unstable"))] mod tests { use core::fmt::Arguments; - use io::{IoSlice, Result, Write}; + use crate::io::{IoSlice, Result, Write}; #[derive(Default, Clone, Debug, PartialEq, Eq)] pub struct EmptyWrite; diff --git a/src/network/address.rs b/src/network/address.rs index 5c2600494d..7846c30e90 100644 --- a/src/network/address.rs +++ b/src/network/address.rs @@ -17,14 +17,14 @@ //! This module defines the structures and functions needed to encode //! network addresses in Bitcoin messages. //! -use prelude::*; +use crate::prelude::*; use core::{fmt, iter}; use std::net::{SocketAddr, Ipv6Addr, SocketAddrV4, SocketAddrV6, Ipv4Addr, ToSocketAddrs}; -use io; -use network::constants::ServiceFlags; -use consensus::encode::{self, Decodable, Encodable, VarInt, ReadExt, WriteExt}; +use crate::io; +use crate::network::constants::ServiceFlags; +use crate::consensus::encode::{self, Decodable, Encodable, VarInt, ReadExt, WriteExt}; /// A message which can be sent on the Bitcoin network #[derive(Clone, PartialEq, Eq, Hash)] @@ -107,7 +107,7 @@ impl Decodable for Address { } impl fmt::Debug for Address { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let ipv6 = Ipv6Addr::from(self.address); match ipv6.to_ipv4() { @@ -306,11 +306,11 @@ impl ToSocketAddrs for AddrV2Message { mod test { use core::str::FromStr; use super::{AddrV2Message, AddrV2, Address}; - use network::constants::ServiceFlags; + use crate::network::constants::ServiceFlags; use std::net::{SocketAddr, IpAddr, Ipv4Addr, Ipv6Addr}; - use hashes::hex::FromHex; + use crate::hashes::hex::FromHex; - use consensus::encode::{deserialize, serialize}; + use crate::consensus::encode::{deserialize, serialize}; #[test] fn serialize_address_test() { diff --git a/src/network/constants.rs b/src/network/constants.rs index 0db6e98c44..1989814581 100644 --- a/src/network/constants.rs +++ b/src/network/constants.rs @@ -39,8 +39,8 @@ use core::{fmt, ops, convert::From}; -use io; -use consensus::encode::{self, Encodable, Decodable}; +use crate::io; +use crate::consensus::encode::{self, Encodable, Decodable}; /// Version of the protocol as appearing in network message headers /// This constant is used to signal to other peers which features you support. @@ -184,19 +184,19 @@ impl ServiceFlags { } impl fmt::LowerHex for ServiceFlags { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::LowerHex::fmt(&self.0, f) } } impl fmt::UpperHex for ServiceFlags { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::UpperHex::fmt(&self.0, f) } } impl fmt::Display for ServiceFlags { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let mut flags = *self; if flags == ServiceFlags::NONE { return write!(f, "ServiceFlags(NONE)"); @@ -292,7 +292,7 @@ impl Decodable for ServiceFlags { #[cfg(test)] mod tests { use super::{Network, ServiceFlags}; - use consensus::encode::{deserialize, serialize}; + use crate::consensus::encode::{deserialize, serialize}; #[test] fn serialize_test() { diff --git a/src/network/message.rs b/src/network/message.rs index 51cb7b0b14..991df058f3 100644 --- a/src/network/message.rs +++ b/src/network/message.rs @@ -19,19 +19,19 @@ //! also defines (de)serialization routines for many primitives. //! -use prelude::*; +use crate::prelude::*; use core::{mem, fmt, iter}; -use io; -use blockdata::block; -use blockdata::transaction; -use network::address::{Address, AddrV2Message}; -use network::message_network; -use network::message_blockdata; -use network::message_filter; -use consensus::encode::{CheckedData, Decodable, Encodable, VarInt, MAX_VEC_SIZE}; -use consensus::{encode, serialize}; +use crate::io; +use crate::blockdata::block; +use crate::blockdata::transaction; +use crate::network::address::{Address, AddrV2Message}; +use crate::network::message_network; +use crate::network::message_blockdata; +use crate::network::message_filter; +use crate::consensus::encode::{CheckedData, Decodable, Encodable, VarInt, MAX_VEC_SIZE}; +use crate::consensus::{encode, serialize}; /// The maximum number of [super::message_blockdata::Inventory] items in an `inv` message. /// @@ -62,7 +62,7 @@ impl CommandString { } impl fmt::Display for CommandString { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(self.0.as_ref()) } } @@ -386,17 +386,17 @@ impl Decodable for RawNetworkMessage { mod test { use std::net::Ipv4Addr; use super::{RawNetworkMessage, NetworkMessage, CommandString}; - use network::constants::ServiceFlags; - use consensus::encode::{deserialize, deserialize_partial, serialize}; - use hashes::hex::FromHex; - use hashes::sha256d::Hash; - use hashes::Hash as HashTrait; - use network::address::{Address, AddrV2, AddrV2Message}; + use crate::network::constants::ServiceFlags; + use crate::consensus::encode::{deserialize, deserialize_partial, serialize}; + use crate::hashes::hex::FromHex; + use crate::hashes::sha256d::Hash; + use crate::hashes::Hash as HashTrait; + use crate::network::address::{Address, AddrV2, AddrV2Message}; use super::message_network::{Reject, RejectReason, VersionMessage}; - use network::message_blockdata::{Inventory, GetBlocksMessage, GetHeadersMessage}; - use blockdata::block::{Block, BlockHeader}; - use network::message_filter::{GetCFilters, CFilter, GetCFHeaders, CFHeaders, GetCFCheckpt, CFCheckpt}; - use blockdata::transaction::Transaction; + use crate::network::message_blockdata::{Inventory, GetBlocksMessage, GetHeadersMessage}; + use crate::blockdata::block::{Block, BlockHeader}; + use crate::network::message_filter::{GetCFilters, CFilter, GetCFHeaders, CFHeaders, GetCFCheckpt, CFCheckpt}; + use crate::blockdata::transaction::Transaction; fn hash(slice: [u8;32]) -> Hash { Hash::from_slice(&slice).unwrap() diff --git a/src/network/message_blockdata.rs b/src/network/message_blockdata.rs index 7bf7a67582..8e6d6adc88 100644 --- a/src/network/message_blockdata.rs +++ b/src/network/message_blockdata.rs @@ -18,15 +18,15 @@ //! Bitcoin data (blocks and transactions) around. //! -use prelude::*; +use crate::prelude::*; -use io; +use crate::io; -use hashes::sha256d; +use crate::hashes::sha256d; -use network::constants; -use consensus::encode::{self, Decodable, Encodable}; -use hash_types::{BlockHash, Txid, Wtxid}; +use crate::network::constants; +use crate::consensus::encode::{self, Decodable, Encodable}; +use crate::hash_types::{BlockHash, Txid, Wtxid}; /// An inventory item. #[derive(PartialEq, Eq, Clone, Debug, Copy, Hash, PartialOrd, Ord)] @@ -153,10 +153,9 @@ impl_consensus_encoding!(GetHeadersMessage, version, locator_hashes, stop_hash); mod tests { use super::{Vec, GetHeadersMessage, GetBlocksMessage}; - use hashes::hex::FromHex; + use crate::hashes::hex::FromHex; - use consensus::encode::{deserialize, serialize}; - use core::default::Default; + use crate::consensus::encode::{deserialize, serialize}; #[test] fn getblocks_message_test() { diff --git a/src/network/message_filter.rs b/src/network/message_filter.rs index 56be8b7f49..3196e7391a 100644 --- a/src/network/message_filter.rs +++ b/src/network/message_filter.rs @@ -2,7 +2,7 @@ //! BIP157 Client Side Block Filtering network messages //! -use hash_types::{BlockHash, FilterHash, FilterHeader}; +use crate::hash_types::{BlockHash, FilterHash, FilterHeader}; #[derive(PartialEq, Eq, Clone, Debug)] /// getcfilters message diff --git a/src/network/message_network.rs b/src/network/message_network.rs index 5d96b555f6..a876e06790 100644 --- a/src/network/message_network.rs +++ b/src/network/message_network.rs @@ -18,16 +18,16 @@ //! capabilities //! -use prelude::*; +use crate::prelude::*; -use io; +use crate::io; -use network::address::Address; -use network::constants::{self, ServiceFlags}; -use consensus::{Encodable, Decodable, ReadExt}; -use consensus::encode; -use network::message::CommandString; -use hashes::sha256d; +use crate::network::address::Address; +use crate::network::constants::{self, ServiceFlags}; +use crate::consensus::{Encodable, Decodable, ReadExt}; +use crate::consensus::encode; +use crate::network::message::CommandString; +use crate::hashes::sha256d; /// Some simple messages @@ -148,10 +148,10 @@ impl_consensus_encoding!(Reject, message, ccode, reason, hash); mod tests { use super::VersionMessage; - use hashes::hex::FromHex; - use network::constants::ServiceFlags; + use crate::hashes::hex::FromHex; + use crate::network::constants::ServiceFlags; - use consensus::encode::{deserialize, serialize}; + use crate::consensus::encode::{deserialize, serialize}; #[test] fn version_message_test() { diff --git a/src/network/mod.rs b/src/network/mod.rs index bf7a05f813..b4b7643112 100644 --- a/src/network/mod.rs +++ b/src/network/mod.rs @@ -18,7 +18,7 @@ //! of Bitcoin data and network messages. //! -use io; +use crate::io; use core::fmt; #[cfg(feature = "std")] use std::error; @@ -44,7 +44,7 @@ pub enum Error { } impl fmt::Display for Error { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { Error::Io(ref e) => fmt::Display::fmt(e, f), Error::SocketMutexPoisoned => f.write_str("socket mutex was poisoned"), diff --git a/src/network/stream_reader.rs b/src/network/stream_reader.rs index 80c53a6a8a..b4b58809c6 100644 --- a/src/network/stream_reader.rs +++ b/src/network/stream_reader.rs @@ -20,12 +20,12 @@ //! (like can happen with reading from TCP socket) //! -use prelude::*; +use crate::prelude::*; use core::fmt; -use io::{self, Read}; +use crate::io::{self, Read}; -use consensus::{encode, Decodable}; +use crate::consensus::{encode, Decodable}; /// Struct used to configure stream reader function pub struct StreamReader { @@ -38,7 +38,7 @@ pub struct StreamReader { } impl fmt::Debug for StreamReader { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "StreamReader with buffer_size={} and unparsed content {:?}", self.data.capacity(), self.unparsed) } @@ -85,13 +85,13 @@ impl StreamReader { mod test { use std::thread; use std::time::Duration; - use io::{self, BufReader, Write}; + use crate::io::{self, BufReader, Write}; use std::net::{TcpListener, TcpStream, Shutdown}; use std::thread::JoinHandle; - use network::constants::ServiceFlags; + use crate::network::constants::ServiceFlags; use super::StreamReader; - use network::message::{NetworkMessage, RawNetworkMessage}; + use crate::network::message::{NetworkMessage, RawNetworkMessage}; // First, let's define some byte arrays for sample messages - dumps are taken from live // Bitcoin Core node v0.17.1 with Wireshark @@ -315,10 +315,10 @@ mod test { #[test] fn read_block_from_file_test() { - use io; - use consensus::serialize; - use hashes::hex::FromHex; - use Block; + use crate::io; + use crate::consensus::serialize; + use crate::hashes::hex::FromHex; + use crate::Block; let normal_data = Vec::from_hex("010000004ddccd549d28f385ab457e98d1b11ce80bfea2c5ab93015ade4973e400000000bf4473e53794beae34e64fccc471dace6ae544180816f89591894e0f417a914cd74d6e49ffff001d323b3a7b0201000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0804ffff001d026e04ffffffff0100f2052a0100000043410446ef0102d1ec5240f0d061a4246c1bdef63fc3dbab7733052fbbf0ecd8f41fc26bf049ebb4f9527f374280259e7cfa99c48b0e3f39c51347a19a5819651503a5ac00000000010000000321f75f3139a013f50f315b23b0c9a2b6eac31e2bec98e5891c924664889942260000000049483045022100cb2c6b346a978ab8c61b18b5e9397755cbd17d6eb2fe0083ef32e067fa6c785a02206ce44e613f31d9a6b0517e46f3db1576e9812cc98d159bfdaf759a5014081b5c01ffffffff79cda0945903627c3da1f85fc95d0b8ee3e76ae0cfdc9a65d09744b1f8fc85430000000049483045022047957cdd957cfd0becd642f6b84d82f49b6cb4c51a91f49246908af7c3cfdf4a022100e96b46621f1bffcf5ea5982f88cef651e9354f5791602369bf5a82a6cd61a62501fffffffffe09f5fe3ffbf5ee97a54eb5e5069e9da6b4856ee86fc52938c2f979b0f38e82000000004847304402204165be9a4cbab8049e1af9723b96199bfd3e85f44c6b4c0177e3962686b26073022028f638da23fc003760861ad481ead4099312c60030d4cb57820ce4d33812a5ce01ffffffff01009d966b01000000434104ea1feff861b51fe3f5f8a3b12d0f4712db80e919548a80839fc47c6a21e66d957e9c5d8cd108c7a2d2324bad71f9904ac0ae7336507d785b17a2c115e427a32fac00000000").unwrap(); let cutoff_data = Vec::from_hex("010000004ddccd549d28f385ab457e98d1b11ce80bfea2c5ab93015ade4973e400000000bf4473e53794beae34e64fccc471dace6ae544180816f89591894e0f417a914cd74d6e49ffff001d323b3a7b0201000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0804ffff001d026e04ffffffff0100f2052a0100000043410446ef0102d1ec5240f0d061a4246c1bdef63fc3dbab7733052fbbf0ecd8f41fc26bf049ebb4f9527f374280259e7cfa99c48b0e3f39c51347a19a5819651503a5ac00000000010000000321f75f3139a013f50f315b23b0c9a2b6eac31e2bec98e5891c924664889942260000000049483045022100cb2c6b346a978ab8c61b18b5e9397755cbd17d6eb2fe0083ef32e067fa6c785a02206ce44e613f31d9a6b0517e46f3db1576e9812cc98d159bfdaf759a5014081b5c01ffffffff79cda0945903627c3da1f85fc95d0b8ee3e76ae0cfdc9a65d09744b1f8fc85430000000049483045022047957cdd957cfd0becd642f6b84d82f49b6cb4c51a91f49246908af7c3cfdf4a022100e96b46621f1bffcf5ea5982f88cef651e9354f5791602369bf5a82a6cd61a62501fffffffffe09f5fe3ffbf5ee97a54eb5e5069e9da6b4856ee86fc52938c2f979b0f38e82000000004847304402204165be9a4cbab8049e1af9723b96199bfd3e85f44c6b4c0177e3962686b26073022028f638da23fc003760861ad481ead4099312c60030d4cb57820ce4d33812a5ce01ffffffff01009d966b01000000434104ea1feff861b51fe3f5f8a3b12d0f4712db80e919548a80839fc47c6a21e66d957e9c5d8cd108c7a2d2324bad71f9904ac0ae7336507d785b17a2c115e427a32fac").unwrap(); diff --git a/src/serde_utils.rs b/src/serde_utils.rs index 47e9998a27..cece5cfb06 100644 --- a/src/serde_utils.rs +++ b/src/serde_utils.rs @@ -7,14 +7,14 @@ pub mod btreemap_byte_values { // NOTE: This module can be exactly copied to use with HashMap. - use prelude::*; - use hashes::hex::{FromHex, ToHex}; + use crate::prelude::*; + use crate::hashes::hex::{FromHex, ToHex}; use serde; pub fn serialize(v: &BTreeMap>, s: S) -> Result where S: serde::Serializer, - T: serde::Serialize + ::core::hash::Hash + Eq + Ord, + T: serde::Serialize + core::hash::Hash + Eq + Ord, { use serde::ser::SerializeMap; @@ -33,17 +33,17 @@ pub mod btreemap_byte_values { pub fn deserialize<'de, D, T>(d: D) -> Result>, D::Error> where D: serde::Deserializer<'de>, - T: serde::Deserialize<'de> + ::core::hash::Hash + Eq + Ord, + T: serde::Deserialize<'de> + core::hash::Hash + Eq + Ord, { - use ::core::marker::PhantomData; + use core::marker::PhantomData; struct Visitor(PhantomData); impl<'de, T> serde::de::Visitor<'de> for Visitor where - T: serde::Deserialize<'de> + ::core::hash::Hash + Eq + Ord, + T: serde::Deserialize<'de> + core::hash::Hash + Eq + Ord, { type Value = BTreeMap>; - fn expecting(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { + fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { write!(f, "a map with hexadecimal values") } @@ -74,13 +74,13 @@ pub mod btreemap_as_seq { // NOTE: This module can be exactly copied to use with HashMap. - use prelude::*; + use crate::prelude::*; use serde; pub fn serialize(v: &BTreeMap, s: S) -> Result where S: serde::Serializer, - T: serde::Serialize + ::core::hash::Hash + Eq + Ord, + T: serde::Serialize + core::hash::Hash + Eq + Ord, U: serde::Serialize, { use serde::ser::SerializeSeq; @@ -100,19 +100,19 @@ pub mod btreemap_as_seq { pub fn deserialize<'de, D, T, U>(d: D) -> Result, D::Error> where D: serde::Deserializer<'de>, - T: serde::Deserialize<'de> + ::core::hash::Hash + Eq + Ord, + T: serde::Deserialize<'de> + core::hash::Hash + Eq + Ord, U: serde::Deserialize<'de>, { - use ::core::marker::PhantomData; + use core::marker::PhantomData; struct Visitor(PhantomData<(T, U)>); impl<'de, T, U> serde::de::Visitor<'de> for Visitor where - T: serde::Deserialize<'de> + ::core::hash::Hash + Eq + Ord, + T: serde::Deserialize<'de> + core::hash::Hash + Eq + Ord, U: serde::Deserialize<'de>, { type Value = BTreeMap; - fn expecting(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { + fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { write!(f, "a sequence of pairs") } @@ -143,14 +143,14 @@ pub mod btreemap_as_seq_byte_values { // NOTE: This module can be exactly copied to use with HashMap. - use prelude::*; + use crate::prelude::*; use serde; /// A custom key-value pair type that serialized the bytes as hex. #[derive(Debug, Deserialize)] struct OwnedPair( T, - #[serde(deserialize_with = "::serde_utils::hex_bytes::deserialize")] + #[serde(deserialize_with = "crate::serde_utils::hex_bytes::deserialize")] Vec, ); @@ -158,14 +158,14 @@ pub mod btreemap_as_seq_byte_values { #[derive(Debug, Serialize)] struct BorrowedPair<'a, T: 'static>( &'a T, - #[serde(serialize_with = "::serde_utils::hex_bytes::serialize")] + #[serde(serialize_with = "crate::serde_utils::hex_bytes::serialize")] &'a [u8], ); pub fn serialize(v: &BTreeMap>, s: S) -> Result where S: serde::Serializer, - T: serde::Serialize + ::core::hash::Hash + Eq + Ord + 'static, + T: serde::Serialize + core::hash::Hash + Eq + Ord + 'static, { use serde::ser::SerializeSeq; @@ -184,17 +184,17 @@ pub mod btreemap_as_seq_byte_values { pub fn deserialize<'de, D, T>(d: D) -> Result>, D::Error> where D: serde::Deserializer<'de>, - T: serde::Deserialize<'de> + ::core::hash::Hash + Eq + Ord, + T: serde::Deserialize<'de> + core::hash::Hash + Eq + Ord, { - use ::core::marker::PhantomData; + use core::marker::PhantomData; struct Visitor(PhantomData); impl<'de, T> serde::de::Visitor<'de> for Visitor where - T: serde::Deserialize<'de> + ::core::hash::Hash + Eq + Ord, + T: serde::Deserialize<'de> + core::hash::Hash + Eq + Ord, { type Value = BTreeMap>; - fn expecting(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { + fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { write!(f, "a sequence of pairs") } @@ -222,7 +222,7 @@ pub mod hex_bytes { //! Module for serialization of byte arrays as hex strings. #![allow(missing_docs)] - use hashes::hex::{FromHex, ToHex}; + use crate::hashes::hex::{FromHex, ToHex}; use serde; pub fn serialize(bytes: &T, s: S) -> Result @@ -239,19 +239,19 @@ pub mod hex_bytes { pub fn deserialize<'de, D, B>(d: D) -> Result where D: serde::Deserializer<'de>, B: serde::Deserialize<'de> + FromHex, { - struct Visitor(::core::marker::PhantomData); + struct Visitor(core::marker::PhantomData); impl<'de, B: FromHex> serde::de::Visitor<'de> for Visitor { type Value = B; - fn expecting(&self, formatter: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { + fn expecting(&self, formatter: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { formatter.write_str("an ASCII hex string") } fn visit_bytes(self, v: &[u8]) -> Result where E: serde::de::Error, { - if let Ok(hex) = ::core::str::from_utf8(v) { + if let Ok(hex) = core::str::from_utf8(v) { FromHex::from_hex(hex).map_err(E::custom) } else { return Err(E::invalid_value(serde::de::Unexpected::Bytes(v), &self)); @@ -269,7 +269,7 @@ pub mod hex_bytes { if !d.is_human_readable() { serde::Deserialize::deserialize(d) } else { - d.deserialize_str(Visitor(::core::marker::PhantomData)) + d.deserialize_str(Visitor(core::marker::PhantomData)) } } } diff --git a/src/util/address.rs b/src/util/address.rs index a3d08dda85..86d125be18 100644 --- a/src/util/address.rs +++ b/src/util/address.rs @@ -33,19 +33,19 @@ //! let address = Address::p2pkh(&public_key, Network::Bitcoin); //! ``` -use prelude::*; +use crate::prelude::*; use core::fmt; use core::str::FromStr; #[cfg(feature = "std")] use std::error; use bech32; -use hashes::Hash; -use hash_types::{PubkeyHash, WPubkeyHash, ScriptHash, WScriptHash}; -use blockdata::script; -use network::constants::Network; -use util::base58; -use util::ecdsa; +use crate::hashes::Hash; +use crate::hash_types::{PubkeyHash, WPubkeyHash, ScriptHash, WScriptHash}; +use crate::blockdata::script; +use crate::network::constants::Network; +use crate::util::base58; +use crate::util::ecdsa; /// Address error. #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone)] @@ -67,7 +67,7 @@ pub enum Error { } impl fmt::Display for Error { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { Error::Base58(ref e) => write!(f, "base58: {}", e), Error::Bech32(ref e) => write!(f, "bech32: {}", e), @@ -87,7 +87,7 @@ impl fmt::Display for Error { } #[cfg(feature = "std")] -impl ::std::error::Error for Error { +impl std::error::Error for Error { fn cause(&self) -> Option<&dyn error::Error> { match *self { Error::Base58(ref e) => Some(e), @@ -125,7 +125,7 @@ pub enum AddressType { } impl fmt::Display for AddressType { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(match *self { AddressType::P2pkh => "p2pkh", AddressType::P2sh => "p2sh", @@ -372,7 +372,7 @@ impl Address { // Alternate formatting `{:#}` is used to return uppercase version of bech32 addresses which should // be used in QR codes, see [Address::to_qr_uri] impl fmt::Display for Address { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { match self.payload { Payload::PubkeyHash(ref hash) => { let mut prefixed = [0; 21]; @@ -528,7 +528,7 @@ impl FromStr for Address { } impl fmt::Debug for Address { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}", self.to_string()) } } @@ -537,11 +537,11 @@ impl fmt::Debug for Address { mod tests { use core::str::FromStr; - use hashes::hex::{FromHex, ToHex}; + use crate::hashes::hex::{FromHex, ToHex}; - use blockdata::script::Script; - use network::constants::Network::{Bitcoin, Testnet}; - use util::ecdsa::PublicKey; + use crate::blockdata::script::Script; + use crate::network::constants::Network::{Bitcoin, Testnet}; + use crate::util::ecdsa::PublicKey; use super::*; diff --git a/src/util/amount.rs b/src/util/amount.rs index 777501f064..f1fdf8ec62 100644 --- a/src/util/amount.rs +++ b/src/util/amount.rs @@ -14,9 +14,9 @@ //! We refer to the documentation on the types for more information. //! -use prelude::*; +use crate::prelude::*; -use core::{ops, default, str::FromStr, cmp::Ordering}; +use core::{ops, str::FromStr, cmp::Ordering}; use core::fmt::{self, Write}; /// A set of denominations in which amounts can be expressed. @@ -51,7 +51,7 @@ impl Denomination { } impl fmt::Display for Denomination { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(match *self { Denomination::Bitcoin => "BTC", Denomination::MilliBitcoin => "mBTC", @@ -100,7 +100,7 @@ pub enum ParseAmountError { } impl fmt::Display for ParseAmountError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { ParseAmountError::Negative => f.write_str("amount is negative"), ParseAmountError::TooBig => f.write_str("amount is too big"), @@ -114,7 +114,7 @@ impl fmt::Display for ParseAmountError { } #[cfg(feature = "std")] -impl ::std::error::Error for ParseAmountError {} +impl std::error::Error for ParseAmountError {} fn is_too_precise(s: &str, precision: usize) -> bool { s.contains('.') || precision >= s.len() || s.chars().rev().take(precision).any(|d| d != '0') @@ -424,14 +424,14 @@ impl Amount { } } -impl default::Default for Amount { +impl Default for Amount { fn default() -> Self { Amount::ZERO } } impl fmt::Debug for Amount { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "Amount({:.8} BTC)", self.as_btc()) } } @@ -439,7 +439,7 @@ impl fmt::Debug for Amount { // No one should depend on a binding contract for Display for this type. // Just using Bitcoin denominated string. impl fmt::Display for Amount { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.fmt_value_in(f, Denomination::Bitcoin)?; write!(f, " {}", Denomination::Bitcoin) } @@ -749,14 +749,14 @@ impl SignedAmount { } } -impl default::Default for SignedAmount { +impl Default for SignedAmount { fn default() -> Self { SignedAmount::ZERO } } impl fmt::Debug for SignedAmount { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "SignedAmount({:.8} BTC)", self.as_btc()) } } @@ -764,7 +764,7 @@ impl fmt::Debug for SignedAmount { // No one should depend on a binding contract for Display for this type. // Just using Bitcoin denominated string. impl fmt::Display for SignedAmount { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.fmt_value_in(f, Denomination::Bitcoin)?; write!(f, " {}", Denomination::Bitcoin) } @@ -870,7 +870,7 @@ pub mod serde { //! ``` use serde::{Deserialize, Deserializer, Serialize, Serializer}; - use util::amount::{Amount, Denomination, SignedAmount}; + use crate::util::amount::{Amount, Denomination, SignedAmount}; /// This trait is used only to avoid code duplication and naming collisions /// of the different serde serialization crates. @@ -959,7 +959,7 @@ pub mod serde { //! Use with `#[serde(with = "amount::serde::as_sat")]`. use serde::{Deserializer, Serializer}; - use util::amount::serde::SerdeAmount; + use crate::util::amount::serde::SerdeAmount; pub fn serialize(a: &A, s: S) -> Result { a.ser_sat(s) @@ -974,7 +974,7 @@ pub mod serde { //! Use with `#[serde(default, with = "amount::serde::as_sat::opt")]`. use serde::{Deserializer, Serializer, de}; - use util::amount::serde::SerdeAmountForOpt; + use crate::util::amount::serde::SerdeAmountForOpt; use core::fmt; use core::marker::PhantomData; @@ -996,7 +996,7 @@ pub mod serde { impl<'de, X: SerdeAmountForOpt> de::Visitor<'de> for VisitOptAmt { type Value = Option; - fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { write!(formatter, "An Option<{}64>", X::type_prefix()) } @@ -1022,7 +1022,7 @@ pub mod serde { //! Use with `#[serde(with = "amount::serde::as_btc")]`. use serde::{Deserializer, Serializer}; - use util::amount::serde::SerdeAmount; + use crate::util::amount::serde::SerdeAmount; pub fn serialize(a: &A, s: S) -> Result { a.ser_btc(s) @@ -1037,7 +1037,7 @@ pub mod serde { //! Use with `#[serde(default, with = "amount::serde::as_btc::opt")]`. use serde::{Deserializer, Serializer, de}; - use util::amount::serde::SerdeAmountForOpt; + use crate::util::amount::serde::SerdeAmountForOpt; use core::fmt; use core::marker::PhantomData; @@ -1059,7 +1059,7 @@ pub mod serde { impl<'de, X :SerdeAmountForOpt> de::Visitor<'de> for VisitOptAmt { type Value = Option; - fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { write!(formatter, "An Option") } @@ -1372,9 +1372,9 @@ mod tests { #[derive(Serialize, Deserialize, PartialEq, Debug)] struct T { - #[serde(with = "::util::amount::serde::as_sat")] + #[serde(with = "crate::util::amount::serde::as_sat")] pub amt: Amount, - #[serde(with = "::util::amount::serde::as_sat")] + #[serde(with = "crate::util::amount::serde::as_sat")] pub samt: SignedAmount, } @@ -1404,9 +1404,9 @@ mod tests { #[derive(Serialize, Deserialize, PartialEq, Debug)] struct T { - #[serde(with = "::util::amount::serde::as_btc")] + #[serde(with = "crate::util::amount::serde::as_btc")] pub amt: Amount, - #[serde(with = "::util::amount::serde::as_btc")] + #[serde(with = "crate::util::amount::serde::as_btc")] pub samt: SignedAmount, } @@ -1438,9 +1438,9 @@ mod tests { #[derive(Serialize, Deserialize, PartialEq, Debug, Eq)] struct T { - #[serde(default, with = "::util::amount::serde::as_btc::opt")] + #[serde(default, with = "crate::util::amount::serde::as_btc::opt")] pub amt: Option, - #[serde(default, with = "::util::amount::serde::as_btc::opt")] + #[serde(default, with = "crate::util::amount::serde::as_btc::opt")] pub samt: Option, } @@ -1481,9 +1481,9 @@ mod tests { #[derive(Serialize, Deserialize, PartialEq, Debug, Eq)] struct T { - #[serde(default, with = "::util::amount::serde::as_sat::opt")] + #[serde(default, with = "crate::util::amount::serde::as_sat::opt")] pub amt: Option, - #[serde(default, with = "::util::amount::serde::as_sat::opt")] + #[serde(default, with = "crate::util::amount::serde::as_sat::opt")] pub samt: Option, } diff --git a/src/util/base58.rs b/src/util/base58.rs index 8d2c7279f3..5a902ed24c 100644 --- a/src/util/base58.rs +++ b/src/util/base58.rs @@ -14,14 +14,14 @@ //! Base58 encoder and decoder -use prelude::*; +use crate::prelude::*; use core::{fmt, str, iter, slice}; -use hashes::{sha256d, Hash}; +use crate::hashes::{sha256d, Hash}; use secp256k1; -use util::{endian, key}; +use crate::util::{endian, key}; /// An error that might occur during base58 decoding #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone)] @@ -45,7 +45,7 @@ pub enum Error { } impl fmt::Display for Error { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { Error::BadByte(b) => write!(f, "invalid base58 character 0x{:x}", b), Error::BadChecksum(exp, actual) => write!(f, "base58ck checksum 0x{:x} does not match expected 0x{:x}", actual, exp), @@ -59,7 +59,7 @@ impl fmt::Display for Error { } #[cfg(feature = "std")] -impl ::std::error::Error for Error {} +impl std::error::Error for Error {} /// Vector-like object that holds the first 100 elements on the stack. If more space is needed it /// will be allocated on the heap. @@ -87,12 +87,12 @@ impl SmallVec { } } - pub fn iter(&self) -> iter::Chain, slice::Iter> { + pub fn iter(&self) -> iter::Chain, slice::Iter<'_, T>> { // If len<100 then we just append an empty vec self.stack[0..self.len].iter().chain(self.heap.iter()) } - pub fn iter_mut(&mut self) -> iter::Chain, slice::IterMut> { + pub fn iter_mut(&mut self) -> iter::Chain, slice::IterMut<'_, T>> { // If len<100 then we just append an empty vec self.stack[0..self.len].iter_mut().chain(self.heap.iter_mut()) } @@ -236,7 +236,7 @@ pub fn check_encode_slice(data: &[u8]) -> String { /// Obtain a string with the base58check encoding of a slice /// (Tack the first 4 256-digits of the object's Bitcoin hash onto the end.) -pub fn check_encode_slice_to_fmt(fmt: &mut fmt::Formatter, data: &[u8]) -> fmt::Result { +pub fn check_encode_slice_to_fmt(fmt: &mut fmt::Formatter<'_>, data: &[u8]) -> fmt::Result { let checksum = sha256d::Hash::hash(&data); let iter = data.iter() .cloned() @@ -257,7 +257,7 @@ impl From for Error { #[cfg(test)] mod tests { use super::*; - use hashes::hex::FromHex; + use crate::hashes::hex::FromHex; #[test] fn test_base58_encode() { diff --git a/src/util/bip143.rs b/src/util/bip143.rs index 963a3c3b11..0d29a1fd16 100644 --- a/src/util/bip143.rs +++ b/src/util/bip143.rs @@ -19,15 +19,15 @@ //! signatures, which are placed in the scriptSig. //! -use hashes::{Hash, sha256d}; -use hash_types::SigHash; -use blockdata::script::Script; -use blockdata::transaction::{Transaction, TxIn, SigHashType}; -use consensus::{encode, Encodable}; +use crate::hashes::{Hash, sha256d}; +use crate::hash_types::SigHash; +use crate::blockdata::script::Script; +use crate::blockdata::transaction::{Transaction, TxIn, SigHashType}; +use crate::consensus::{encode, Encodable}; -use prelude::*; +use crate::prelude::*; -use io; +use crate::io; use core::ops::{Deref, DerefMut}; /// Parts of a sighash which are common across inputs or signatures, and which are @@ -270,14 +270,14 @@ impl> SigHashCache { #[cfg(test)] #[allow(deprecated)] mod tests { - use hash_types::SigHash; - use blockdata::script::Script; - use blockdata::transaction::Transaction; - use consensus::encode::deserialize; - use network::constants::Network; - use util::address::Address; - use util::ecdsa::PublicKey; - use hashes::hex::FromHex; + use crate::hash_types::SigHash; + use crate::blockdata::script::Script; + use crate::blockdata::transaction::Transaction; + use crate::consensus::encode::deserialize; + use crate::network::constants::Network; + use crate::util::address::Address; + use crate::util::ecdsa::PublicKey; + use crate::hashes::hex::FromHex; use super::*; diff --git a/src/util/bip158.rs b/src/util/bip158.rs index 33eecca52d..4f9de89695 100644 --- a/src/util/bip158.rs +++ b/src/util/bip158.rs @@ -45,21 +45,21 @@ //! ``` //! -use prelude::*; +use crate::prelude::*; -use io::{self as io, Cursor}; +use crate::io::{self as io, Cursor}; use core::fmt::{self, Display, Formatter}; use core::cmp::{self, Ordering}; -use hashes::{Hash, siphash24}; -use hash_types::{BlockHash, FilterHash, FilterHeader}; +use crate::hashes::{Hash, siphash24}; +use crate::hash_types::{BlockHash, FilterHash, FilterHeader}; -use blockdata::block::Block; -use blockdata::script::Script; -use blockdata::transaction::OutPoint; -use consensus::{Decodable, Encodable}; -use consensus::encode::VarInt; -use util::endian; +use crate::blockdata::block::Block; +use crate::blockdata::script::Script; +use crate::blockdata::transaction::OutPoint; +use crate::consensus::{Decodable, Encodable}; +use crate::consensus::encode::VarInt; +use crate::util::endian; /// Golomb encoding parameter as in BIP-158, see also https://gist.github.com/sipa/576d5f09c3b86c3b1b75598d799fc845 const P: u8 = 19; @@ -75,10 +75,10 @@ pub enum Error { } #[cfg(feature = "std")] -impl ::std::error::Error for Error {} +impl std::error::Error for Error {} impl Display for Error { - fn fmt(&self, f: &mut Formatter) -> Result<(), fmt::Error> { + fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), fmt::Error> { match *self { Error::UtxoMissing(ref coin) => write!(f, "unresolved UTXO {}", coin), Error::Io(ref io) => write!(f, "{}", io) @@ -393,7 +393,7 @@ impl GCSFilter { } /// Golomb-Rice encode a number n to a bit stream (Parameter 2^k) - fn golomb_rice_encode(&self, writer: &mut BitStreamWriter, n: u64) -> Result { + fn golomb_rice_encode(&self, writer: &mut BitStreamWriter<'_>, n: u64) -> Result { let mut wrote = 0; let mut q = n >> self.p; while q > 0 { @@ -407,7 +407,7 @@ impl GCSFilter { } /// Golomb-Rice decode a number from a bit stream (Parameter 2^k) - fn golomb_rice_decode(&self, reader: &mut BitStreamReader) -> Result { + fn golomb_rice_decode(&self, reader: &mut BitStreamReader<'_>) -> Result { let mut q = 0u64; while reader.read(1)? == 1 { q += 1; @@ -431,7 +431,7 @@ pub struct BitStreamReader<'a> { impl<'a> BitStreamReader<'a> { /// Create a new BitStreamReader that reads bitwise from a given reader - pub fn new(reader: &'a mut dyn io::Read) -> BitStreamReader { + pub fn new(reader: &'a mut dyn io::Read) -> BitStreamReader<'_> { BitStreamReader { buffer: [0u8], reader: reader, @@ -469,7 +469,7 @@ pub struct BitStreamWriter<'a> { impl<'a> BitStreamWriter<'a> { /// Create a new BitStreamWriter that writes bitwise to a given writer - pub fn new(writer: &'a mut dyn io::Write) -> BitStreamWriter { + pub fn new(writer: &'a mut dyn io::Write) -> BitStreamWriter<'_> { BitStreamWriter { buffer: [0u8], writer: writer, @@ -510,17 +510,17 @@ impl<'a> BitStreamWriter<'a> { #[cfg(test)] mod test { - use io::Cursor; + use crate::io::Cursor; - use hash_types::BlockHash; - use hashes::hex::FromHex; + use crate::hash_types::BlockHash; + use crate::hashes::hex::FromHex; use super::*; - extern crate serde_json; + use serde_json; use self::serde_json::{Value}; - use consensus::encode::deserialize; + use crate::consensus::encode::deserialize; use std::collections::HashMap; #[test] diff --git a/src/util/bip32.rs b/src/util/bip32.rs index 1e663aabd2..149c0f38fc 100644 --- a/src/util/bip32.rs +++ b/src/util/bip32.rs @@ -16,19 +16,19 @@ //! Implementation of BIP32 hierarchical deterministic wallets, as defined //! at -use prelude::*; +use crate::prelude::*; -use core::{fmt, str::FromStr, default::Default}; +use core::{fmt, str::FromStr}; #[cfg(feature = "std")] use std::error; #[cfg(feature = "serde")] use serde; -use hash_types::XpubIdentifier; -use hashes::{sha512, Hash, HashEngine, Hmac, HmacEngine}; +use crate::hash_types::XpubIdentifier; +use crate::hashes::{sha512, Hash, HashEngine, Hmac, HmacEngine}; use secp256k1::{self, Secp256k1}; -use network::constants::Network; -use util::{base58, endian, key}; -use util::ecdsa::{PublicKey, PrivateKey}; +use crate::network::constants::Network; +use crate::util::{base58, endian, key}; +use crate::util::ecdsa::{PublicKey, PrivateKey}; /// A chain code #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] @@ -168,7 +168,7 @@ impl From for u32 { } impl fmt::Display for ChildNumber { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { ChildNumber::Hardened { index } => { fmt::Display::fmt(&index, f)?; @@ -268,13 +268,13 @@ impl<'a> From<&'a [ChildNumber]> for DerivationPath { } } -impl ::core::iter::FromIterator for DerivationPath { +impl core::iter::FromIterator for DerivationPath { fn from_iter(iter: T) -> Self where T: IntoIterator { DerivationPath(Vec::from_iter(iter)) } } -impl<'a> ::core::iter::IntoIterator for &'a DerivationPath { +impl<'a> core::iter::IntoIterator for &'a DerivationPath { type Item = &'a ChildNumber; type IntoIter = slice::Iter<'a, ChildNumber>; fn into_iter(self) -> Self::IntoIter { @@ -365,17 +365,17 @@ impl DerivationPath { /// Get an [Iterator] over the children of this [DerivationPath] /// starting with the given [ChildNumber]. - pub fn children_from(&self, cn: ChildNumber) -> DerivationPathIterator { + pub fn children_from(&self, cn: ChildNumber) -> DerivationPathIterator<'_> { DerivationPathIterator::start_from(&self, cn) } /// Get an [Iterator] over the unhardened children of this [DerivationPath]. - pub fn normal_children(&self) -> DerivationPathIterator { + pub fn normal_children(&self) -> DerivationPathIterator<'_> { DerivationPathIterator::start_from(&self, ChildNumber::Normal{ index: 0 }) } /// Get an [Iterator] over the hardened children of this [DerivationPath]. - pub fn hardened_children(&self) -> DerivationPathIterator { + pub fn hardened_children(&self) -> DerivationPathIterator<'_> { DerivationPathIterator::start_from(&self, ChildNumber::Hardened{ index: 0 }) } @@ -403,7 +403,7 @@ impl DerivationPath { } impl fmt::Display for DerivationPath { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str("m")?; for cn in self.0.iter() { f.write_str("/")?; @@ -414,7 +414,7 @@ impl fmt::Display for DerivationPath { } impl fmt::Debug for DerivationPath { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Display::fmt(&self, f) } } @@ -445,7 +445,7 @@ pub enum Error { } impl fmt::Display for Error { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { Error::CannotDeriveFromHardenedKey => f.write_str("cannot derive hardened key from public key"), Error::Ecdsa(ref e) => fmt::Display::fmt(e, f), @@ -725,7 +725,7 @@ impl ExtendedPubKey { } impl fmt::Display for ExtendedPrivKey { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { base58::check_encode_slice_to_fmt(fmt, &self.encode()[..]) } } @@ -745,7 +745,7 @@ impl FromStr for ExtendedPrivKey { } impl fmt::Display for ExtendedPubKey { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { base58::check_encode_slice_to_fmt(fmt, &self.encode()[..]) } } @@ -772,9 +772,9 @@ mod tests { use core::str::FromStr; use secp256k1::{self, Secp256k1}; - use hashes::hex::FromHex; + use crate::hashes::hex::FromHex; - use network::constants::Network::{self, Bitcoin}; + use crate::network::constants::Network::{self, Bitcoin}; #[test] fn test_parse_derivation_path() { diff --git a/src/util/contracthash.rs b/src/util/contracthash.rs index 29e0e90547..5902446554 100644 --- a/src/util/contracthash.rs +++ b/src/util/contracthash.rs @@ -20,20 +20,20 @@ #![cfg_attr(not(test), deprecated)] -use prelude::*; +use crate::prelude::*; use core::fmt; #[cfg(feature = "std")] use std::error; use secp256k1::{self, Secp256k1}; -use PrivateKey; -use PublicKey; -use hashes::{sha256, Hash, HashEngine, Hmac, HmacEngine}; -use blockdata::{opcodes, script}; +use crate::PrivateKey; +use crate::PublicKey; +use crate::hashes::{sha256, Hash, HashEngine, Hmac, HmacEngine}; +use crate::blockdata::{opcodes, script}; -use hash_types::ScriptHash; -use network::constants::Network; -use util::address; +use crate::hash_types::ScriptHash; +use crate::network::constants::Network; +use crate::util::address; /// Encoding of "pubkey here" in script; from Bitcoin Core `src/script/script.h` static PUBKEY: u8 = 0xFE; @@ -61,7 +61,7 @@ pub enum Error { } impl fmt::Display for Error { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { Error::Secp(ref e) => fmt::Display::fmt(&e, f), Error::Script(ref e) => fmt::Display::fmt(&e, f), @@ -75,7 +75,7 @@ impl fmt::Display for Error { } #[cfg(feature = "std")] -impl ::std::error::Error for Error { +impl std::error::Error for Error { fn cause(&self) -> Option<&dyn error::Error> { match *self { Error::Secp(ref e) => Some(e), @@ -280,15 +280,15 @@ pub fn untemplate(script: &script::Script) -> Result<(Template, Vec), #[cfg(test)] mod tests { use secp256k1::Secp256k1; - use hashes::hex::FromHex; + use crate::hashes::hex::FromHex; use secp256k1::rand::thread_rng; use core::str::FromStr; - use blockdata::script::Script; - use network::constants::Network; + use crate::blockdata::script::Script; + use crate::network::constants::Network; use super::*; - use PublicKey; + use crate::PublicKey; macro_rules! hex (($hex:expr) => (Vec::from_hex($hex).unwrap())); macro_rules! hex_key (($hex:expr) => (PublicKey::from_slice(&hex!($hex)).unwrap())); diff --git a/src/util/ecdsa.rs b/src/util/ecdsa.rs index 9e8589f85b..e657a139b4 100644 --- a/src/util/ecdsa.rs +++ b/src/util/ecdsa.rs @@ -16,18 +16,18 @@ //! ECDSA keys used in Bitcoin that can be roundtrip (de)serialized. //! -use prelude::*; +use crate::prelude::*; use core::{ops, str::FromStr}; use core::fmt::{self, Write as _fmtWrite}; -use io; +use crate::io; use secp256k1::{self, Secp256k1}; -use network::constants::Network; -use hashes::{Hash, hash160}; -use hash_types::{PubkeyHash, WPubkeyHash}; -use util::base58; -use util::key::Error; +use crate::network::constants::Network; +use crate::hashes::{Hash, hash160}; +use crate::hash_types::{PubkeyHash, WPubkeyHash}; +use crate::util::base58; +use crate::util::key::Error; /// A Bitcoin ECDSA public key #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] @@ -143,7 +143,7 @@ impl PublicKey { } impl fmt::Display for PublicKey { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { if self.compressed { for ch in &self.key.serialize()[..] { write!(f, "{:02x}", ch)?; @@ -271,13 +271,13 @@ impl PrivateKey { } impl fmt::Display for PrivateKey { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.fmt_wif(f) } } impl fmt::Debug for PrivateKey { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "[private key data]") } } @@ -297,38 +297,38 @@ impl ops::Index for PrivateKey { } #[cfg(feature = "serde")] -impl ::serde::Serialize for PrivateKey { - fn serialize(&self, s: S) -> Result { +impl serde::Serialize for PrivateKey { + fn serialize(&self, s: S) -> Result { s.collect_str(self) } } #[cfg(feature = "serde")] -impl<'de> ::serde::Deserialize<'de> for PrivateKey { - fn deserialize>(d: D) -> Result { +impl<'de> serde::Deserialize<'de> for PrivateKey { + fn deserialize>(d: D) -> Result { struct WifVisitor; - impl<'de> ::serde::de::Visitor<'de> for WifVisitor { + impl<'de> serde::de::Visitor<'de> for WifVisitor { type Value = PrivateKey; - fn expecting(&self, formatter: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { + fn expecting(&self, formatter: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { formatter.write_str("an ASCII WIF string") } fn visit_bytes(self, v: &[u8]) -> Result where - E: ::serde::de::Error, + E: serde::de::Error, { - if let Ok(s) = ::core::str::from_utf8(v) { + if let Ok(s) = core::str::from_utf8(v) { PrivateKey::from_str(s).map_err(E::custom) } else { - Err(E::invalid_value(::serde::de::Unexpected::Bytes(v), &self)) + Err(E::invalid_value(serde::de::Unexpected::Bytes(v), &self)) } } fn visit_str(self, v: &str) -> Result where - E: ::serde::de::Error, + E: serde::de::Error, { PrivateKey::from_str(v).map_err(E::custom) } @@ -339,8 +339,8 @@ impl<'de> ::serde::Deserialize<'de> for PrivateKey { } #[cfg(feature = "serde")] -impl ::serde::Serialize for PublicKey { - fn serialize(&self, s: S) -> Result { +impl serde::Serialize for PublicKey { + fn serialize(&self, s: S) -> Result { if s.is_human_readable() { s.collect_str(self) } else { @@ -354,32 +354,32 @@ impl ::serde::Serialize for PublicKey { } #[cfg(feature = "serde")] -impl<'de> ::serde::Deserialize<'de> for PublicKey { - fn deserialize>(d: D) -> Result { +impl<'de> serde::Deserialize<'de> for PublicKey { + fn deserialize>(d: D) -> Result { if d.is_human_readable() { struct HexVisitor; - impl<'de> ::serde::de::Visitor<'de> for HexVisitor { + impl<'de> serde::de::Visitor<'de> for HexVisitor { type Value = PublicKey; - fn expecting(&self, formatter: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { + fn expecting(&self, formatter: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { formatter.write_str("an ASCII hex string") } fn visit_bytes(self, v: &[u8]) -> Result where - E: ::serde::de::Error, + E: serde::de::Error, { - if let Ok(hex) = ::core::str::from_utf8(v) { + if let Ok(hex) = core::str::from_utf8(v) { PublicKey::from_str(hex).map_err(E::custom) } else { - Err(E::invalid_value(::serde::de::Unexpected::Bytes(v), &self)) + Err(E::invalid_value(serde::de::Unexpected::Bytes(v), &self)) } } fn visit_str(self, v: &str) -> Result where - E: ::serde::de::Error, + E: serde::de::Error, { PublicKey::from_str(v).map_err(E::custom) } @@ -388,16 +388,16 @@ impl<'de> ::serde::Deserialize<'de> for PublicKey { } else { struct BytesVisitor; - impl<'de> ::serde::de::Visitor<'de> for BytesVisitor { + impl<'de> serde::de::Visitor<'de> for BytesVisitor { type Value = PublicKey; - fn expecting(&self, formatter: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { + fn expecting(&self, formatter: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { formatter.write_str("a bytestring") } fn visit_bytes(self, v: &[u8]) -> Result where - E: ::serde::de::Error, + E: serde::de::Error, { PublicKey::from_slice(v).map_err(E::custom) } @@ -410,14 +410,14 @@ impl<'de> ::serde::Deserialize<'de> for PublicKey { #[cfg(test)] mod tests { - use io; + use crate::io; use super::{PrivateKey, PublicKey}; use secp256k1::Secp256k1; use std::str::FromStr; - use hashes::hex::ToHex; - use network::constants::Network::Testnet; - use network::constants::Network::Bitcoin; - use util::address::Address; + use crate::hashes::hex::ToHex; + use crate::network::constants::Network::Testnet; + use crate::network::constants::Network::Bitcoin; + use crate::util::address::Address; #[test] fn test_key_derivation() { diff --git a/src/util/endian.rs b/src/util/endian.rs index f09a123780..800c3e33c8 100644 --- a/src/util/endian.rs +++ b/src/util/endian.rs @@ -2,10 +2,10 @@ macro_rules! define_slice_to_be { ($name: ident, $type: ty) => { #[inline] pub fn $name(slice: &[u8]) -> $type { - assert_eq!(slice.len(), ::core::mem::size_of::<$type>()); + assert_eq!(slice.len(), core::mem::size_of::<$type>()); let mut res = 0; - for i in 0..::core::mem::size_of::<$type>() { - res |= (slice[i] as $type) << (::core::mem::size_of::<$type>() - i - 1)*8; + for i in 0..core::mem::size_of::<$type>() { + res |= (slice[i] as $type) << (core::mem::size_of::<$type>() - i - 1)*8; } res } @@ -15,9 +15,9 @@ macro_rules! define_slice_to_le { ($name: ident, $type: ty) => { #[inline] pub fn $name(slice: &[u8]) -> $type { - assert_eq!(slice.len(), ::core::mem::size_of::<$type>()); + assert_eq!(slice.len(), core::mem::size_of::<$type>()); let mut res = 0; - for i in 0..::core::mem::size_of::<$type>() { + for i in 0..core::mem::size_of::<$type>() { res |= (slice[i] as $type) << i*8; } res @@ -28,7 +28,7 @@ macro_rules! define_be_to_array { ($name: ident, $type: ty, $byte_len: expr) => { #[inline] pub fn $name(val: $type) -> [u8; $byte_len] { - debug_assert_eq!(::core::mem::size_of::<$type>(), $byte_len); // size_of isn't a constfn in 1.22 + debug_assert_eq!(core::mem::size_of::<$type>(), $byte_len); // size_of isn't a constfn in 1.22 let mut res = [0; $byte_len]; for i in 0..$byte_len { res[i] = ((val >> ($byte_len - i - 1)*8) & 0xff) as u8; @@ -41,7 +41,7 @@ macro_rules! define_le_to_array { ($name: ident, $type: ty, $byte_len: expr) => { #[inline] pub fn $name(val: $type) -> [u8; $byte_len] { - debug_assert_eq!(::core::mem::size_of::<$type>(), $byte_len); // size_of isn't a constfn in 1.22 + debug_assert_eq!(core::mem::size_of::<$type>(), $byte_len); // size_of isn't a constfn in 1.22 let mut res = [0; $byte_len]; for i in 0..$byte_len { res[i] = ((val >> i*8) & 0xff) as u8; @@ -91,8 +91,8 @@ macro_rules! define_chunk_slice_to_int { ($name: ident, $type: ty, $converter: ident) => { #[inline] pub fn $name(inp: &[u8], outp: &mut [$type]) { - assert_eq!(inp.len(), outp.len() * ::core::mem::size_of::<$type>()); - for (outp_val, data_bytes) in outp.iter_mut().zip(inp.chunks(::core::mem::size_of::<$type>())) { + assert_eq!(inp.len(), outp.len() * core::mem::size_of::<$type>()); + for (outp_val, data_bytes) in outp.iter_mut().zip(inp.chunks(core::mem::size_of::<$type>())) { *outp_val = $converter(data_bytes); } } diff --git a/src/util/hash.rs b/src/util/hash.rs index 3f1080976f..3090527cc6 100644 --- a/src/util/hash.rs +++ b/src/util/hash.rs @@ -15,13 +15,13 @@ //! //! Utility functions related to hashing data, including merkleization -use prelude::*; +use crate::prelude::*; -use io; +use crate::io; use core::cmp::min; -use hashes::Hash; -use consensus::encode::Encodable; +use crate::hashes::Hash; +use crate::consensus::encode::Encodable; /// Calculates the merkle root of a list of hashes inline /// into the allocated slice. diff --git a/src/util/key.rs b/src/util/key.rs index fd2cba2841..97fb131278 100644 --- a/src/util/key.rs +++ b/src/util/key.rs @@ -17,13 +17,13 @@ //! #[deprecated(since = "0.26.1", note = "Please use `util::ecdsa` instead")] -pub use util::ecdsa::{PrivateKey, PublicKey}; +pub use crate::util::ecdsa::{PrivateKey, PublicKey}; use core::fmt; #[cfg(feature = "std")] use std::error; use secp256k1; -use util::base58; +use crate::util::base58; /// A key-related error. #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] @@ -36,7 +36,7 @@ pub enum Error { impl fmt::Display for Error { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { Error::Base58(ref e) => write!(f, "Key base58 error: {}", e), Error::Secp256k1(ref e) => write!(f, "Key secp256k1 error: {}", e), @@ -45,7 +45,7 @@ impl fmt::Display for Error { } #[cfg(feature = "std")] -impl ::std::error::Error for Error { +impl std::error::Error for Error { fn cause(&self) -> Option<&dyn error::Error> { match *self { Error::Base58(ref e) => Some(e), diff --git a/src/util/merkleblock.rs b/src/util/merkleblock.rs index 4e28f2a0f3..c8878022c5 100644 --- a/src/util/merkleblock.rs +++ b/src/util/merkleblock.rs @@ -51,18 +51,18 @@ //! assert_eq!(1, index.len()); //! assert_eq!(1, index[0]); //! ``` -use prelude::*; +use crate::prelude::*; -use io; +use crate::io; -use hashes::Hash; -use hash_types::{Txid, TxMerkleNode}; +use crate::hashes::Hash; +use crate::hash_types::{Txid, TxMerkleNode}; -use blockdata::transaction::Transaction; -use blockdata::constants::{MAX_BLOCK_WEIGHT, MIN_TRANSACTION_WEIGHT}; -use consensus::encode::{self, Decodable, Encodable}; -use util::merkleblock::MerkleBlockError::*; -use {Block, BlockHeader}; +use crate::blockdata::transaction::Transaction; +use crate::blockdata::constants::{MAX_BLOCK_WEIGHT, MIN_TRANSACTION_WEIGHT}; +use crate::consensus::encode::{self, Decodable, Encodable}; +use crate::util::merkleblock::MerkleBlockError::*; +use crate::{Block, BlockHeader}; /// An error when verifying the merkle block #[derive(Clone, PartialEq, Eq, Debug)] @@ -439,7 +439,7 @@ impl MerkleBlock { /// Create a MerkleBlock from a block, that contains proofs for specific txids. #[cfg(feature = "std")] #[deprecated(since="0.26.2", note="use from_block_with_predicate")] - pub fn from_block(block: &Block, match_txids: &::std::collections::HashSet) -> Self { + pub fn from_block(block: &Block, match_txids: &std::collections::HashSet) -> Self { Self::from_block_with_predicate(block, |t| match_txids.contains(t)) } @@ -470,7 +470,7 @@ impl MerkleBlock { pub fn from_header_txids( header: &BlockHeader, block_txids: &[Txid], - match_txids: &::std::collections::HashSet, + match_txids: &std::collections::HashSet, ) -> Self { Self::from_header_txids_with_predicate(header, block_txids, |t| match_txids.contains(t)) } @@ -517,15 +517,15 @@ impl Decodable for MerkleBlock { mod tests { use core::cmp::min; - use hashes::Hash; - use hashes::hex::{FromHex, ToHex}; - use hash_types::{Txid, TxMerkleNode}; + use crate::hashes::Hash; + use crate::hashes::hex::{FromHex, ToHex}; + use crate::hash_types::{Txid, TxMerkleNode}; use secp256k1::rand::prelude::*; - use consensus::encode::{deserialize, serialize}; - use util::hash::bitcoin_merkle_root; - use util::merkleblock::{MerkleBlock, PartialMerkleTree}; - use Block; + use crate::consensus::encode::{deserialize, serialize}; + use crate::util::hash::bitcoin_merkle_root; + use crate::util::merkleblock::{MerkleBlock, PartialMerkleTree}; + use crate::Block; #[test] fn pmt_tests() { diff --git a/src/util/misc.rs b/src/util/misc.rs index 0009b1713e..2f7204bd4f 100644 --- a/src/util/misc.rs +++ b/src/util/misc.rs @@ -16,12 +16,12 @@ //! //! Various utility functions -use prelude::*; +use crate::prelude::*; -use hashes::{sha256d, Hash, HashEngine}; +use crate::hashes::{sha256d, Hash, HashEngine}; -use blockdata::opcodes; -use consensus::{encode, Encodable}; +use crate::blockdata::opcodes; +use crate::consensus::{encode, Encodable}; #[cfg(feature = "secp-recovery")] pub use self::message_signing::{MessageSignature, MessageSignatureError}; @@ -31,16 +31,16 @@ pub const BITCOIN_SIGNED_MSG_PREFIX: &[u8] = b"\x18Bitcoin Signed Message:\n"; #[cfg(feature = "secp-recovery")] mod message_signing { - #[cfg(feature = "base64")] use prelude::*; + #[cfg(feature = "base64")] use crate::prelude::*; use core::fmt; #[cfg(feature = "std")] use std::error; - use hashes::sha256d; + use crate::hashes::sha256d; use secp256k1; use secp256k1::recovery::{RecoveryId, RecoverableSignature}; - use util::ecdsa::PublicKey; - use util::address::{Address, AddressType}; + use crate::util::ecdsa::PublicKey; + use crate::util::address::{Address, AddressType}; /// An error used for dealing with Bitcoin Signed Messages. #[derive(Debug, PartialEq, Eq)] @@ -54,7 +54,7 @@ mod message_signing { } impl fmt::Display for MessageSignatureError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { MessageSignatureError::InvalidLength => write!(f, "length not 65 bytes"), MessageSignatureError::InvalidEncoding(ref e) => write!(f, "invalid encoding: {}", e), @@ -171,29 +171,29 @@ mod message_signing { #[cfg(feature = "base64")] /// Convert a signature from base64 encoding. pub fn from_base64(s: &str) -> Result { - let bytes = ::base64::decode(s).map_err(|_| MessageSignatureError::InvalidBase64)?; + let bytes = base64::decode(s).map_err(|_| MessageSignatureError::InvalidBase64)?; MessageSignature::from_slice(&bytes) } #[cfg(feature = "base64")] /// Convert to base64 encoding. pub fn to_base64(&self) -> String { - ::base64::encode(&self.serialize()[..]) + base64::encode(&self.serialize()[..]) } } #[cfg(feature = "base64")] impl fmt::Display for MessageSignature { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let bytes = self.serialize(); // This avoids the allocation of a String. - write!(f, "{}", ::base64::display::Base64Display::with_config( - &bytes[..], ::base64::STANDARD)) + write!(f, "{}", base64::display::Base64Display::with_config( + &bytes[..], base64::STANDARD)) } } #[cfg(feature = "base64")] - impl ::core::str::FromStr for MessageSignature { + impl core::str::FromStr for MessageSignature { type Err = MessageSignatureError; fn from_str(s: &str) -> Result { MessageSignature::from_base64(s) @@ -248,7 +248,7 @@ pub fn signed_msg_hash(msg: &str) -> sha256d::Hash { #[cfg(test)] mod tests { - use hashes::hex::ToHex; + use crate::hashes::hex::ToHex; use super::script_find_and_remove; use super::signed_msg_hash; @@ -321,11 +321,11 @@ mod tests { assert_eq!(pubkey.compressed, true); assert_eq!(pubkey.key, secp256k1::PublicKey::from_secret_key(&secp, &privkey)); - let p2pkh = ::Address::p2pkh(&pubkey, ::Network::Bitcoin); + let p2pkh = crate::Address::p2pkh(&pubkey, crate::Network::Bitcoin); assert_eq!(signature2.is_signed_by_address(&secp, &p2pkh, msg_hash), Ok(true)); - let p2wpkh = ::Address::p2wpkh(&pubkey, ::Network::Bitcoin).unwrap(); + let p2wpkh = crate::Address::p2wpkh(&pubkey, crate::Network::Bitcoin).unwrap(); assert_eq!(signature2.is_signed_by_address(&secp, &p2wpkh, msg_hash), Ok(false)); - let p2shwpkh = ::Address::p2shwpkh(&pubkey, ::Network::Bitcoin).unwrap(); + let p2shwpkh = crate::Address::p2shwpkh(&pubkey, crate::Network::Bitcoin).unwrap(); assert_eq!(signature2.is_signed_by_address(&secp, &p2shwpkh, msg_hash), Ok(false)); } } diff --git a/src/util/mod.rs b/src/util/mod.rs index d47cf4a3e3..b50c2eaa86 100644 --- a/src/util/mod.rs +++ b/src/util/mod.rs @@ -35,13 +35,13 @@ pub mod bip158; pub(crate) mod endian; -use prelude::*; -use io; +use crate::prelude::*; +use crate::io; use core::fmt; #[cfg(feature = "std")] use std::error; -use network; -use consensus::encode; +use crate::network; +use crate::consensus::encode; /// A trait which allows numbers to act as fixed-size bit arrays pub trait BitArray { @@ -79,7 +79,7 @@ pub enum Error { } impl fmt::Display for Error { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { Error::Encode(ref e) => fmt::Display::fmt(e, f), Error::Network(ref e) => fmt::Display::fmt(e, f), @@ -90,7 +90,7 @@ impl fmt::Display for Error { } #[cfg(feature = "std")] -impl ::std::error::Error for Error { +impl std::error::Error for Error { fn cause(&self) -> Option<&dyn error::Error> { match *self { Error::Encode(ref e) => Some(e), diff --git a/src/util/psbt/error.rs b/src/util/psbt/error.rs index 67d46de2c1..74d19a96bc 100644 --- a/src/util/psbt/error.rs +++ b/src/util/psbt/error.rs @@ -12,15 +12,15 @@ // If not, see . // -use prelude::*; +use crate::prelude::*; use core::fmt; -use blockdata::transaction::Transaction; -use consensus::encode; -use util::psbt::raw; +use crate::blockdata::transaction::Transaction; +use crate::consensus::encode; +use crate::util::psbt::raw; -use hashes; +use crate::hashes; #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] /// Enum for marking psbt hash error @@ -80,7 +80,7 @@ pub enum Error { } impl fmt::Display for Error { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { Error::InvalidKey(ref rkey) => write!(f, "invalid key: {}", rkey), Error::InvalidProprietaryKey => write!(f, "non-proprietary key type found when proprietary key was expected"), @@ -107,7 +107,7 @@ impl fmt::Display for Error { } #[cfg(feature = "std")] -impl ::std::error::Error for Error {} +impl std::error::Error for Error {} #[doc(hidden)] impl From for Error { diff --git a/src/util/psbt/macros.rs b/src/util/psbt/macros.rs index 12d82a4195..9e95c3ff2a 100644 --- a/src/util/psbt/macros.rs +++ b/src/util/psbt/macros.rs @@ -79,7 +79,7 @@ macro_rules! impl_psbtmap_consensus_decoding { fn consensus_decode( mut d: D, ) -> Result { - let mut rv: Self = ::core::default::Default::default(); + let mut rv: Self = Default::default(); loop { match $crate::consensus::Decodable::consensus_decode(&mut d) { diff --git a/src/util/psbt/map/global.rs b/src/util/psbt/map/global.rs index 42d856ca4a..cee83b8211 100644 --- a/src/util/psbt/map/global.rs +++ b/src/util/psbt/map/global.rs @@ -12,20 +12,20 @@ // If not, see . // -use prelude::*; +use crate::prelude::*; -use io::{self, Cursor, Read}; +use crate::io::{self, Cursor, Read}; use core::cmp; -use blockdata::transaction::Transaction; -use consensus::{encode, Encodable, Decodable}; -use consensus::encode::MAX_VEC_SIZE; -use util::psbt::map::Map; -use util::psbt::raw; -use util::psbt; -use util::psbt::Error; -use util::endian::u32_to_array_le; -use util::bip32::{ExtendedPubKey, KeySource, Fingerprint, DerivationPath, ChildNumber}; +use crate::blockdata::transaction::Transaction; +use crate::consensus::{encode, Encodable, Decodable}; +use crate::consensus::encode::MAX_VEC_SIZE; +use crate::util::psbt::map::Map; +use crate::util::psbt::raw; +use crate::util::psbt; +use crate::util::psbt::Error; +use crate::util::endian::u32_to_array_le; +use crate::util::bip32::{ExtendedPubKey, KeySource, Fingerprint, DerivationPath, ChildNumber}; /// Type: Unsigned Transaction PSBT_GLOBAL_UNSIGNED_TX = 0x00 const PSBT_GLOBAL_UNSIGNED_TX: u8 = 0x00; @@ -49,10 +49,10 @@ pub struct Global { /// derivation path as defined by BIP 32 pub xpub: BTreeMap, /// Global proprietary key-value pairs. - #[cfg_attr(feature = "serde", serde(with = "::serde_utils::btreemap_as_seq_byte_values"))] + #[cfg_attr(feature = "serde", serde(with = "crate::serde_utils::btreemap_as_seq_byte_values"))] pub proprietary: BTreeMap>, /// Unknown global key-value pairs. - #[cfg_attr(feature = "serde", serde(with = "::serde_utils::btreemap_as_seq_byte_values"))] + #[cfg_attr(feature = "serde", serde(with = "crate::serde_utils::btreemap_as_seq_byte_values"))] pub unknown: BTreeMap>, } @@ -330,7 +330,7 @@ impl Decodable for Global { } } } - Err(::consensus::encode::Error::Psbt(::util::psbt::Error::NoMorePairs)) => break, + Err(crate::consensus::encode::Error::Psbt(crate::util::psbt::Error::NoMorePairs)) => break, Err(e) => return Err(e), } } diff --git a/src/util/psbt/map/input.rs b/src/util/psbt/map/input.rs index 04b0c6e4f6..48d4b9758e 100644 --- a/src/util/psbt/map/input.rs +++ b/src/util/psbt/map/input.rs @@ -12,21 +12,21 @@ // If not, see . // -use prelude::*; - -use io; - -use blockdata::script::Script; -use blockdata::transaction::{SigHashType, Transaction, TxOut}; -use consensus::encode; -use util::bip32::KeySource; -use hashes::{self, hash160, ripemd160, sha256, sha256d}; -use util::ecdsa::PublicKey; -use util::psbt; -use util::psbt::map::Map; -use util::psbt::raw; -use util::psbt::serialize::Deserialize; -use util::psbt::{Error, error}; +use crate::prelude::*; + +use crate::io; + +use crate::blockdata::script::Script; +use crate::blockdata::transaction::{SigHashType, Transaction, TxOut}; +use crate::consensus::encode; +use crate::util::bip32::KeySource; +use crate::hashes::{self, hash160, ripemd160, sha256, sha256d}; +use crate::util::ecdsa::PublicKey; +use crate::util::psbt; +use crate::util::psbt::map::Map; +use crate::util::psbt::raw; +use crate::util::psbt::serialize::Deserialize; +use crate::util::psbt::{Error, error}; /// Type: Non-Witness UTXO PSBT_IN_NON_WITNESS_UTXO = 0x00 const PSBT_IN_NON_WITNESS_UTXO: u8 = 0x00; @@ -72,7 +72,7 @@ pub struct Input { pub witness_utxo: Option, /// A map from public keys to their corresponding signature as would be /// pushed to the stack from a scriptSig or witness. - #[cfg_attr(feature = "serde", serde(with = "::serde_utils::btreemap_byte_values"))] + #[cfg_attr(feature = "serde", serde(with = "crate::serde_utils::btreemap_byte_values"))] pub partial_sigs: BTreeMap>, /// The sighash type to be used for this input. Signatures for this input /// must use the sighash type. @@ -83,7 +83,7 @@ pub struct Input { pub witness_script: Option