Enable edition 2018

Add 'edition = "2018"' to the manifest and do a bunch of manual path
fixups (use statements and fully qualified paths).
This commit is contained in:
Tobin C. Harding 2022-05-03 09:02:58 +10:00
parent dca0d67771
commit 9f0c687d89
16 changed files with 97 additions and 94 deletions

View File

@ -10,6 +10,7 @@ description = "General purpose library for using and interoperating with Bitcoin
keywords = [ "crypto", "bitcoin" ]
readme = "README.md"
exclude = ["./test_data"]
edition = "2018"
# Please don't forget to add relevant features to docs.rs below
[features]

View File

@ -508,10 +508,10 @@ 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 test::{black_box, Bencher};
use network::stream_reader::StreamReader;
use crate::network::stream_reader::StreamReader;
#[bench]
#[allow(deprecated)]

View File

@ -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};

View File

@ -617,7 +617,7 @@ impl Script {
/// Shorthand for [`Self::verify_with_flags`] with flag [bitcoinconsensus::VERIFY_ALL].
#[cfg(feature="bitcoinconsensus")]
#[cfg_attr(docsrs, doc(cfg(feature = "bitcoinconsensus")))]
pub fn verify (&self, index: usize, amount: ::Amount, spending: &[u8]) -> Result<(), Error> {
pub fn verify (&self, index: usize, amount: crate::Amount, spending: &[u8]) -> Result<(), Error> {
self.verify_with_flags(index, amount, spending, ::bitcoinconsensus::VERIFY_ALL)
}
@ -630,7 +630,7 @@ impl Script {
/// * `flags` - Verification flags, see [`bitcoinconsensus::VERIFY_ALL`] and similar.
#[cfg(feature="bitcoinconsensus")]
#[cfg_attr(docsrs, doc(cfg(feature = "bitcoinconsensus")))]
pub fn verify_with_flags<F: Into<u32>>(&self, index: usize, amount: ::Amount, spending: &[u8], flags: F) -> Result<(), Error> {
pub fn verify_with_flags<F: Into<u32>>(&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())?)
}
@ -1440,7 +1440,7 @@ mod test {
// a random segwit transaction from the blockchain using native segwit
let spent = Builder::from(Vec::from_hex("0020701a8d401c84fb13e6baf169d59684e17abd9fa216c8cc5b9fc63d622ff8c58d").unwrap()).into_script();
let spending = Vec::from_hex("010000000001011f97548fbbe7a0db7588a66e18d803d0089315aa7d4cc28360b6ec50ef36718a0100000000ffffffff02df1776000000000017a9146c002a686959067f4866b8fb493ad7970290ab728757d29f0000000000220020701a8d401c84fb13e6baf169d59684e17abd9fa216c8cc5b9fc63d622ff8c58d04004730440220565d170eed95ff95027a69b313758450ba84a01224e1f7f130dda46e94d13f8602207bdd20e307f062594022f12ed5017bbf4a055a06aea91c10110a0e3bb23117fc014730440220647d2dc5b15f60bc37dc42618a370b2a1490293f9e5c8464f53ec4fe1dfe067302203598773895b4b16d37485cbe21b337f4e4b650739880098c592553add7dd4355016952210375e00eb72e29da82b89367947f29ef34afb75e8654f6ea368e0acdfd92976b7c2103a1b26313f430c4b15bb1fdce663207659d8cac749a0e53d70eff01874496feff2103c96d495bfdd5ba4145e3e046fee45e84a8a48ad05bd8dbb395c011a32cf9f88053ae00000000").unwrap();
spent.verify(0, ::Amount::from_sat(18393430), spending.as_slice()).unwrap();
spent.verify(0, crate::Amount::from_sat(18393430), spending.as_slice()).unwrap();
}
#[test]

View File

@ -34,7 +34,7 @@ use crate::hashes::hex::FromHex;
use crate::util::endian;
use crate::blockdata::constants::WITNESS_SCALE_FACTOR;
#[cfg(feature="bitcoinconsensus")] use blockdata::script;
#[cfg(feature="bitcoinconsensus")] use crate::blockdata::script;
use crate::blockdata::script::Script;
use crate::blockdata::witness::Witness;
use crate::consensus::{encode, Decodable, Encodable};
@ -43,7 +43,7 @@ use crate::hash_types::{Sighash, Txid, Wtxid};
use crate::VarInt;
#[cfg(doc)]
use util::sighash::SchnorrSighashType;
use crate::util::sighash::SchnorrSighashType;
/// Used for signature hash for invalid use of SIGHASH_SINGLE.
const UINT256_ONE: [u8; 32] = [
@ -590,7 +590,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()));
}
@ -1541,10 +1541,10 @@ mod tests {
#[test]
#[cfg(feature="bitcoinconsensus")]
fn test_transaction_verify () {
use hashes::hex::FromHex;
use std::collections::HashMap;
use blockdata::script;
use blockdata::witness::Witness;
use crate::hashes::hex::FromHex;
use crate::blockdata::script;
use crate::blockdata::witness::Witness;
// a random recent segwit transaction from blockchain using both old and segwit inputs
let mut spending: Transaction = deserialize(Vec::from_hex("020000000001031cfbc8f54fbfa4a33a30068841371f80dbfe166211242213188428f437445c91000000006a47304402206fbcec8d2d2e740d824d3d36cc345b37d9f65d665a99f5bd5c9e8d42270a03a8022013959632492332200c2908459547bf8dbf97c65ab1a28dec377d6f1d41d3d63e012103d7279dfb90ce17fe139ba60a7c41ddf605b25e1c07a4ddcb9dfef4e7d6710f48feffffff476222484f5e35b3f0e43f65fc76e21d8be7818dd6a989c160b1e5039b7835fc00000000171600140914414d3c94af70ac7e25407b0689e0baa10c77feffffffa83d954a62568bbc99cc644c62eb7383d7c2a2563041a0aeb891a6a4055895570000000017160014795d04cc2d4f31480d9a3710993fbd80d04301dffeffffff06fef72f000000000017a91476fd7035cd26f1a32a5ab979e056713aac25796887a5000f00000000001976a914b8332d502a529571c6af4be66399cd33379071c588ac3fda0500000000001976a914fc1d692f8de10ae33295f090bea5fe49527d975c88ac522e1b00000000001976a914808406b54d1044c429ac54c0e189b0d8061667e088ac6eb68501000000001976a914dfab6085f3a8fb3e6710206a5a959313c5618f4d88acbba20000000000001976a914eb3026552d7e3f3073457d0bee5d4757de48160d88ac0002483045022100bee24b63212939d33d513e767bc79300051f7a0d433c3fcf1e0e3bf03b9eb1d70220588dc45a9ce3a939103b4459ce47500b64e23ab118dfc03c9caa7d6bfc32b9c601210354fd80328da0f9ae6eef2b3a81f74f9a6f66761fadf96f1d1d22b1fd6845876402483045022100e29c7e3a5efc10da6269e5fc20b6a1cb8beb92130cc52c67e46ef40aaa5cac5f0220644dd1b049727d991aece98a105563416e10a5ac4221abac7d16931842d5c322012103960b87412d6e169f30e12106bdf70122aabb9eb61f455518322a18b920a4dfa887d30700")
@ -1601,9 +1601,9 @@ mod tests {
#[cfg(all(test, feature = "unstable"))]
mod benches {
use super::Transaction;
use EmptyWrite;
use consensus::{deserialize, Encodable};
use hashes::hex::FromHex;
use crate::EmptyWrite;
use crate::consensus::{deserialize, Encodable};
use crate::hashes::hex::FromHex;
use test::{black_box, Bencher};
const SOME_TX: &'static str = "0100000001a15d57094aa7a21a28cb20b59aab8fc7d1149a3bdbcddba9c622e4f5f6a99ece010000006c493046022100f93bb0e7d8db7bd46e40132d1f8242026e045f03a0efe71bbb8e3f475e970d790221009337cd7f1f929f00cc6ff01f03729b069a7c21b59b1736ddfee5db5946c5da8c0121033b9b137ee87d5a812d6f506efdd37f0affa7ffc310711c06c7f3e097c9447c52ffffffff0100e1f505000000001976a9140389035a9225b3839e2bbf32d826a1e222031fd888ac00000000";

View File

@ -20,7 +20,7 @@
//! hash).
//!
use crate::hashes::{Hash, sha256, sha256d, hash160};
use crate::hashes::{Hash, sha256, sha256d, hash160, hash_newtype};
macro_rules! impl_hashencode {
($hashtype:ident) => {

View File

@ -93,11 +93,11 @@ macro_rules! impl_array_newtype {
}
}
impl<I> $crate::core::ops::Index<I> for $thing
impl<I> core::ops::Index<I> for $thing
where
[$ty]: $crate::core::ops::Index<I>,
[$ty]: core::ops::Index<I>,
{
type Output = <[$ty] as $crate::core::ops::Index<I>>::Output;
type Output = <[$ty] as core::ops::Index<I>>::Output;
#[inline]
fn index(&self, index: I) -> &Self::Output {

View File

@ -190,7 +190,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;
@ -204,7 +204,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;

View File

@ -9,14 +9,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<S, T>(v: &BTreeMap<T, Vec<u8>>, s: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
T: serde::Serialize + ::core::hash::Hash + Eq + Ord,
T: serde::Serialize + core::hash::Hash + Eq + Ord,
{
use serde::ser::SerializeMap;
@ -35,18 +35,18 @@ pub mod btreemap_byte_values {
pub fn deserialize<'de, D, T>(d: D) -> Result<BTreeMap<T, Vec<u8>>, 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<T>(PhantomData<T>);
impl<'de, T> serde::de::Visitor<'de> for Visitor<T>
where
T: serde::Deserialize<'de> + ::core::hash::Hash + Eq + Ord,
T: serde::Deserialize<'de> + core::hash::Hash + Eq + Ord,
{
type Value = BTreeMap<T, Vec<u8>>;
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")
}
@ -77,13 +77,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<S, T, U>(v: &BTreeMap<T, U>, s: S) -> Result<S::Ok, S::Error>
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;
@ -103,20 +103,20 @@ pub mod btreemap_as_seq {
pub fn deserialize<'de, D, T, U>(d: D) -> Result<BTreeMap<T, U>, 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<T, U>(PhantomData<(T, U)>);
impl<'de, T, U> serde::de::Visitor<'de> for Visitor<T, U>
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<T, U>;
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")
}
@ -147,14 +147,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>(
T,
#[serde(deserialize_with = "::serde_utils::hex_bytes::deserialize")]
#[serde(deserialize_with = "crate::serde_utils::hex_bytes::deserialize")]
Vec<u8>,
);
@ -162,14 +162,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<S, T>(v: &BTreeMap<T, Vec<u8>>, s: S) -> Result<S::Ok, S::Error>
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;
@ -188,18 +188,18 @@ pub mod btreemap_as_seq_byte_values {
pub fn deserialize<'de, D, T>(d: D) -> Result<BTreeMap<T, Vec<u8>>, 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<T>(PhantomData<T>);
impl<'de, T> serde::de::Visitor<'de> for Visitor<T>
where
T: serde::Deserialize<'de> + ::core::hash::Hash + Eq + Ord,
T: serde::Deserialize<'de> + core::hash::Hash + Eq + Ord,
{
type Value = BTreeMap<T, Vec<u8>>;
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")
}
@ -246,12 +246,12 @@ pub mod hex_bytes {
where
D: serde::Deserializer<'de>, B: serde::Deserialize<'de> + FromHex,
{
struct Visitor<B>(::core::marker::PhantomData<B>);
struct Visitor<B>(core::marker::PhantomData<B>);
impl<'de, B: FromHex> serde::de::Visitor<'de> for Visitor<B> {
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")
}
@ -259,7 +259,7 @@ pub mod hex_bytes {
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));
@ -278,7 +278,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))
}
}
}

View File

@ -1233,7 +1233,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.
@ -1322,7 +1322,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: SerdeAmount, S: Serializer>(a: &A, s: S) -> Result<S::Ok, S::Error> {
a.ser_sat(s)
@ -1337,7 +1337,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;
@ -1386,7 +1386,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: SerdeAmount, S: Serializer>(a: &A, s: S) -> Result<S::Ok, S::Error> {
a.ser_btc(s)
@ -1401,7 +1401,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;
@ -1941,9 +1941,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,
}
@ -1970,9 +1970,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,
}
@ -2004,9 +2004,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<Amount>,
#[serde(default, with = "::util::amount::serde::as_btc::opt")]
#[serde(default, with = "crate::util::amount::serde::as_btc::opt")]
pub samt: Option<SignedAmount>,
}
@ -2047,9 +2047,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<Amount>,
#[serde(default, with = "::util::amount::serde::as_sat::opt")]
#[serde(default, with = "crate::util::amount::serde::as_sat::opt")]
pub samt: Option<SignedAmount>,
}

View File

@ -34,7 +34,8 @@ 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;
@ -321,7 +322,7 @@ mod tests {
fn test_message_signature() {
use core::str::FromStr;
use secp256k1;
use ::AddressType;
use crate::{Address, Network, AddressType};
let secp = secp256k1::Secp256k1::new();
let message = "rust-bitcoin MessageSignature test";
@ -342,14 +343,14 @@ mod tests {
assert_eq!(pubkey.compressed, true);
assert_eq!(pubkey.inner, secp256k1::PublicKey::from_secret_key(&secp, &privkey));
let p2pkh = ::Address::p2pkh(&pubkey, ::Network::Bitcoin);
let p2pkh = Address::p2pkh(&pubkey, 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 = Address::p2wpkh(&pubkey, Network::Bitcoin).unwrap();
assert_eq!(
signature2.is_signed_by_address(&secp, &p2wpkh, msg_hash),
Err(MessageSignatureError::UnsupportedAddressType(AddressType::P2wpkh))
);
let p2shwpkh = ::Address::p2shwpkh(&pubkey, ::Network::Bitcoin).unwrap();
let p2shwpkh = Address::p2shwpkh(&pubkey, Network::Bitcoin).unwrap();
assert_eq!(
signature2.is_signed_by_address(&secp, &p2shwpkh, msg_hash),
Err(MessageSignatureError::UnsupportedAddressType(AddressType::P2sh))
@ -360,7 +361,8 @@ mod tests {
#[cfg(all(feature = "secp-recovery", feature = "base64"))]
fn test_incorrect_message_signature() {
use secp256k1;
use util::key::PublicKey;
use crate::util::key::PublicKey;
use crate::{Address, Network};
let secp = secp256k1::Secp256k1::new();
let message = "a different message from what was signed";
@ -376,7 +378,7 @@ mod tests {
&::base64::decode(&pubkey_base64).expect("base64 string")
).expect("pubkey slice");
let p2pkh = ::Address::p2pkh(&pubkey, ::Network::Bitcoin);
let p2pkh = Address::p2pkh(&pubkey, Network::Bitcoin);
assert_eq!(signature.is_signed_by_address(&secp, &p2pkh, msg_hash), Ok(false));
}
}

View File

@ -102,7 +102,7 @@ pub struct Input {
pub witness_script: Option<Script>,
/// A map from public keys needed to sign this input to their corresponding
/// master key fingerprints and derivation paths.
#[cfg_attr(feature = "serde", serde(with = "::serde_utils::btreemap_as_seq"))]
#[cfg_attr(feature = "serde", serde(with = "crate::serde_utils::btreemap_as_seq"))]
pub bip32_derivation: BTreeMap<secp256k1::PublicKey, KeySource>,
/// The finalized, fully-constructed scriptSig with signatures and any other
/// scripts necessary for this input to pass validation.
@ -112,37 +112,37 @@ pub struct Input {
pub final_script_witness: Option<Witness>,
/// TODO: Proof of reserves commitment
/// RIPEMD160 hash to preimage map.
#[cfg_attr(feature = "serde", serde(with = "::serde_utils::btreemap_byte_values"))]
#[cfg_attr(feature = "serde", serde(with = "crate::serde_utils::btreemap_byte_values"))]
pub ripemd160_preimages: BTreeMap<ripemd160::Hash, Vec<u8>>,
/// SHA256 hash to preimage map.
#[cfg_attr(feature = "serde", serde(with = "::serde_utils::btreemap_byte_values"))]
#[cfg_attr(feature = "serde", serde(with = "crate::serde_utils::btreemap_byte_values"))]
pub sha256_preimages: BTreeMap<sha256::Hash, Vec<u8>>,
/// HSAH160 hash to preimage map.
#[cfg_attr(feature = "serde", serde(with = "::serde_utils::btreemap_byte_values"))]
#[cfg_attr(feature = "serde", serde(with = "crate::serde_utils::btreemap_byte_values"))]
pub hash160_preimages: BTreeMap<hash160::Hash, Vec<u8>>,
/// HAS256 hash to preimage map.
#[cfg_attr(feature = "serde", serde(with = "::serde_utils::btreemap_byte_values"))]
#[cfg_attr(feature = "serde", serde(with = "crate::serde_utils::btreemap_byte_values"))]
pub hash256_preimages: BTreeMap<sha256d::Hash, Vec<u8>>,
/// Serialized schnorr signature with sighash type for key spend.
pub tap_key_sig: Option<SchnorrSig>,
/// Map of <xonlypubkey>|<leafhash> with signature.
#[cfg_attr(feature = "serde", serde(with = "::serde_utils::btreemap_as_seq"))]
#[cfg_attr(feature = "serde", serde(with = "crate::serde_utils::btreemap_as_seq"))]
pub tap_script_sigs: BTreeMap<(XOnlyPublicKey, TapLeafHash), SchnorrSig>,
/// Map of Control blocks to Script version pair.
#[cfg_attr(feature = "serde", serde(with = "::serde_utils::btreemap_as_seq"))]
#[cfg_attr(feature = "serde", serde(with = "crate::serde_utils::btreemap_as_seq"))]
pub tap_scripts: BTreeMap<ControlBlock, (Script, LeafVersion)>,
/// Map of tap root x only keys to origin info and leaf hashes contained in it.
#[cfg_attr(feature = "serde", serde(with = "::serde_utils::btreemap_as_seq"))]
#[cfg_attr(feature = "serde", serde(with = "crate::serde_utils::btreemap_as_seq"))]
pub tap_key_origins: BTreeMap<XOnlyPublicKey, (Vec<TapLeafHash>, KeySource)>,
/// Taproot Internal key.
pub tap_internal_key: Option<XOnlyPublicKey>,
/// Taproot Merkle root.
pub tap_merkle_root: Option<TapBranchHash>,
/// Proprietary key-value pairs for this input.
#[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<raw::ProprietaryKey, Vec<u8>>,
/// Unknown key-value pairs for this input.
#[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<raw::Key, Vec<u8>>,
}

View File

@ -56,25 +56,25 @@ pub struct Output {
pub witness_script: Option<Script>,
/// A map from public keys needed to spend this output to their
/// corresponding master key fingerprints and derivation paths.
#[cfg_attr(feature = "serde", serde(with = "::serde_utils::btreemap_as_seq"))]
#[cfg_attr(feature = "serde", serde(with = "crate::serde_utils::btreemap_as_seq"))]
pub bip32_derivation: BTreeMap<secp256k1::PublicKey, KeySource>,
/// The internal pubkey.
pub tap_internal_key: Option<XOnlyPublicKey>,
/// Taproot Output tree.
pub tap_tree: Option<TapTree>,
/// Map of tap root x only keys to origin info and leaf hashes contained in it.
#[cfg_attr(feature = "serde", serde(with = "::serde_utils::btreemap_as_seq"))]
#[cfg_attr(feature = "serde", serde(with = "crate::serde_utils::btreemap_as_seq"))]
pub tap_key_origins: BTreeMap<XOnlyPublicKey, (Vec<TapLeafHash>, KeySource)>,
/// Proprietary key-value pairs for this output.
#[cfg_attr(
feature = "serde",
serde(with = "::serde_utils::btreemap_as_seq_byte_values")
serde(with = "crate::serde_utils::btreemap_as_seq_byte_values")
)]
pub proprietary: BTreeMap<raw::ProprietaryKey, Vec<u8>>,
/// Unknown key-value pairs for this output.
#[cfg_attr(
feature = "serde",
serde(with = "::serde_utils::btreemap_as_seq_byte_values")
serde(with = "crate::serde_utils::btreemap_as_seq_byte_values")
)]
pub unknown: BTreeMap<raw::Key, Vec<u8>>,
}

View File

@ -62,10 +62,10 @@ pub struct PartiallySignedTransaction {
/// derivation path as defined by BIP 32
pub xpub: BTreeMap<ExtendedPubKey, KeySource>,
/// 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<raw::ProprietaryKey, Vec<u8>>,
/// 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<raw::Key, Vec<u8>>,
/// The corresponding key-value map for each input in the unsigned
@ -219,8 +219,8 @@ mod display_from_str {
use super::PartiallySignedTransaction;
use core::fmt::{Display, Formatter, self};
use core::str::FromStr;
use consensus::encode::{Error, self};
use ::base64::display::Base64Display;
use crate::consensus::encode::{Error, self};
use base64::display::Base64Display;
/// Error happening during PSBT decoding from Base64 string
#[derive(Debug)]
@ -496,8 +496,8 @@ mod tests {
fn test_serde_psbt() {
//! Create a full PSBT value with various fields filled and make sure it can be JSONized.
use hashes::sha256d;
use util::psbt::map::Input;
use EcdsaSighashType;
use crate::util::psbt::map::Input;
use crate::EcdsaSighashType;
// create some values to use in the PSBT
let tx = Transaction {
@ -632,7 +632,7 @@ mod tests {
#[test]
#[should_panic(expected = "ConsensusEncoding")]
fn invalid_vector_2_base64() {
use util::psbt::PsbtParseError;
use crate::util::psbt::PsbtParseError;
PartiallySignedTransaction::from_str("cHNidP8BAHUCAAAAASaBcTce3/KF6Tet7qSze3gADAVmy7OtZGQXE8pCFxv2AAAAAAD+////AtPf9QUAAAAAGXapFNDFmQPFusKGh2DpD9UhpGZap2UgiKwA4fUFAAAAABepFDVF5uM7gyxHBQ8k0+65PJwDlIvHh7MuEwAAAQD9pQEBAAAAAAECiaPHHqtNIOA3G7ukzGmPopXJRjr6Ljl/hTPMti+VZ+UBAAAAFxYAFL4Y0VKpsBIDna89p95PUzSe7LmF/////4b4qkOnHf8USIk6UwpyN+9rRgi7st0tAXHmOuxqSJC0AQAAABcWABT+Pp7xp0XpdNkCxDVZQ6vLNL1TU/////8CAMLrCwAAAAAZdqkUhc/xCX/Z4Ai7NK9wnGIZeziXikiIrHL++E4sAAAAF6kUM5cluiHv1irHU6m80GfWx6ajnQWHAkcwRAIgJxK+IuAnDzlPVoMR3HyppolwuAJf3TskAinwf4pfOiQCIAGLONfc0xTnNMkna9b7QPZzMlvEuqFEyADS8vAtsnZcASED0uFWdJQbrUqZY3LLh+GFbTZSYG2YVi/jnF6efkE/IQUCSDBFAiEA0SuFLYXc2WHS9fSrZgZU327tzHlMDDPOXMMJ/7X85Y0CIGczio4OFyXBl/saiK9Z9R5E5CVbIBZ8hoQDHAXR8lkqASECI7cr7vCWXRC+B3jv7NYfysb3mk6haTkzgHNEZPhPKrMAAAAAAA==")
// This weird thing is necessary since rustc 0.29 prints out I/O error in a different format than later versions
.map_err(|err| match err {

View File

@ -34,7 +34,7 @@ pub struct Key {
/// The type of this PSBT key.
pub type_value: u8,
/// The key itself in raw byte form.
#[cfg_attr(feature = "serde", serde(with = "::serde_utils::hex_bytes"))]
#[cfg_attr(feature = "serde", serde(with = "crate::serde_utils::hex_bytes"))]
pub key: Vec<u8>,
}
@ -45,7 +45,7 @@ pub struct Pair {
/// The key of this key-value pair.
pub key: Key,
/// The value of this key-value pair in raw byte form.
#[cfg_attr(feature = "serde", serde(with = "::serde_utils::hex_bytes"))]
#[cfg_attr(feature = "serde", serde(with = "crate::serde_utils::hex_bytes"))]
pub value: Vec<u8>,
}
@ -59,12 +59,12 @@ pub type ProprietaryType = u8;
pub struct ProprietaryKey<Subtype=ProprietaryType> where Subtype: Copy + From<u8> + Into<u8> {
/// Proprietary type prefix used for grouping together keys under some
/// application and avoid namespace collision
#[cfg_attr(feature = "serde", serde(with = "::serde_utils::hex_bytes"))]
#[cfg_attr(feature = "serde", serde(with = "crate::serde_utils::hex_bytes"))]
pub prefix: Vec<u8>,
/// Custom proprietary subtype
pub subtype: Subtype,
/// Additional key bytes (like serialized public key data etc)
#[cfg_attr(feature = "serde", serde(with = "::serde_utils::hex_bytes"))]
#[cfg_attr(feature = "serde", serde(with = "crate::serde_utils::hex_bytes"))]
pub key: Vec<u8>,
}

View File

@ -402,7 +402,7 @@ impl TaprootBuilder {
/// If the script weight calculations overflow, a sub-optimal tree may be generated. This should
/// not happen unless you are dealing with billions of branches with weights close to 2^32.
///
/// [`TapTree`]: ::util::psbt::TapTree
/// [`TapTree`]: crate::util::psbt::TapTree
pub fn with_huffman_tree<I>(
script_weights: I,
) -> Result<Self, TaprootBuilderError>
@ -808,7 +808,7 @@ impl ControlBlock {
/// Serializes the control block.
///
/// This would be required when using [`ControlBlock`] as a witness element while spending an
/// output via script path. This serialization does not include the [`::VarInt`] prefix that would
/// output via script path. This serialization does not include the [`crate::VarInt`] prefix that would
/// be applied when encoding this element as a witness.
pub fn serialize(&self) -> Vec<u8> {
let mut buf = Vec::with_capacity(self.size());