Fix in preparation for next edition
Use cargo to upgrade from edition 2015 to edition 2018. cargo fix --edition No manual changes made. The result of the command above is just to fix all the use statements (add `crate::`) and fix the fully qualified path formats i.e., `::Foo` -> `crate::Foo`.
This commit is contained in:
parent
af1f259419
commit
dca0d67771
|
@ -20,22 +20,22 @@
|
||||||
//! these blocks and the blockchain.
|
//! these blocks and the blockchain.
|
||||||
//!
|
//!
|
||||||
|
|
||||||
use prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
use core::fmt;
|
use core::fmt;
|
||||||
|
|
||||||
use util;
|
use crate::util;
|
||||||
use util::Error::{BlockBadTarget, BlockBadProofOfWork};
|
use crate::util::Error::{BlockBadTarget, BlockBadProofOfWork};
|
||||||
use util::hash::bitcoin_merkle_root;
|
use crate::util::hash::bitcoin_merkle_root;
|
||||||
use hashes::{Hash, HashEngine};
|
use crate::hashes::{Hash, HashEngine};
|
||||||
use hash_types::{Wtxid, BlockHash, TxMerkleNode, WitnessMerkleNode, WitnessCommitment};
|
use crate::hash_types::{Wtxid, BlockHash, TxMerkleNode, WitnessMerkleNode, WitnessCommitment};
|
||||||
use util::uint::Uint256;
|
use crate::util::uint::Uint256;
|
||||||
use consensus::encode::Encodable;
|
use crate::consensus::encode::Encodable;
|
||||||
use network::constants::Network;
|
use crate::network::constants::Network;
|
||||||
use blockdata::transaction::Transaction;
|
use crate::blockdata::transaction::Transaction;
|
||||||
use blockdata::constants::{max_target, WITNESS_SCALE_FACTOR};
|
use crate::blockdata::constants::{max_target, WITNESS_SCALE_FACTOR};
|
||||||
use blockdata::script;
|
use crate::blockdata::script;
|
||||||
use VarInt;
|
use crate::VarInt;
|
||||||
|
|
||||||
/// A block header, which contains all the block's information except
|
/// A block header, which contains all the block's information except
|
||||||
/// the actual transactions
|
/// the actual transactions
|
||||||
|
@ -359,13 +359,13 @@ impl ::std::error::Error for Bip34Error {}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use hashes::hex::FromHex;
|
use crate::hashes::hex::FromHex;
|
||||||
|
|
||||||
use blockdata::block::{Block, BlockHeader};
|
use crate::blockdata::block::{Block, BlockHeader};
|
||||||
use consensus::encode::{deserialize, serialize};
|
use crate::consensus::encode::{deserialize, serialize};
|
||||||
use util::uint::Uint256;
|
use crate::util::uint::Uint256;
|
||||||
use util::Error::{BlockBadTarget, BlockBadProofOfWork};
|
use crate::util::Error::{BlockBadTarget, BlockBadProofOfWork};
|
||||||
use network::constants::Network;
|
use crate::network::constants::Network;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_coinbase_and_bip34() {
|
fn test_coinbase_and_bip34() {
|
||||||
|
|
|
@ -19,19 +19,19 @@
|
||||||
//! single transaction.
|
//! single transaction.
|
||||||
//!
|
//!
|
||||||
|
|
||||||
use prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
use core::default::Default;
|
use core::default::Default;
|
||||||
|
|
||||||
use hashes::hex::{self, HexIterator};
|
use crate::hashes::hex::{self, HexIterator};
|
||||||
use hashes::sha256d;
|
use crate::hashes::sha256d;
|
||||||
use blockdata::opcodes;
|
use crate::blockdata::opcodes;
|
||||||
use blockdata::script;
|
use crate::blockdata::script;
|
||||||
use blockdata::transaction::{OutPoint, Transaction, TxOut, TxIn};
|
use crate::blockdata::transaction::{OutPoint, Transaction, TxOut, TxIn};
|
||||||
use blockdata::block::{Block, BlockHeader};
|
use crate::blockdata::block::{Block, BlockHeader};
|
||||||
use blockdata::witness::Witness;
|
use crate::blockdata::witness::Witness;
|
||||||
use network::constants::Network;
|
use crate::network::constants::Network;
|
||||||
use util::uint::Uint256;
|
use crate::util::uint::Uint256;
|
||||||
|
|
||||||
/// The maximum allowable sequence number
|
/// The maximum allowable sequence number
|
||||||
pub const MAX_SEQUENCE: u32 = 0xFFFFFFFF;
|
pub const MAX_SEQUENCE: u32 = 0xFFFFFFFF;
|
||||||
|
@ -179,12 +179,12 @@ pub fn genesis_block(network: Network) -> Block {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use core::default::Default;
|
use core::default::Default;
|
||||||
use hashes::hex::FromHex;
|
use crate::hashes::hex::FromHex;
|
||||||
|
|
||||||
use network::constants::Network;
|
use crate::network::constants::Network;
|
||||||
use consensus::encode::serialize;
|
use crate::consensus::encode::serialize;
|
||||||
use blockdata::constants::{genesis_block, bitcoin_genesis_tx};
|
use crate::blockdata::constants::{genesis_block, bitcoin_genesis_tx};
|
||||||
use blockdata::constants::{MAX_SEQUENCE, COIN_VALUE};
|
use crate::blockdata::constants::{MAX_SEQUENCE, COIN_VALUE};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn bitcoin_genesis_first_transaction() {
|
fn bitcoin_genesis_first_transaction() {
|
||||||
|
|
|
@ -23,28 +23,28 @@
|
||||||
//! This module provides the structures and functions needed to support scripts.
|
//! This module provides the structures and functions needed to support scripts.
|
||||||
//!
|
//!
|
||||||
|
|
||||||
use prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
use io;
|
use crate::io;
|
||||||
use core::{fmt, default::Default};
|
use core::{fmt, default::Default};
|
||||||
use core::ops::Index;
|
use core::ops::Index;
|
||||||
|
|
||||||
#[cfg(feature = "serde")] use serde;
|
#[cfg(feature = "serde")] use serde;
|
||||||
|
|
||||||
use hash_types::{PubkeyHash, WPubkeyHash, ScriptHash, WScriptHash};
|
use crate::hash_types::{PubkeyHash, WPubkeyHash, ScriptHash, WScriptHash};
|
||||||
use blockdata::opcodes;
|
use crate::blockdata::opcodes;
|
||||||
use consensus::{encode, Decodable, Encodable};
|
use crate::consensus::{encode, Decodable, Encodable};
|
||||||
use hashes::{Hash, hex};
|
use crate::hashes::{Hash, hex};
|
||||||
use policy::DUST_RELAY_TX_FEE;
|
use crate::policy::DUST_RELAY_TX_FEE;
|
||||||
#[cfg(feature="bitcoinconsensus")] use bitcoinconsensus;
|
#[cfg(feature="bitcoinconsensus")] use bitcoinconsensus;
|
||||||
#[cfg(feature="bitcoinconsensus")] use core::convert::From;
|
#[cfg(feature="bitcoinconsensus")] use core::convert::From;
|
||||||
use OutPoint;
|
use crate::OutPoint;
|
||||||
|
|
||||||
use util::key::PublicKey;
|
use crate::util::key::PublicKey;
|
||||||
use util::address::WitnessVersion;
|
use crate::util::address::WitnessVersion;
|
||||||
use util::taproot::{LeafVersion, TapBranchHash, TapLeafHash};
|
use crate::util::taproot::{LeafVersion, TapBranchHash, TapLeafHash};
|
||||||
use secp256k1::{Secp256k1, Verification, XOnlyPublicKey};
|
use secp256k1::{Secp256k1, Verification, XOnlyPublicKey};
|
||||||
use schnorr::{TapTweak, TweakedPublicKey, UntweakedPublicKey};
|
use crate::schnorr::{TapTweak, TweakedPublicKey, UntweakedPublicKey};
|
||||||
|
|
||||||
/// A Bitcoin script.
|
/// A Bitcoin script.
|
||||||
#[derive(Clone, Default, PartialOrd, Ord, PartialEq, Eq, Hash)]
|
#[derive(Clone, Default, PartialOrd, Ord, PartialEq, Eq, Hash)]
|
||||||
|
@ -557,7 +557,7 @@ impl Script {
|
||||||
|
|
||||||
/// Checks whether a script can be proven to have no satisfying input.
|
/// Checks whether a script can be proven to have no satisfying input.
|
||||||
pub fn is_provably_unspendable(&self) -> bool {
|
pub fn is_provably_unspendable(&self) -> bool {
|
||||||
use blockdata::opcodes::Class::{ReturnOp, IllegalOp};
|
use crate::blockdata::opcodes::Class::{ReturnOp, IllegalOp};
|
||||||
|
|
||||||
match self.0.first() {
|
match self.0.first() {
|
||||||
Some(b) => {
|
Some(b) => {
|
||||||
|
@ -572,7 +572,7 @@ impl Script {
|
||||||
|
|
||||||
/// Returns the minimum value an output with this script should have in order to be
|
/// Returns the minimum value an output with this script should have in order to be
|
||||||
/// broadcastable on today's Bitcoin network.
|
/// 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
|
// 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 broadcast/confirmed.
|
// otherwise allow users to create transactions which likely can never be broadcast/confirmed.
|
||||||
let sats = DUST_RELAY_TX_FEE as u64 / 1000 * // The default dust relay fee is 3000 satoshi/kB (i.e. 3 sat/vByte)
|
let sats = DUST_RELAY_TX_FEE as u64 / 1000 * // The default dust relay fee is 3000 satoshi/kB (i.e. 3 sat/vByte)
|
||||||
|
@ -588,7 +588,7 @@ impl Script {
|
||||||
self.consensus_encode(&mut sink()).expect("sinks don't error") as u64 // The serialized size of this script_pubkey
|
self.consensus_encode(&mut sink()).expect("sinks don't error") as u64 // The serialized size of this script_pubkey
|
||||||
};
|
};
|
||||||
|
|
||||||
::Amount::from_sat(sats)
|
crate::Amount::from_sat(sats)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Iterates over the script in the form of `Instruction`s, which are an enum covering opcodes,
|
/// Iterates over the script in the form of `Instruction`s, which are an enum covering opcodes,
|
||||||
|
@ -1075,11 +1075,11 @@ mod test {
|
||||||
use super::*;
|
use super::*;
|
||||||
use super::build_scriptint;
|
use super::build_scriptint;
|
||||||
|
|
||||||
use hashes::hex::{FromHex, ToHex};
|
use crate::hashes::hex::{FromHex, ToHex};
|
||||||
use consensus::encode::{deserialize, serialize};
|
use crate::consensus::encode::{deserialize, serialize};
|
||||||
use blockdata::opcodes;
|
use crate::blockdata::opcodes;
|
||||||
use util::key::PublicKey;
|
use crate::util::key::PublicKey;
|
||||||
use util::psbt::serialize::Serialize;
|
use crate::util::psbt::serialize::Serialize;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn script() {
|
fn script() {
|
||||||
|
@ -1449,7 +1449,7 @@ mod test {
|
||||||
// well-known scriptPubKey types.
|
// well-known scriptPubKey types.
|
||||||
let script_p2wpkh = Builder::new().push_int(0).push_slice(&[42; 20]).into_script();
|
let script_p2wpkh = Builder::new().push_int(0).push_slice(&[42; 20]).into_script();
|
||||||
assert!(script_p2wpkh.is_v0_p2wpkh());
|
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()
|
let script_p2pkh = Builder::new()
|
||||||
.push_opcode(opcodes::all::OP_DUP)
|
.push_opcode(opcodes::all::OP_DUP)
|
||||||
|
@ -1459,7 +1459,7 @@ mod test {
|
||||||
.push_opcode(opcodes::all::OP_CHECKSIG)
|
.push_opcode(opcodes::all::OP_CHECKSIG)
|
||||||
.into_script();
|
.into_script();
|
||||||
assert!(script_p2pkh.is_p2pkh());
|
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));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -23,24 +23,24 @@
|
||||||
//! This module provides the structures and functions needed to support transactions.
|
//! This module provides the structures and functions needed to support transactions.
|
||||||
//!
|
//!
|
||||||
|
|
||||||
use prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
use io;
|
use crate::io;
|
||||||
use core::{fmt, str, default::Default};
|
use core::{fmt, str, default::Default};
|
||||||
#[cfg(feature = "std")] use std::error;
|
#[cfg(feature = "std")] use std::error;
|
||||||
|
|
||||||
use hashes::{self, Hash, sha256d};
|
use crate::hashes::{self, Hash, sha256d};
|
||||||
use hashes::hex::FromHex;
|
use crate::hashes::hex::FromHex;
|
||||||
|
|
||||||
use util::endian;
|
use crate::util::endian;
|
||||||
use blockdata::constants::WITNESS_SCALE_FACTOR;
|
use crate::blockdata::constants::WITNESS_SCALE_FACTOR;
|
||||||
#[cfg(feature="bitcoinconsensus")] use blockdata::script;
|
#[cfg(feature="bitcoinconsensus")] use blockdata::script;
|
||||||
use blockdata::script::Script;
|
use crate::blockdata::script::Script;
|
||||||
use blockdata::witness::Witness;
|
use crate::blockdata::witness::Witness;
|
||||||
use consensus::{encode, Decodable, Encodable};
|
use crate::consensus::{encode, Decodable, Encodable};
|
||||||
use consensus::encode::MAX_VEC_SIZE;
|
use crate::consensus::encode::MAX_VEC_SIZE;
|
||||||
use hash_types::{Sighash, Txid, Wtxid};
|
use crate::hash_types::{Sighash, Txid, Wtxid};
|
||||||
use VarInt;
|
use crate::VarInt;
|
||||||
|
|
||||||
#[cfg(doc)]
|
#[cfg(doc)]
|
||||||
use util::sighash::SchnorrSighashType;
|
use util::sighash::SchnorrSighashType;
|
||||||
|
@ -895,17 +895,17 @@ mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
use core::str::FromStr;
|
use core::str::FromStr;
|
||||||
use blockdata::constants::WITNESS_SCALE_FACTOR;
|
use crate::blockdata::constants::WITNESS_SCALE_FACTOR;
|
||||||
use blockdata::script::Script;
|
use crate::blockdata::script::Script;
|
||||||
use consensus::encode::serialize;
|
use crate::consensus::encode::serialize;
|
||||||
use consensus::encode::deserialize;
|
use crate::consensus::encode::deserialize;
|
||||||
|
|
||||||
use hashes::Hash;
|
use crate::hashes::Hash;
|
||||||
use hashes::hex::FromHex;
|
use crate::hashes::hex::FromHex;
|
||||||
|
|
||||||
use hash_types::*;
|
use crate::hash_types::*;
|
||||||
use super::EcdsaSighashType;
|
use super::EcdsaSighashType;
|
||||||
use util::sighash::SighashCache;
|
use crate::util::sighash::SighashCache;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_outpoint() {
|
fn test_outpoint() {
|
||||||
|
@ -958,8 +958,8 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_is_coinbase () {
|
fn test_is_coinbase () {
|
||||||
use network::constants::Network;
|
use crate::network::constants::Network;
|
||||||
use blockdata::constants;
|
use crate::blockdata::constants;
|
||||||
|
|
||||||
let genesis = constants::genesis_block(Network::Bitcoin);
|
let genesis = constants::genesis_block(Network::Bitcoin);
|
||||||
assert! (genesis.txdata[0].is_coin_base());
|
assert! (genesis.txdata[0].is_coin_base());
|
||||||
|
|
|
@ -3,13 +3,13 @@
|
||||||
//! This module contains the [`Witness`] struct and related methods to operate on it
|
//! This module contains the [`Witness`] struct and related methods to operate on it
|
||||||
//!
|
//!
|
||||||
|
|
||||||
use blockdata::transaction::EcdsaSighashType;
|
use crate::blockdata::transaction::EcdsaSighashType;
|
||||||
use consensus::encode::{Error, MAX_VEC_SIZE};
|
use crate::consensus::encode::{Error, MAX_VEC_SIZE};
|
||||||
use consensus::{Decodable, Encodable, WriteExt};
|
use crate::consensus::{Decodable, Encodable, WriteExt};
|
||||||
use io::{self, Read, Write};
|
use crate::io::{self, Read, Write};
|
||||||
use prelude::*;
|
use crate::prelude::*;
|
||||||
use secp256k1::ecdsa;
|
use secp256k1::ecdsa;
|
||||||
use VarInt;
|
use crate::VarInt;
|
||||||
|
|
||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
use serde;
|
use serde;
|
||||||
|
@ -302,12 +302,12 @@ impl<'de> serde::Deserialize<'de> for Witness {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use blockdata::transaction::EcdsaSighashType;
|
use super::*;
|
||||||
use blockdata::witness::Witness;
|
|
||||||
use consensus::{deserialize, serialize};
|
use crate::consensus::{deserialize, serialize};
|
||||||
use hashes::hex::{FromHex, ToHex};
|
use crate::hashes::hex::{FromHex, ToHex};
|
||||||
use Transaction;
|
use crate::Transaction;
|
||||||
use secp256k1::ecdsa;
|
use crate::secp256k1::ecdsa;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_push() {
|
fn test_push() {
|
||||||
|
|
|
@ -27,24 +27,24 @@
|
||||||
//! typically big-endian decimals, etc.)
|
//! typically big-endian decimals, etc.)
|
||||||
//!
|
//!
|
||||||
|
|
||||||
use prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
use core::{fmt, mem, u32, convert::From};
|
use core::{fmt, mem, u32, convert::From};
|
||||||
#[cfg(feature = "std")] use std::error;
|
#[cfg(feature = "std")] use std::error;
|
||||||
|
|
||||||
use hashes::{sha256d, Hash, sha256};
|
use crate::hashes::{sha256d, Hash, sha256};
|
||||||
use hash_types::{BlockHash, FilterHash, TxMerkleNode, FilterHeader};
|
use crate::hash_types::{BlockHash, FilterHash, TxMerkleNode, FilterHeader};
|
||||||
|
|
||||||
use io::{self, Cursor, Read};
|
use crate::io::{self, Cursor, Read};
|
||||||
|
|
||||||
use util::endian;
|
use crate::util::endian;
|
||||||
use util::psbt;
|
use crate::util::psbt;
|
||||||
use util::taproot::TapLeafHash;
|
use crate::util::taproot::TapLeafHash;
|
||||||
use hashes::hex::ToHex;
|
use crate::hashes::hex::ToHex;
|
||||||
|
|
||||||
use blockdata::transaction::{TxOut, Transaction, TxIn};
|
use crate::blockdata::transaction::{TxOut, Transaction, TxIn};
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
use network::{message_blockdata::Inventory, address::{Address, AddrV2Message}};
|
use crate::network::{message_blockdata::Inventory, address::{Address, AddrV2Message}};
|
||||||
|
|
||||||
/// Encoding error
|
/// Encoding error
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -776,11 +776,11 @@ mod tests {
|
||||||
use core::{mem::{self, discriminant}, fmt};
|
use core::{mem::{self, discriminant}, fmt};
|
||||||
use super::{deserialize, serialize, Error, CheckedData, VarInt};
|
use super::{deserialize, serialize, Error, CheckedData, VarInt};
|
||||||
use super::{Transaction, BlockHash, FilterHash, TxMerkleNode, TxOut, TxIn};
|
use super::{Transaction, BlockHash, FilterHash, TxMerkleNode, TxOut, TxIn};
|
||||||
use consensus::{Encodable, deserialize_partial, Decodable};
|
use crate::consensus::{Encodable, deserialize_partial, Decodable};
|
||||||
use util::endian::{u64_to_array_le, u32_to_array_le, u16_to_array_le};
|
use crate::util::endian::{u64_to_array_le, u32_to_array_le, u16_to_array_le};
|
||||||
use secp256k1::rand::{thread_rng, Rng};
|
use secp256k1::rand::{thread_rng, Rng};
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
use network::{Address, message_blockdata::Inventory};
|
use crate::network::{Address, message_blockdata::Inventory};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn serialize_int_test() {
|
fn serialize_int_test() {
|
||||||
|
|
|
@ -18,8 +18,8 @@
|
||||||
//! chains (such as mainnet, testnet).
|
//! chains (such as mainnet, testnet).
|
||||||
//!
|
//!
|
||||||
|
|
||||||
use network::constants::Network;
|
use crate::network::constants::Network;
|
||||||
use util::uint::Uint256;
|
use crate::util::uint::Uint256;
|
||||||
|
|
||||||
/// Lowest possible difficulty for Mainnet. See comment on Params::pow_limit for more info.
|
/// Lowest possible difficulty for Mainnet. See comment on Params::pow_limit for more info.
|
||||||
const MAX_BITS_BITCOIN: Uint256 = Uint256([
|
const MAX_BITS_BITCOIN: Uint256 = Uint256([
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
//! hash).
|
//! hash).
|
||||||
//!
|
//!
|
||||||
|
|
||||||
use hashes::{Hash, sha256, sha256d, hash160};
|
use crate::hashes::{Hash, sha256, sha256d, hash160};
|
||||||
|
|
||||||
macro_rules! impl_hashencode {
|
macro_rules! impl_hashencode {
|
||||||
($hashtype:ident) => {
|
($hashtype:ident) => {
|
||||||
|
|
50
src/lib.rs
50
src/lib.rs
|
@ -115,33 +115,33 @@ pub mod consensus;
|
||||||
pub mod hash_types;
|
pub mod hash_types;
|
||||||
pub mod policy;
|
pub mod policy;
|
||||||
|
|
||||||
pub use hash_types::*;
|
pub use crate::hash_types::*;
|
||||||
pub use blockdata::block::Block;
|
pub use crate::blockdata::block::Block;
|
||||||
pub use blockdata::block::BlockHeader;
|
pub use crate::blockdata::block::BlockHeader;
|
||||||
pub use blockdata::script::Script;
|
pub use crate::blockdata::script::Script;
|
||||||
pub use blockdata::transaction::Transaction;
|
pub use crate::blockdata::transaction::Transaction;
|
||||||
pub use blockdata::transaction::TxIn;
|
pub use crate::blockdata::transaction::TxIn;
|
||||||
pub use blockdata::transaction::TxOut;
|
pub use crate::blockdata::transaction::TxOut;
|
||||||
pub use blockdata::transaction::OutPoint;
|
pub use crate::blockdata::transaction::OutPoint;
|
||||||
pub use blockdata::transaction::EcdsaSighashType;
|
pub use crate::blockdata::transaction::EcdsaSighashType;
|
||||||
pub use blockdata::witness::Witness;
|
pub use crate::blockdata::witness::Witness;
|
||||||
pub use consensus::encode::VarInt;
|
pub use crate::consensus::encode::VarInt;
|
||||||
pub use network::constants::Network;
|
pub use crate::network::constants::Network;
|
||||||
pub use util::Error;
|
pub use crate::util::Error;
|
||||||
pub use util::address::Address;
|
pub use crate::util::address::Address;
|
||||||
pub use util::address::AddressType;
|
pub use crate::util::address::AddressType;
|
||||||
pub use util::amount::Amount;
|
pub use crate::util::amount::Amount;
|
||||||
pub use util::amount::Denomination;
|
pub use crate::util::amount::Denomination;
|
||||||
pub use util::amount::SignedAmount;
|
pub use crate::util::amount::SignedAmount;
|
||||||
pub use util::merkleblock::MerkleBlock;
|
pub use crate::util::merkleblock::MerkleBlock;
|
||||||
pub use util::sighash::SchnorrSighashType;
|
pub use crate::util::sighash::SchnorrSighashType;
|
||||||
|
|
||||||
pub use util::ecdsa::{self, EcdsaSig, EcdsaSigError};
|
pub use crate::util::ecdsa::{self, EcdsaSig, EcdsaSigError};
|
||||||
pub use util::schnorr::{self, SchnorrSig, SchnorrSigError};
|
pub use crate::util::schnorr::{self, SchnorrSig, SchnorrSigError};
|
||||||
pub use util::key::{PrivateKey, PublicKey, XOnlyPublicKey, KeyPair};
|
pub use crate::util::key::{PrivateKey, PublicKey, XOnlyPublicKey, KeyPair};
|
||||||
pub use util::psbt;
|
pub use crate::util::psbt;
|
||||||
#[allow(deprecated)]
|
#[allow(deprecated)]
|
||||||
pub use blockdata::transaction::SigHashType;
|
pub use crate::blockdata::transaction::SigHashType;
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
|
@ -18,14 +18,14 @@
|
||||||
//! network addresses in Bitcoin messages.
|
//! network addresses in Bitcoin messages.
|
||||||
//!
|
//!
|
||||||
|
|
||||||
use prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
use core::{fmt, iter};
|
use core::{fmt, iter};
|
||||||
use std::net::{SocketAddr, Ipv6Addr, SocketAddrV4, SocketAddrV6, Ipv4Addr, ToSocketAddrs};
|
use std::net::{SocketAddr, Ipv6Addr, SocketAddrV4, SocketAddrV6, Ipv4Addr, ToSocketAddrs};
|
||||||
|
|
||||||
use io;
|
use crate::io;
|
||||||
use network::constants::ServiceFlags;
|
use crate::network::constants::ServiceFlags;
|
||||||
use consensus::encode::{self, Decodable, Encodable, VarInt, ReadExt, WriteExt};
|
use crate::consensus::encode::{self, Decodable, Encodable, VarInt, ReadExt, WriteExt};
|
||||||
|
|
||||||
/// A message which can be sent on the Bitcoin network
|
/// A message which can be sent on the Bitcoin network
|
||||||
#[derive(Clone, PartialEq, Eq, Hash)]
|
#[derive(Clone, PartialEq, Eq, Hash)]
|
||||||
|
@ -294,11 +294,11 @@ impl ToSocketAddrs for AddrV2Message {
|
||||||
mod test {
|
mod test {
|
||||||
use core::str::FromStr;
|
use core::str::FromStr;
|
||||||
use super::{AddrV2Message, AddrV2, Address};
|
use super::{AddrV2Message, AddrV2, Address};
|
||||||
use network::constants::ServiceFlags;
|
use crate::network::constants::ServiceFlags;
|
||||||
use std::net::{SocketAddr, IpAddr, Ipv4Addr, Ipv6Addr};
|
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]
|
#[test]
|
||||||
fn serialize_address_test() {
|
fn serialize_address_test() {
|
||||||
|
|
|
@ -39,8 +39,8 @@
|
||||||
|
|
||||||
use core::{fmt, ops, convert::From};
|
use core::{fmt, ops, convert::From};
|
||||||
|
|
||||||
use io;
|
use crate::io;
|
||||||
use consensus::encode::{self, Encodable, Decodable};
|
use crate::consensus::encode::{self, Encodable, Decodable};
|
||||||
|
|
||||||
/// Version of the protocol as appearing in network message headers
|
/// Version of the protocol as appearing in network message headers
|
||||||
/// This constant is used to signal to other peers which features you support.
|
/// This constant is used to signal to other peers which features you support.
|
||||||
|
@ -289,7 +289,7 @@ impl Decodable for ServiceFlags {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::{Network, ServiceFlags};
|
use super::{Network, ServiceFlags};
|
||||||
use consensus::encode::{deserialize, serialize};
|
use crate::consensus::encode::{deserialize, serialize};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn serialize_test() {
|
fn serialize_test() {
|
||||||
|
|
|
@ -18,20 +18,20 @@
|
||||||
//! are used for (de)serializing Bitcoin objects for transmission on the network.
|
//! are used for (de)serializing Bitcoin objects for transmission on the network.
|
||||||
//!
|
//!
|
||||||
|
|
||||||
use prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
use core::{mem, fmt, iter};
|
use core::{mem, fmt, iter};
|
||||||
|
|
||||||
use io;
|
use crate::io;
|
||||||
use blockdata::block;
|
use crate::blockdata::block;
|
||||||
use blockdata::transaction;
|
use crate::blockdata::transaction;
|
||||||
use network::address::{Address, AddrV2Message};
|
use crate::network::address::{Address, AddrV2Message};
|
||||||
use network::{message_network, message_bloom};
|
use crate::network::{message_network, message_bloom};
|
||||||
use network::message_blockdata;
|
use crate::network::message_blockdata;
|
||||||
use network::message_filter;
|
use crate::network::message_filter;
|
||||||
use consensus::encode::{CheckedData, Decodable, Encodable, VarInt, MAX_VEC_SIZE};
|
use crate::consensus::encode::{CheckedData, Decodable, Encodable, VarInt, MAX_VEC_SIZE};
|
||||||
use consensus::{encode, serialize};
|
use crate::consensus::{encode, serialize};
|
||||||
use util::merkleblock::MerkleBlock;
|
use crate::util::merkleblock::MerkleBlock;
|
||||||
|
|
||||||
/// The maximum number of [super::message_blockdata::Inventory] items in an `inv` message.
|
/// The maximum number of [super::message_blockdata::Inventory] items in an `inv` message.
|
||||||
///
|
///
|
||||||
|
@ -414,20 +414,20 @@ impl Decodable for RawNetworkMessage {
|
||||||
mod test {
|
mod test {
|
||||||
use std::net::Ipv4Addr;
|
use std::net::Ipv4Addr;
|
||||||
use super::{RawNetworkMessage, NetworkMessage, CommandString};
|
use super::{RawNetworkMessage, NetworkMessage, CommandString};
|
||||||
use network::constants::ServiceFlags;
|
use crate::network::constants::ServiceFlags;
|
||||||
use consensus::encode::{deserialize, deserialize_partial, serialize};
|
use crate::consensus::encode::{deserialize, deserialize_partial, serialize};
|
||||||
use hashes::hex::FromHex;
|
use crate::hashes::hex::FromHex;
|
||||||
use hashes::sha256d::Hash;
|
use crate::hashes::sha256d::Hash;
|
||||||
use hashes::Hash as HashTrait;
|
use crate::hashes::Hash as HashTrait;
|
||||||
use network::address::{Address, AddrV2, AddrV2Message};
|
use crate::network::address::{Address, AddrV2, AddrV2Message};
|
||||||
use super::message_network::{Reject, RejectReason, VersionMessage};
|
use super::message_network::{Reject, RejectReason, VersionMessage};
|
||||||
use network::message_blockdata::{Inventory, GetBlocksMessage, GetHeadersMessage};
|
use crate::network::message_blockdata::{Inventory, GetBlocksMessage, GetHeadersMessage};
|
||||||
use blockdata::block::{Block, BlockHeader};
|
use crate::blockdata::block::{Block, BlockHeader};
|
||||||
use network::message_filter::{GetCFilters, CFilter, GetCFHeaders, CFHeaders, GetCFCheckpt, CFCheckpt};
|
use crate::network::message_filter::{GetCFilters, CFilter, GetCFHeaders, CFHeaders, GetCFCheckpt, CFCheckpt};
|
||||||
use blockdata::transaction::Transaction;
|
use crate::blockdata::transaction::Transaction;
|
||||||
use blockdata::script::Script;
|
use crate::blockdata::script::Script;
|
||||||
use network::message_bloom::{FilterAdd, FilterLoad, BloomFlags};
|
use crate::network::message_bloom::{FilterAdd, FilterLoad, BloomFlags};
|
||||||
use MerkleBlock;
|
use crate::MerkleBlock;
|
||||||
|
|
||||||
fn hash(slice: [u8;32]) -> Hash {
|
fn hash(slice: [u8;32]) -> Hash {
|
||||||
Hash::from_slice(&slice).unwrap()
|
Hash::from_slice(&slice).unwrap()
|
||||||
|
|
|
@ -18,15 +18,15 @@
|
||||||
//! Bitcoin data (blocks and transactions) around.
|
//! 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 crate::network::constants;
|
||||||
use consensus::encode::{self, Decodable, Encodable};
|
use crate::consensus::encode::{self, Decodable, Encodable};
|
||||||
use hash_types::{BlockHash, Txid, Wtxid};
|
use crate::hash_types::{BlockHash, Txid, Wtxid};
|
||||||
|
|
||||||
/// An inventory item.
|
/// An inventory item.
|
||||||
#[derive(PartialEq, Eq, Clone, Debug, Copy, Hash, PartialOrd, Ord)]
|
#[derive(PartialEq, Eq, Clone, Debug, Copy, Hash, PartialOrd, Ord)]
|
||||||
|
@ -149,9 +149,9 @@ impl_consensus_encoding!(GetHeadersMessage, version, locator_hashes, stop_hash);
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::{Vec, GetHeadersMessage, GetBlocksMessage};
|
use super::{Vec, GetHeadersMessage, GetBlocksMessage};
|
||||||
|
|
||||||
use hashes::hex::FromHex;
|
use crate::hashes::hex::FromHex;
|
||||||
|
|
||||||
use consensus::encode::{deserialize, serialize};
|
use crate::consensus::encode::{deserialize, serialize};
|
||||||
use core::default::Default;
|
use core::default::Default;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
//! This module describes BIP37 Connection Bloom filtering network messages.
|
//! This module describes BIP37 Connection Bloom filtering network messages.
|
||||||
//!
|
//!
|
||||||
|
|
||||||
use consensus::encode;
|
use crate::consensus::encode;
|
||||||
use consensus::{Decodable, Encodable, ReadExt};
|
use crate::consensus::{Decodable, Encodable, ReadExt};
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
/// `filterload` message sets the current bloom filter
|
/// `filterload` message sets the current bloom filter
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
//! This module describes BIP157 Client Side Block Filtering network messages.
|
//! This module describes BIP157 Client Side Block Filtering network messages.
|
||||||
//!
|
//!
|
||||||
|
|
||||||
use hash_types::{BlockHash, FilterHash, FilterHeader};
|
use crate::hash_types::{BlockHash, FilterHash, FilterHeader};
|
||||||
|
|
||||||
/// getcfilters message
|
/// getcfilters message
|
||||||
#[derive(PartialEq, Eq, Clone, Debug)]
|
#[derive(PartialEq, Eq, Clone, Debug)]
|
||||||
|
|
|
@ -18,15 +18,15 @@
|
||||||
//! capabilities.
|
//! capabilities.
|
||||||
//!
|
//!
|
||||||
|
|
||||||
use prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
use io;
|
use crate::io;
|
||||||
|
|
||||||
use network::address::Address;
|
use crate::network::address::Address;
|
||||||
use network::constants::{self, ServiceFlags};
|
use crate::network::constants::{self, ServiceFlags};
|
||||||
use consensus::{Encodable, Decodable, ReadExt};
|
use crate::consensus::{Encodable, Decodable, ReadExt};
|
||||||
use consensus::encode;
|
use crate::consensus::encode;
|
||||||
use hashes::sha256d;
|
use crate::hashes::sha256d;
|
||||||
|
|
||||||
/// Some simple messages
|
/// Some simple messages
|
||||||
|
|
||||||
|
@ -149,11 +149,11 @@ mod tests {
|
||||||
use super::Reject;
|
use super::Reject;
|
||||||
use super::RejectReason;
|
use super::RejectReason;
|
||||||
|
|
||||||
use hashes::hex::FromHex;
|
use crate::hashes::hex::FromHex;
|
||||||
use hashes::sha256d::Hash;
|
use crate::hashes::sha256d::Hash;
|
||||||
use network::constants::ServiceFlags;
|
use crate::network::constants::ServiceFlags;
|
||||||
|
|
||||||
use consensus::encode::{deserialize, serialize};
|
use crate::consensus::encode::{deserialize, serialize};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn version_message_test() {
|
fn version_message_test() {
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
//! of Bitcoin data and network messages.
|
//! of Bitcoin data and network messages.
|
||||||
//!
|
//!
|
||||||
|
|
||||||
use io;
|
use crate::io;
|
||||||
use core::fmt;
|
use core::fmt;
|
||||||
#[cfg(feature = "std")] use std::error;
|
#[cfg(feature = "std")] use std::error;
|
||||||
|
|
||||||
|
|
|
@ -23,9 +23,9 @@
|
||||||
//!
|
//!
|
||||||
|
|
||||||
use core::fmt;
|
use core::fmt;
|
||||||
use io::{Read, BufReader};
|
use crate::io::{Read, BufReader};
|
||||||
|
|
||||||
use consensus::{encode, Decodable};
|
use crate::consensus::{encode, Decodable};
|
||||||
|
|
||||||
/// Struct used to configure stream reader function
|
/// Struct used to configure stream reader function
|
||||||
pub struct StreamReader<R: Read> {
|
pub struct StreamReader<R: Read> {
|
||||||
|
@ -60,13 +60,13 @@ impl<R: Read> StreamReader<R> {
|
||||||
mod test {
|
mod test {
|
||||||
use std::thread;
|
use std::thread;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use io::{BufReader, Write};
|
use crate::io::{BufReader, Write};
|
||||||
use std::net::{TcpListener, TcpStream, Shutdown};
|
use std::net::{TcpListener, TcpStream, Shutdown};
|
||||||
use std::thread::JoinHandle;
|
use std::thread::JoinHandle;
|
||||||
use network::constants::ServiceFlags;
|
use crate::network::constants::ServiceFlags;
|
||||||
|
|
||||||
use super::StreamReader;
|
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
|
// First, let's define some byte arrays for sample messages - dumps are taken from live
|
||||||
// Bitcoin Core node v0.17.1 with Wireshark
|
// Bitcoin Core node v0.17.1 with Wireshark
|
||||||
|
@ -274,10 +274,10 @@ mod test {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn read_block_from_file_test() {
|
fn read_block_from_file_test() {
|
||||||
use io;
|
use crate::io;
|
||||||
use consensus::serialize;
|
use crate::consensus::serialize;
|
||||||
use hashes::hex::FromHex;
|
use crate::hashes::hex::FromHex;
|
||||||
use Block;
|
use crate::Block;
|
||||||
|
|
||||||
let normal_data = Vec::from_hex("010000004ddccd549d28f385ab457e98d1b11ce80bfea2c5ab93015ade4973e400000000bf4473e53794beae34e64fccc471dace6ae544180816f89591894e0f417a914cd74d6e49ffff001d323b3a7b0201000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0804ffff001d026e04ffffffff0100f2052a0100000043410446ef0102d1ec5240f0d061a4246c1bdef63fc3dbab7733052fbbf0ecd8f41fc26bf049ebb4f9527f374280259e7cfa99c48b0e3f39c51347a19a5819651503a5ac00000000010000000321f75f3139a013f50f315b23b0c9a2b6eac31e2bec98e5891c924664889942260000000049483045022100cb2c6b346a978ab8c61b18b5e9397755cbd17d6eb2fe0083ef32e067fa6c785a02206ce44e613f31d9a6b0517e46f3db1576e9812cc98d159bfdaf759a5014081b5c01ffffffff79cda0945903627c3da1f85fc95d0b8ee3e76ae0cfdc9a65d09744b1f8fc85430000000049483045022047957cdd957cfd0becd642f6b84d82f49b6cb4c51a91f49246908af7c3cfdf4a022100e96b46621f1bffcf5ea5982f88cef651e9354f5791602369bf5a82a6cd61a62501fffffffffe09f5fe3ffbf5ee97a54eb5e5069e9da6b4856ee86fc52938c2f979b0f38e82000000004847304402204165be9a4cbab8049e1af9723b96199bfd3e85f44c6b4c0177e3962686b26073022028f638da23fc003760861ad481ead4099312c60030d4cb57820ce4d33812a5ce01ffffffff01009d966b01000000434104ea1feff861b51fe3f5f8a3b12d0f4712db80e919548a80839fc47c6a21e66d957e9c5d8cd108c7a2d2324bad71f9904ac0ae7336507d785b17a2c115e427a32fac00000000").unwrap();
|
let normal_data = Vec::from_hex("010000004ddccd549d28f385ab457e98d1b11ce80bfea2c5ab93015ade4973e400000000bf4473e53794beae34e64fccc471dace6ae544180816f89591894e0f417a914cd74d6e49ffff001d323b3a7b0201000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0804ffff001d026e04ffffffff0100f2052a0100000043410446ef0102d1ec5240f0d061a4246c1bdef63fc3dbab7733052fbbf0ecd8f41fc26bf049ebb4f9527f374280259e7cfa99c48b0e3f39c51347a19a5819651503a5ac00000000010000000321f75f3139a013f50f315b23b0c9a2b6eac31e2bec98e5891c924664889942260000000049483045022100cb2c6b346a978ab8c61b18b5e9397755cbd17d6eb2fe0083ef32e067fa6c785a02206ce44e613f31d9a6b0517e46f3db1576e9812cc98d159bfdaf759a5014081b5c01ffffffff79cda0945903627c3da1f85fc95d0b8ee3e76ae0cfdc9a65d09744b1f8fc85430000000049483045022047957cdd957cfd0becd642f6b84d82f49b6cb4c51a91f49246908af7c3cfdf4a022100e96b46621f1bffcf5ea5982f88cef651e9354f5791602369bf5a82a6cd61a62501fffffffffe09f5fe3ffbf5ee97a54eb5e5069e9da6b4856ee86fc52938c2f979b0f38e82000000004847304402204165be9a4cbab8049e1af9723b96199bfd3e85f44c6b4c0177e3962686b26073022028f638da23fc003760861ad481ead4099312c60030d4cb57820ce4d33812a5ce01ffffffff01009d966b01000000434104ea1feff861b51fe3f5f8a3b12d0f4712db80e919548a80839fc47c6a21e66d957e9c5d8cd108c7a2d2324bad71f9904ac0ae7336507d785b17a2c115e427a32fac00000000").unwrap();
|
||||||
let cutoff_data = Vec::from_hex("010000004ddccd549d28f385ab457e98d1b11ce80bfea2c5ab93015ade4973e400000000bf4473e53794beae34e64fccc471dace6ae544180816f89591894e0f417a914cd74d6e49ffff001d323b3a7b0201000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0804ffff001d026e04ffffffff0100f2052a0100000043410446ef0102d1ec5240f0d061a4246c1bdef63fc3dbab7733052fbbf0ecd8f41fc26bf049ebb4f9527f374280259e7cfa99c48b0e3f39c51347a19a5819651503a5ac00000000010000000321f75f3139a013f50f315b23b0c9a2b6eac31e2bec98e5891c924664889942260000000049483045022100cb2c6b346a978ab8c61b18b5e9397755cbd17d6eb2fe0083ef32e067fa6c785a02206ce44e613f31d9a6b0517e46f3db1576e9812cc98d159bfdaf759a5014081b5c01ffffffff79cda0945903627c3da1f85fc95d0b8ee3e76ae0cfdc9a65d09744b1f8fc85430000000049483045022047957cdd957cfd0becd642f6b84d82f49b6cb4c51a91f49246908af7c3cfdf4a022100e96b46621f1bffcf5ea5982f88cef651e9354f5791602369bf5a82a6cd61a62501fffffffffe09f5fe3ffbf5ee97a54eb5e5069e9da6b4856ee86fc52938c2f979b0f38e82000000004847304402204165be9a4cbab8049e1af9723b96199bfd3e85f44c6b4c0177e3962686b26073022028f638da23fc003760861ad481ead4099312c60030d4cb57820ce4d33812a5ce01ffffffff01009d966b01000000434104ea1feff861b51fe3f5f8a3b12d0f4712db80e919548a80839fc47c6a21e66d957e9c5d8cd108c7a2d2324bad71f9904ac0ae7336507d785b17a2c115e427a32fac").unwrap();
|
let cutoff_data = Vec::from_hex("010000004ddccd549d28f385ab457e98d1b11ce80bfea2c5ab93015ade4973e400000000bf4473e53794beae34e64fccc471dace6ae544180816f89591894e0f417a914cd74d6e49ffff001d323b3a7b0201000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0804ffff001d026e04ffffffff0100f2052a0100000043410446ef0102d1ec5240f0d061a4246c1bdef63fc3dbab7733052fbbf0ecd8f41fc26bf049ebb4f9527f374280259e7cfa99c48b0e3f39c51347a19a5819651503a5ac00000000010000000321f75f3139a013f50f315b23b0c9a2b6eac31e2bec98e5891c924664889942260000000049483045022100cb2c6b346a978ab8c61b18b5e9397755cbd17d6eb2fe0083ef32e067fa6c785a02206ce44e613f31d9a6b0517e46f3db1576e9812cc98d159bfdaf759a5014081b5c01ffffffff79cda0945903627c3da1f85fc95d0b8ee3e76ae0cfdc9a65d09744b1f8fc85430000000049483045022047957cdd957cfd0becd642f6b84d82f49b6cb4c51a91f49246908af7c3cfdf4a022100e96b46621f1bffcf5ea5982f88cef651e9354f5791602369bf5a82a6cd61a62501fffffffffe09f5fe3ffbf5ee97a54eb5e5069e9da6b4856ee86fc52938c2f979b0f38e82000000004847304402204165be9a4cbab8049e1af9723b96199bfd3e85f44c6b4c0177e3962686b26073022028f638da23fc003760861ad481ead4099312c60030d4cb57820ce4d33812a5ce01ffffffff01009d966b01000000434104ea1feff861b51fe3f5f8a3b12d0f4712db80e919548a80839fc47c6a21e66d957e9c5d8cd108c7a2d2324bad71f9904ac0ae7336507d785b17a2c115e427a32fac").unwrap();
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
//! let address = Address::p2pkh(&public_key, Network::Bitcoin);
|
//! let address = Address::p2pkh(&public_key, Network::Bitcoin);
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
use prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
use core::fmt;
|
use core::fmt;
|
||||||
use core::num::ParseIntError;
|
use core::num::ParseIntError;
|
||||||
|
@ -41,16 +41,16 @@ use core::str::FromStr;
|
||||||
|
|
||||||
use secp256k1::{Secp256k1, Verification, XOnlyPublicKey};
|
use secp256k1::{Secp256k1, Verification, XOnlyPublicKey};
|
||||||
use bech32;
|
use bech32;
|
||||||
use hashes::{sha256, Hash, HashEngine};
|
use crate::hashes::{sha256, Hash, HashEngine};
|
||||||
use hash_types::{PubkeyHash, ScriptHash};
|
use crate::hash_types::{PubkeyHash, ScriptHash};
|
||||||
use blockdata::{script, opcodes};
|
use crate::blockdata::{script, opcodes};
|
||||||
use blockdata::constants::{PUBKEY_ADDRESS_PREFIX_MAIN, SCRIPT_ADDRESS_PREFIX_MAIN, PUBKEY_ADDRESS_PREFIX_TEST, SCRIPT_ADDRESS_PREFIX_TEST, MAX_SCRIPT_ELEMENT_SIZE};
|
use crate::blockdata::constants::{PUBKEY_ADDRESS_PREFIX_MAIN, SCRIPT_ADDRESS_PREFIX_MAIN, PUBKEY_ADDRESS_PREFIX_TEST, SCRIPT_ADDRESS_PREFIX_TEST, MAX_SCRIPT_ELEMENT_SIZE};
|
||||||
use network::constants::Network;
|
use crate::network::constants::Network;
|
||||||
use util::base58;
|
use crate::util::base58;
|
||||||
use util::taproot::TapBranchHash;
|
use crate::util::taproot::TapBranchHash;
|
||||||
use util::key::PublicKey;
|
use crate::util::key::PublicKey;
|
||||||
use blockdata::script::Instruction;
|
use crate::blockdata::script::Instruction;
|
||||||
use util::schnorr::{TapTweak, UntweakedPublicKey, TweakedPublicKey};
|
use crate::util::schnorr::{TapTweak, UntweakedPublicKey, TweakedPublicKey};
|
||||||
|
|
||||||
/// Address error.
|
/// Address error.
|
||||||
#[derive(Debug, PartialEq, Eq, Clone)]
|
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||||
|
@ -889,22 +889,22 @@ impl fmt::Debug for Address {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convert a byte array of a pubkey hash into a segwit redeem hash
|
/// Convert a byte array of a pubkey hash into a segwit redeem hash
|
||||||
fn segwit_redeem_hash(pubkey_hash: &[u8]) -> ::hashes::hash160::Hash {
|
fn segwit_redeem_hash(pubkey_hash: &[u8]) -> crate::hashes::hash160::Hash {
|
||||||
let mut sha_engine = sha256::Hash::engine();
|
let mut sha_engine = sha256::Hash::engine();
|
||||||
sha_engine.input(&[0, 20]);
|
sha_engine.input(&[0, 20]);
|
||||||
sha_engine.input(pubkey_hash);
|
sha_engine.input(pubkey_hash);
|
||||||
::hashes::hash160::Hash::from_engine(sha_engine)
|
crate::hashes::hash160::Hash::from_engine(sha_engine)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use core::str::FromStr;
|
use core::str::FromStr;
|
||||||
|
|
||||||
use hashes::hex::{FromHex, ToHex};
|
use crate::hashes::hex::{FromHex, ToHex};
|
||||||
|
|
||||||
use blockdata::script::Script;
|
use crate::blockdata::script::Script;
|
||||||
use network::constants::Network::{Bitcoin, Testnet};
|
use crate::network::constants::Network::{Bitcoin, Testnet};
|
||||||
use util::key::PublicKey;
|
use crate::util::key::PublicKey;
|
||||||
use secp256k1::XOnlyPublicKey;
|
use secp256k1::XOnlyPublicKey;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
//! We refer to the documentation on the types for more information.
|
//! 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, default, str::FromStr, cmp::Ordering};
|
||||||
use core::fmt::{self, Write};
|
use core::fmt::{self, Write};
|
||||||
|
@ -1201,7 +1201,7 @@ impl<T> CheckedSum<SignedAmount> for T where T: Iterator<Item=SignedAmount> {
|
||||||
}
|
}
|
||||||
|
|
||||||
mod private {
|
mod private {
|
||||||
use ::{Amount, SignedAmount};
|
use crate::{Amount, SignedAmount};
|
||||||
|
|
||||||
/// Used to seal the `CheckedSum` trait
|
/// Used to seal the `CheckedSum` trait
|
||||||
pub trait SumSeal<A> {}
|
pub trait SumSeal<A> {}
|
||||||
|
|
|
@ -18,14 +18,14 @@
|
||||||
//! strings respectively.
|
//! strings respectively.
|
||||||
//!
|
//!
|
||||||
|
|
||||||
use prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
use core::{fmt, str, iter, slice};
|
use core::{fmt, str, iter, slice};
|
||||||
|
|
||||||
use hashes::{sha256d, Hash, hex};
|
use crate::hashes::{sha256d, Hash, hex};
|
||||||
use secp256k1;
|
use secp256k1;
|
||||||
|
|
||||||
use util::{endian, key};
|
use crate::util::{endian, key};
|
||||||
|
|
||||||
/// An error that might occur during base58 decoding
|
/// An error that might occur during base58 decoding
|
||||||
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone)]
|
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone)]
|
||||||
|
@ -268,7 +268,7 @@ impl From<key::Error> for Error {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use hashes::hex::FromHex;
|
use crate::hashes::hex::FromHex;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_base58_encode() {
|
fn test_base58_encode() {
|
||||||
|
|
|
@ -19,16 +19,16 @@
|
||||||
//! signatures, which are placed in the scriptSig.
|
//! signatures, which are placed in the scriptSig.
|
||||||
//!
|
//!
|
||||||
|
|
||||||
use hashes::Hash;
|
use crate::hashes::Hash;
|
||||||
use hash_types::Sighash;
|
use crate::hash_types::Sighash;
|
||||||
use blockdata::script::Script;
|
use crate::blockdata::script::Script;
|
||||||
use blockdata::witness::Witness;
|
use crate::blockdata::witness::Witness;
|
||||||
use blockdata::transaction::{Transaction, TxIn, EcdsaSighashType};
|
use crate::blockdata::transaction::{Transaction, TxIn, EcdsaSighashType};
|
||||||
use consensus::{encode, Encodable};
|
use crate::consensus::{encode, Encodable};
|
||||||
|
|
||||||
use io;
|
use crate::io;
|
||||||
use core::ops::{Deref, DerefMut};
|
use core::ops::{Deref, DerefMut};
|
||||||
use util::sighash;
|
use crate::util::sighash;
|
||||||
|
|
||||||
/// Parts of a sighash which are common across inputs or signatures, and which are
|
/// Parts of a sighash which are common across inputs or signatures, and which are
|
||||||
/// sufficient (in conjunction with a private key) to sign the transaction
|
/// sufficient (in conjunction with a private key) to sign the transaction
|
||||||
|
@ -188,14 +188,14 @@ impl<R: DerefMut<Target = Transaction>> SigHashCache<R> {
|
||||||
#[allow(deprecated)]
|
#[allow(deprecated)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use hash_types::Sighash;
|
use crate::hash_types::Sighash;
|
||||||
use blockdata::script::Script;
|
use crate::blockdata::script::Script;
|
||||||
use blockdata::transaction::Transaction;
|
use crate::blockdata::transaction::Transaction;
|
||||||
use consensus::encode::deserialize;
|
use crate::consensus::encode::deserialize;
|
||||||
use network::constants::Network;
|
use crate::network::constants::Network;
|
||||||
use util::address::Address;
|
use crate::util::address::Address;
|
||||||
use util::key::PublicKey;
|
use crate::util::key::PublicKey;
|
||||||
use hashes::hex::FromHex;
|
use crate::hashes::hex::FromHex;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
|
|
@ -45,21 +45,21 @@
|
||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
|
|
||||||
use prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
use io::{self, Cursor};
|
use crate::io::{self, Cursor};
|
||||||
use core::fmt::{self, Display, Formatter};
|
use core::fmt::{self, Display, Formatter};
|
||||||
use core::cmp::{self, Ordering};
|
use core::cmp::{self, Ordering};
|
||||||
|
|
||||||
use hashes::{Hash, siphash24};
|
use crate::hashes::{Hash, siphash24};
|
||||||
use hash_types::{BlockHash, FilterHash, FilterHeader};
|
use crate::hash_types::{BlockHash, FilterHash, FilterHeader};
|
||||||
|
|
||||||
use blockdata::block::Block;
|
use crate::blockdata::block::Block;
|
||||||
use blockdata::script::Script;
|
use crate::blockdata::script::Script;
|
||||||
use blockdata::transaction::OutPoint;
|
use crate::blockdata::transaction::OutPoint;
|
||||||
use consensus::{Decodable, Encodable};
|
use crate::consensus::{Decodable, Encodable};
|
||||||
use consensus::encode::VarInt;
|
use crate::consensus::encode::VarInt;
|
||||||
use util::endian;
|
use crate::util::endian;
|
||||||
|
|
||||||
/// Golomb encoding parameter as in BIP-158, see also https://gist.github.com/sipa/576d5f09c3b86c3b1b75598d799fc845
|
/// Golomb encoding parameter as in BIP-158, see also https://gist.github.com/sipa/576d5f09c3b86c3b1b75598d799fc845
|
||||||
const P: u8 = 19;
|
const P: u8 = 19;
|
||||||
|
@ -511,17 +511,17 @@ impl<'a> BitStreamWriter<'a> {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use io::Cursor;
|
use crate::io::Cursor;
|
||||||
|
|
||||||
use hash_types::BlockHash;
|
use crate::hash_types::BlockHash;
|
||||||
use hashes::hex::FromHex;
|
use crate::hashes::hex::FromHex;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
extern crate serde_json;
|
extern crate serde_json;
|
||||||
use self::serde_json::Value;
|
use self::serde_json::Value;
|
||||||
|
|
||||||
use consensus::encode::deserialize;
|
use crate::consensus::encode::deserialize;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -17,21 +17,21 @@
|
||||||
//! at <https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki>.
|
//! at <https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki>.
|
||||||
//!
|
//!
|
||||||
|
|
||||||
use prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
use io::Write;
|
use crate::io::Write;
|
||||||
use core::{fmt, str::FromStr, default::Default};
|
use core::{fmt, str::FromStr, default::Default};
|
||||||
use core::ops::Index;
|
use core::ops::Index;
|
||||||
#[cfg(feature = "std")] use std::error;
|
#[cfg(feature = "std")] use std::error;
|
||||||
#[cfg(feature = "serde")] use serde;
|
#[cfg(feature = "serde")] use serde;
|
||||||
|
|
||||||
use hash_types::XpubIdentifier;
|
use crate::hash_types::XpubIdentifier;
|
||||||
use hashes::{sha512, Hash, HashEngine, Hmac, HmacEngine, hex};
|
use crate::hashes::{sha512, Hash, HashEngine, Hmac, HmacEngine, hex};
|
||||||
use secp256k1::{self, Secp256k1, XOnlyPublicKey};
|
use secp256k1::{self, Secp256k1, XOnlyPublicKey};
|
||||||
|
|
||||||
use network::constants::Network;
|
use crate::network::constants::Network;
|
||||||
use util::{base58, endian, key};
|
use crate::util::{base58, endian, key};
|
||||||
use util::key::{PublicKey, PrivateKey, KeyPair};
|
use crate::util::key::{PublicKey, PrivateKey, KeyPair};
|
||||||
|
|
||||||
/// A chain code
|
/// A chain code
|
||||||
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
|
@ -846,9 +846,9 @@ mod tests {
|
||||||
use core::str::FromStr;
|
use core::str::FromStr;
|
||||||
|
|
||||||
use secp256k1::{self, Secp256k1};
|
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]
|
#[test]
|
||||||
fn test_parse_derivation_path() {
|
fn test_parse_derivation_path() {
|
||||||
|
|
|
@ -16,13 +16,13 @@
|
||||||
//!
|
//!
|
||||||
//! This module provides ECDSA signatures used Bitcoin that can be roundtrip (de)serialized.
|
//! This module provides ECDSA signatures used Bitcoin that can be roundtrip (de)serialized.
|
||||||
|
|
||||||
use prelude::*;
|
use crate::prelude::*;
|
||||||
use core::str::FromStr;
|
use core::str::FromStr;
|
||||||
use core::{fmt, iter};
|
use core::{fmt, iter};
|
||||||
use hashes::hex::{self, FromHex};
|
use crate::hashes::hex::{self, FromHex};
|
||||||
use blockdata::transaction::NonStandardSighashType;
|
use crate::blockdata::transaction::NonStandardSighashType;
|
||||||
use secp256k1;
|
use secp256k1;
|
||||||
use EcdsaSighashType;
|
use crate::EcdsaSighashType;
|
||||||
|
|
||||||
/// An ECDSA signature with the corresponding hash type.
|
/// An ECDSA signature with the corresponding hash type.
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||||
|
|
|
@ -19,13 +19,13 @@
|
||||||
|
|
||||||
use core::iter;
|
use core::iter;
|
||||||
|
|
||||||
use prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
use io;
|
use crate::io;
|
||||||
use core::cmp::min;
|
use core::cmp::min;
|
||||||
|
|
||||||
use hashes::Hash;
|
use crate::hashes::Hash;
|
||||||
use consensus::encode::Encodable;
|
use crate::consensus::encode::Encodable;
|
||||||
|
|
||||||
/// Calculates the merkle root of a list of *hashes*, inline (in place) in `hashes`.
|
/// Calculates the merkle root of a list of *hashes*, inline (in place) in `hashes`.
|
||||||
///
|
///
|
||||||
|
@ -109,10 +109,10 @@ where
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use consensus::encode::deserialize;
|
use crate::consensus::encode::deserialize;
|
||||||
use hashes::sha256d;
|
use crate::hashes::sha256d;
|
||||||
|
|
||||||
use blockdata::block::Block;
|
use crate::blockdata::block::Block;
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -18,18 +18,18 @@
|
||||||
|
|
||||||
pub use secp256k1::{XOnlyPublicKey, KeyPair};
|
pub use secp256k1::{XOnlyPublicKey, KeyPair};
|
||||||
|
|
||||||
use prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
use core::{ops, str::FromStr};
|
use core::{ops, str::FromStr};
|
||||||
use core::fmt::{self, Write};
|
use core::fmt::{self, Write};
|
||||||
use io;
|
use crate::io;
|
||||||
#[cfg(feature = "std")] use std::error;
|
#[cfg(feature = "std")] use std::error;
|
||||||
|
|
||||||
use secp256k1::{self, Secp256k1};
|
use secp256k1::{self, Secp256k1};
|
||||||
use network::constants::Network;
|
use crate::network::constants::Network;
|
||||||
use hashes::{Hash, hash160, hex, hex::FromHex};
|
use crate::hashes::{Hash, hash160, hex, hex::FromHex};
|
||||||
use hash_types::{PubkeyHash, WPubkeyHash};
|
use crate::hash_types::{PubkeyHash, WPubkeyHash};
|
||||||
use util::base58;
|
use crate::util::base58;
|
||||||
|
|
||||||
/// A key-related error.
|
/// A key-related error.
|
||||||
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
|
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
|
||||||
|
@ -482,14 +482,14 @@ impl<'de> ::serde::Deserialize<'de> for PublicKey {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use io;
|
use crate::io;
|
||||||
use super::{PrivateKey, PublicKey};
|
use super::{PrivateKey, PublicKey};
|
||||||
use secp256k1::Secp256k1;
|
use secp256k1::Secp256k1;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use hashes::hex::ToHex;
|
use crate::hashes::hex::ToHex;
|
||||||
use network::constants::Network::Testnet;
|
use crate::network::constants::Network::Testnet;
|
||||||
use network::constants::Network::Bitcoin;
|
use crate::network::constants::Network::Bitcoin;
|
||||||
use util::address::Address;
|
use crate::util::address::Address;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_key_derivation() {
|
fn test_key_derivation() {
|
||||||
|
|
|
@ -52,18 +52,18 @@
|
||||||
//! assert_eq!(1, index[0]);
|
//! assert_eq!(1, index[0]);
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
use prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
use io;
|
use crate::io;
|
||||||
|
|
||||||
use hashes::Hash;
|
use crate::hashes::Hash;
|
||||||
use hash_types::{Txid, TxMerkleNode};
|
use crate::hash_types::{Txid, TxMerkleNode};
|
||||||
|
|
||||||
use blockdata::transaction::Transaction;
|
use crate::blockdata::transaction::Transaction;
|
||||||
use blockdata::constants::{MAX_BLOCK_WEIGHT, MIN_TRANSACTION_WEIGHT};
|
use crate::blockdata::constants::{MAX_BLOCK_WEIGHT, MIN_TRANSACTION_WEIGHT};
|
||||||
use consensus::encode::{self, Decodable, Encodable};
|
use crate::consensus::encode::{self, Decodable, Encodable};
|
||||||
use util::merkleblock::MerkleBlockError::*;
|
use crate::util::merkleblock::MerkleBlockError::*;
|
||||||
use {Block, BlockHeader};
|
use crate::{Block, BlockHeader};
|
||||||
|
|
||||||
/// An error when verifying the merkle block
|
/// An error when verifying the merkle block
|
||||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||||
|
@ -511,15 +511,15 @@ impl Decodable for MerkleBlock {
|
||||||
mod tests {
|
mod tests {
|
||||||
use core::cmp::min;
|
use core::cmp::min;
|
||||||
|
|
||||||
use hashes::Hash;
|
use crate::hashes::Hash;
|
||||||
use hashes::hex::{FromHex, ToHex};
|
use crate::hashes::hex::{FromHex, ToHex};
|
||||||
use hash_types::{Txid, TxMerkleNode};
|
use crate::hash_types::{Txid, TxMerkleNode};
|
||||||
use secp256k1::rand::prelude::*;
|
use secp256k1::rand::prelude::*;
|
||||||
|
|
||||||
use consensus::encode::{deserialize, serialize};
|
use crate::consensus::encode::{deserialize, serialize};
|
||||||
use util::hash::bitcoin_merkle_root;
|
use crate::util::hash::bitcoin_merkle_root;
|
||||||
use util::merkleblock::{MerkleBlock, PartialMerkleTree};
|
use crate::util::merkleblock::{MerkleBlock, PartialMerkleTree};
|
||||||
use Block;
|
use crate::Block;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn pmt_tests() {
|
fn pmt_tests() {
|
||||||
|
|
|
@ -18,12 +18,12 @@
|
||||||
//! recovery when library is used with the `secp-recovery` feature.
|
//! recovery when library is used with the `secp-recovery` feature.
|
||||||
//!
|
//!
|
||||||
|
|
||||||
use prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
use hashes::{sha256d, Hash, HashEngine};
|
use crate::hashes::{sha256d, Hash, HashEngine};
|
||||||
|
|
||||||
use blockdata::opcodes;
|
use crate::blockdata::opcodes;
|
||||||
use consensus::{encode, Encodable};
|
use crate::consensus::{encode, Encodable};
|
||||||
|
|
||||||
#[cfg(feature = "secp-recovery")]
|
#[cfg(feature = "secp-recovery")]
|
||||||
#[cfg_attr(docsrs, doc(cfg(feature = "secp-recovery")))]
|
#[cfg_attr(docsrs, doc(cfg(feature = "secp-recovery")))]
|
||||||
|
@ -38,12 +38,12 @@ mod message_signing {
|
||||||
use core::fmt;
|
use core::fmt;
|
||||||
#[cfg(feature = "std")] use std::error;
|
#[cfg(feature = "std")] use std::error;
|
||||||
|
|
||||||
use hashes::sha256d;
|
use crate::hashes::sha256d;
|
||||||
use secp256k1;
|
use secp256k1;
|
||||||
use secp256k1::ecdsa::{RecoveryId, RecoverableSignature};
|
use secp256k1::ecdsa::{RecoveryId, RecoverableSignature};
|
||||||
|
|
||||||
use util::key::PublicKey;
|
use crate::util::key::PublicKey;
|
||||||
use util::address::{Address, AddressType};
|
use crate::util::address::{Address, AddressType};
|
||||||
|
|
||||||
/// An error used for dealing with Bitcoin Signed Messages.
|
/// An error used for dealing with Bitcoin Signed Messages.
|
||||||
#[cfg_attr(docsrs, doc(cfg(feature = "secp-recovery")))]
|
#[cfg_attr(docsrs, doc(cfg(feature = "secp-recovery")))]
|
||||||
|
@ -267,7 +267,7 @@ pub fn signed_msg_hash(msg: &str) -> sha256d::Hash {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use hashes::hex::ToHex;
|
use crate::hashes::hex::ToHex;
|
||||||
use super::script_find_and_remove;
|
use super::script_find_and_remove;
|
||||||
use super::signed_msg_hash;
|
use super::signed_msg_hash;
|
||||||
|
|
||||||
|
|
|
@ -36,13 +36,13 @@ pub mod sighash;
|
||||||
|
|
||||||
pub(crate) mod endian;
|
pub(crate) mod endian;
|
||||||
|
|
||||||
use prelude::*;
|
use crate::prelude::*;
|
||||||
use io;
|
use crate::io;
|
||||||
use core::fmt;
|
use core::fmt;
|
||||||
#[cfg(feature = "std")] use std::error;
|
#[cfg(feature = "std")] use std::error;
|
||||||
|
|
||||||
use network;
|
use crate::network;
|
||||||
use consensus::encode;
|
use crate::consensus::encode;
|
||||||
|
|
||||||
/// A trait which allows numbers to act as fixed-size bit arrays
|
/// A trait which allows numbers to act as fixed-size bit arrays
|
||||||
pub trait BitArray {
|
pub trait BitArray {
|
||||||
|
|
|
@ -12,16 +12,16 @@
|
||||||
// If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
|
// If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||||
//
|
//
|
||||||
|
|
||||||
use prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
use core::fmt;
|
use core::fmt;
|
||||||
|
|
||||||
use blockdata::transaction::Transaction;
|
use crate::blockdata::transaction::Transaction;
|
||||||
use consensus::encode;
|
use crate::consensus::encode;
|
||||||
use util::psbt::raw;
|
use crate::util::psbt::raw;
|
||||||
|
|
||||||
use hashes;
|
use crate::hashes;
|
||||||
use util::bip32::ExtendedPubKey;
|
use crate::util::bip32::ExtendedPubKey;
|
||||||
|
|
||||||
/// Enum for marking psbt hash error.
|
/// Enum for marking psbt hash error.
|
||||||
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
|
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
|
||||||
|
|
|
@ -12,18 +12,18 @@
|
||||||
// If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
|
// If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||||
//
|
//
|
||||||
|
|
||||||
use prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
use io::{self, Cursor, Read};
|
use crate::io::{self, Cursor, Read};
|
||||||
|
|
||||||
use blockdata::transaction::Transaction;
|
use crate::blockdata::transaction::Transaction;
|
||||||
use consensus::{encode, Encodable, Decodable};
|
use crate::consensus::{encode, Encodable, Decodable};
|
||||||
use consensus::encode::MAX_VEC_SIZE;
|
use crate::consensus::encode::MAX_VEC_SIZE;
|
||||||
use util::psbt::map::Map;
|
use crate::util::psbt::map::Map;
|
||||||
use util::psbt::{raw, PartiallySignedTransaction};
|
use crate::util::psbt::{raw, PartiallySignedTransaction};
|
||||||
use util::psbt::Error;
|
use crate::util::psbt::Error;
|
||||||
use util::endian::u32_to_array_le;
|
use crate::util::endian::u32_to_array_le;
|
||||||
use util::bip32::{ExtendedPubKey, Fingerprint, DerivationPath, ChildNumber};
|
use crate::util::bip32::{ExtendedPubKey, Fingerprint, DerivationPath, ChildNumber};
|
||||||
|
|
||||||
/// Type: Unsigned Transaction PSBT_GLOBAL_UNSIGNED_TX = 0x00
|
/// Type: Unsigned Transaction PSBT_GLOBAL_UNSIGNED_TX = 0x00
|
||||||
const PSBT_GLOBAL_UNSIGNED_TX: u8 = 0x00;
|
const PSBT_GLOBAL_UNSIGNED_TX: u8 = 0x00;
|
||||||
|
@ -205,7 +205,7 @@ impl PartiallySignedTransaction {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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),
|
Err(e) => return Err(e),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,29 +12,29 @@
|
||||||
// If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
|
// If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||||
//
|
//
|
||||||
|
|
||||||
use prelude::*;
|
use crate::prelude::*;
|
||||||
use io;
|
use crate::io;
|
||||||
use core::fmt;
|
use core::fmt;
|
||||||
use core::str::FromStr;
|
use core::str::FromStr;
|
||||||
|
|
||||||
use secp256k1;
|
use secp256k1;
|
||||||
use blockdata::script::Script;
|
use crate::blockdata::script::Script;
|
||||||
use blockdata::witness::Witness;
|
use crate::blockdata::witness::Witness;
|
||||||
use blockdata::transaction::{Transaction, TxOut, NonStandardSighashType, SighashTypeParseError};
|
use crate::blockdata::transaction::{Transaction, TxOut, NonStandardSighashType, SighashTypeParseError};
|
||||||
use consensus::encode;
|
use crate::consensus::encode;
|
||||||
use hashes::{self, hash160, ripemd160, sha256, sha256d};
|
use crate::hashes::{self, hash160, ripemd160, sha256, sha256d};
|
||||||
use secp256k1::XOnlyPublicKey;
|
use secp256k1::XOnlyPublicKey;
|
||||||
use util::bip32::KeySource;
|
use crate::util::bip32::KeySource;
|
||||||
use util::psbt;
|
use crate::util::psbt;
|
||||||
use util::psbt::map::Map;
|
use crate::util::psbt::map::Map;
|
||||||
use util::psbt::raw;
|
use crate::util::psbt::raw;
|
||||||
use util::psbt::serialize::Deserialize;
|
use crate::util::psbt::serialize::Deserialize;
|
||||||
use util::psbt::{Error, error};
|
use crate::util::psbt::{Error, error};
|
||||||
use util::key::PublicKey;
|
use crate::util::key::PublicKey;
|
||||||
|
|
||||||
use util::taproot::{ControlBlock, LeafVersion, TapLeafHash, TapBranchHash};
|
use crate::util::taproot::{ControlBlock, LeafVersion, TapLeafHash, TapBranchHash};
|
||||||
use util::sighash;
|
use crate::util::sighash;
|
||||||
use {EcdsaSighashType, SchnorrSighashType, EcdsaSig, SchnorrSig};
|
use crate::{EcdsaSighashType, SchnorrSighashType, EcdsaSig, SchnorrSig};
|
||||||
|
|
||||||
/// Type: Non-Witness UTXO PSBT_IN_NON_WITNESS_UTXO = 0x00
|
/// Type: Non-Witness UTXO PSBT_IN_NON_WITNESS_UTXO = 0x00
|
||||||
const PSBT_IN_NON_WITNESS_UTXO: u8 = 0x00;
|
const PSBT_IN_NON_WITNESS_UTXO: u8 = 0x00;
|
||||||
|
@ -154,7 +154,7 @@ pub struct Input {
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
pub struct PsbtSighashType {
|
pub struct PsbtSighashType {
|
||||||
pub (in ::util::psbt) inner: u32,
|
pub (in crate::util::psbt) inner: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for PsbtSighashType {
|
impl fmt::Display for PsbtSighashType {
|
||||||
|
|
|
@ -12,12 +12,12 @@
|
||||||
// If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
|
// If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||||
//
|
//
|
||||||
|
|
||||||
use prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
use io;
|
use crate::io;
|
||||||
|
|
||||||
use consensus::encode;
|
use crate::consensus::encode;
|
||||||
use util::psbt::raw;
|
use crate::util::psbt::raw;
|
||||||
|
|
||||||
mod global;
|
mod global;
|
||||||
mod input;
|
mod input;
|
||||||
|
|
|
@ -12,23 +12,23 @@
|
||||||
// If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
|
// If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||||
//
|
//
|
||||||
|
|
||||||
use prelude::*;
|
use crate::prelude::*;
|
||||||
use core;
|
use core;
|
||||||
|
|
||||||
use io;
|
use crate::io;
|
||||||
|
|
||||||
use blockdata::script::Script;
|
use crate::blockdata::script::Script;
|
||||||
use consensus::encode;
|
use crate::consensus::encode;
|
||||||
use secp256k1::XOnlyPublicKey;
|
use secp256k1::XOnlyPublicKey;
|
||||||
use util::bip32::KeySource;
|
use crate::util::bip32::KeySource;
|
||||||
use secp256k1;
|
use secp256k1;
|
||||||
use util::psbt::map::Map;
|
use crate::util::psbt::map::Map;
|
||||||
use util::psbt::raw;
|
use crate::util::psbt::raw;
|
||||||
use util::psbt::Error;
|
use crate::util::psbt::Error;
|
||||||
|
|
||||||
use util::taproot::{ScriptLeaf, TapLeafHash};
|
use crate::util::taproot::{ScriptLeaf, TapLeafHash};
|
||||||
|
|
||||||
use util::taproot::{NodeInfo, TaprootBuilder};
|
use crate::util::taproot::{NodeInfo, TaprootBuilder};
|
||||||
|
|
||||||
/// Type: Redeem Script PSBT_OUT_REDEEM_SCRIPT = 0x00
|
/// Type: Redeem Script PSBT_OUT_REDEEM_SCRIPT = 0x00
|
||||||
const PSBT_OUT_REDEEM_SCRIPT: u8 = 0x00;
|
const PSBT_OUT_REDEEM_SCRIPT: u8 = 0x00;
|
||||||
|
|
|
@ -21,15 +21,15 @@
|
||||||
|
|
||||||
use core::cmp;
|
use core::cmp;
|
||||||
|
|
||||||
use blockdata::script::Script;
|
use crate::blockdata::script::Script;
|
||||||
use blockdata::transaction::{ TxOut, Transaction};
|
use crate::blockdata::transaction::{ TxOut, Transaction};
|
||||||
use consensus::{encode, Encodable, Decodable};
|
use crate::consensus::{encode, Encodable, Decodable};
|
||||||
use consensus::encode::MAX_VEC_SIZE;
|
use crate::consensus::encode::MAX_VEC_SIZE;
|
||||||
pub use util::sighash::Prevouts;
|
pub use crate::util::sighash::Prevouts;
|
||||||
|
|
||||||
use prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
use io;
|
use crate::io;
|
||||||
mod error;
|
mod error;
|
||||||
pub use self::error::Error;
|
pub use self::error::Error;
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ mod map;
|
||||||
pub use self::map::{Input, Output, TapTree, PsbtSighashType, IncompleteTapTree};
|
pub use self::map::{Input, Output, TapTree, PsbtSighashType, IncompleteTapTree};
|
||||||
use self::map::Map;
|
use self::map::Map;
|
||||||
|
|
||||||
use util::bip32::{ExtendedPubKey, KeySource};
|
use crate::util::bip32::{ExtendedPubKey, KeySource};
|
||||||
|
|
||||||
/// Partially signed transaction, commonly referred to as a PSBT.
|
/// Partially signed transaction, commonly referred to as a PSBT.
|
||||||
pub type Psbt = PartiallySignedTransaction;
|
pub type Psbt = PartiallySignedTransaction;
|
||||||
|
@ -337,22 +337,22 @@ impl Decodable for PartiallySignedTransaction {
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
use hashes::hex::FromHex;
|
use crate::hashes::hex::FromHex;
|
||||||
use hashes::{sha256, hash160, Hash, ripemd160};
|
use crate::hashes::{sha256, hash160, Hash, ripemd160};
|
||||||
use hash_types::Txid;
|
use crate::hash_types::Txid;
|
||||||
|
|
||||||
use secp256k1::{Secp256k1, self};
|
use secp256k1::{Secp256k1, self};
|
||||||
|
|
||||||
use blockdata::script::Script;
|
use crate::blockdata::script::Script;
|
||||||
use blockdata::transaction::{Transaction, TxIn, TxOut, OutPoint};
|
use crate::blockdata::transaction::{Transaction, TxIn, TxOut, OutPoint};
|
||||||
use network::constants::Network::Bitcoin;
|
use crate::network::constants::Network::Bitcoin;
|
||||||
use consensus::encode::{deserialize, serialize, serialize_hex};
|
use crate::consensus::encode::{deserialize, serialize, serialize_hex};
|
||||||
use util::bip32::{ChildNumber, ExtendedPrivKey, ExtendedPubKey, Fingerprint, KeySource};
|
use crate::util::bip32::{ChildNumber, ExtendedPrivKey, ExtendedPubKey, Fingerprint, KeySource};
|
||||||
use util::psbt::map::{Output, Input};
|
use crate::util::psbt::map::{Output, Input};
|
||||||
use util::psbt::raw;
|
use crate::util::psbt::raw;
|
||||||
|
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use blockdata::witness::Witness;
|
use crate::blockdata::witness::Witness;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn trivial_psbt() {
|
fn trivial_psbt() {
|
||||||
|
@ -594,17 +594,17 @@ mod tests {
|
||||||
#[cfg(feature = "base64")]
|
#[cfg(feature = "base64")]
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
use hashes::hex::FromHex;
|
use crate::hashes::hex::FromHex;
|
||||||
use hash_types::Txid;
|
use crate::hash_types::Txid;
|
||||||
|
|
||||||
use blockdata::script::Script;
|
use crate::blockdata::script::Script;
|
||||||
use blockdata::transaction::{EcdsaSighashType, Transaction, TxIn, TxOut, OutPoint};
|
use crate::blockdata::transaction::{EcdsaSighashType, Transaction, TxIn, TxOut, OutPoint};
|
||||||
use consensus::encode::serialize_hex;
|
use crate::consensus::encode::serialize_hex;
|
||||||
use util::psbt::map::{Map, Input, Output};
|
use crate::util::psbt::map::{Map, Input, Output};
|
||||||
use util::psbt::raw;
|
use crate::util::psbt::raw;
|
||||||
use util::psbt::{PartiallySignedTransaction, Error};
|
use crate::util::psbt::{PartiallySignedTransaction, Error};
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use blockdata::witness::Witness;
|
use crate::blockdata::witness::Witness;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[should_panic(expected = "InvalidMagic")]
|
#[should_panic(expected = "InvalidMagic")]
|
||||||
|
|
|
@ -18,14 +18,14 @@
|
||||||
//! <https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki>.
|
//! <https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki>.
|
||||||
//!
|
//!
|
||||||
|
|
||||||
use prelude::*;
|
use crate::prelude::*;
|
||||||
use core::fmt;
|
use core::fmt;
|
||||||
|
|
||||||
use io;
|
use crate::io;
|
||||||
use consensus::encode::{self, ReadExt, WriteExt, Decodable, Encodable, VarInt, serialize, deserialize, MAX_VEC_SIZE};
|
use crate::consensus::encode::{self, ReadExt, WriteExt, Decodable, Encodable, VarInt, serialize, deserialize, MAX_VEC_SIZE};
|
||||||
use hashes::hex;
|
use crate::hashes::hex;
|
||||||
use util::psbt::Error;
|
use crate::util::psbt::Error;
|
||||||
use util::read_to_end;
|
use crate::util::read_to_end;
|
||||||
|
|
||||||
/// A PSBT key in its raw byte form.
|
/// A PSBT key in its raw byte form.
|
||||||
#[derive(Debug, PartialEq, Hash, Eq, Clone, Ord, PartialOrd)]
|
#[derive(Debug, PartialEq, Hash, Eq, Clone, Ord, PartialOrd)]
|
||||||
|
|
|
@ -18,26 +18,26 @@
|
||||||
//! bytes from/as PSBT key-value pairs.
|
//! bytes from/as PSBT key-value pairs.
|
||||||
//!
|
//!
|
||||||
|
|
||||||
use prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
use io;
|
use crate::io;
|
||||||
|
|
||||||
use blockdata::script::Script;
|
use crate::blockdata::script::Script;
|
||||||
use blockdata::witness::Witness;
|
use crate::blockdata::witness::Witness;
|
||||||
use blockdata::transaction::{Transaction, TxOut};
|
use crate::blockdata::transaction::{Transaction, TxOut};
|
||||||
use consensus::encode::{self, serialize, Decodable, Encodable, deserialize_partial};
|
use crate::consensus::encode::{self, serialize, Decodable, Encodable, deserialize_partial};
|
||||||
use secp256k1::{self, XOnlyPublicKey};
|
use secp256k1::{self, XOnlyPublicKey};
|
||||||
use util::bip32::{ChildNumber, Fingerprint, KeySource};
|
use crate::util::bip32::{ChildNumber, Fingerprint, KeySource};
|
||||||
use hashes::{hash160, ripemd160, sha256, sha256d, Hash};
|
use crate::hashes::{hash160, ripemd160, sha256, sha256d, Hash};
|
||||||
use util::ecdsa::{EcdsaSig, EcdsaSigError};
|
use crate::util::ecdsa::{EcdsaSig, EcdsaSigError};
|
||||||
use util::psbt;
|
use crate::util::psbt;
|
||||||
use util::taproot::{TapBranchHash, TapLeafHash, ControlBlock, LeafVersion};
|
use crate::util::taproot::{TapBranchHash, TapLeafHash, ControlBlock, LeafVersion};
|
||||||
use schnorr;
|
use crate::schnorr;
|
||||||
use util::key::PublicKey;
|
use crate::util::key::PublicKey;
|
||||||
|
|
||||||
use super::map::{TapTree, PsbtSighashType};
|
use super::map::{TapTree, PsbtSighashType};
|
||||||
|
|
||||||
use util::taproot::TaprootBuilder;
|
use crate::util::taproot::TaprootBuilder;
|
||||||
/// A trait for serializing a value as raw data for insertion into PSBT
|
/// A trait for serializing a value as raw data for insertion into PSBT
|
||||||
/// key-value pairs.
|
/// key-value pairs.
|
||||||
pub trait Serialize {
|
pub trait Serialize {
|
||||||
|
@ -370,7 +370,7 @@ fn key_source_len(key_source: &KeySource) -> usize {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use hashes::hex::FromHex;
|
use crate::hashes::hex::FromHex;
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
// Composes tree matching a given depth map, filled with dumb script leafs,
|
// Composes tree matching a given depth map, filled with dumb script leafs,
|
||||||
|
|
|
@ -18,12 +18,12 @@
|
||||||
//!
|
//!
|
||||||
|
|
||||||
use core::fmt;
|
use core::fmt;
|
||||||
use prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
use secp256k1::{self, Secp256k1, Verification, constants};
|
use secp256k1::{self, Secp256k1, Verification, constants};
|
||||||
use hashes::Hash;
|
use crate::hashes::Hash;
|
||||||
use util::taproot::{TapBranchHash, TapTweakHash};
|
use crate::util::taproot::{TapBranchHash, TapTweakHash};
|
||||||
use SchnorrSighashType;
|
use crate::SchnorrSighashType;
|
||||||
|
|
||||||
/// Deprecated re-export of [`secp256k1::XOnlyPublicKey`]
|
/// Deprecated re-export of [`secp256k1::XOnlyPublicKey`]
|
||||||
#[deprecated(since = "0.28.0", note = "Please use `util::key::XOnlyPublicKey` instead")]
|
#[deprecated(since = "0.28.0", note = "Please use `util::key::XOnlyPublicKey` instead")]
|
||||||
|
@ -34,13 +34,13 @@ pub type XOnlyPublicKey = secp256k1::XOnlyPublicKey;
|
||||||
pub type KeyPair = secp256k1::KeyPair;
|
pub type KeyPair = secp256k1::KeyPair;
|
||||||
|
|
||||||
/// Untweaked BIP-340 X-coord-only public key
|
/// Untweaked BIP-340 X-coord-only public key
|
||||||
pub type UntweakedPublicKey = ::XOnlyPublicKey;
|
pub type UntweakedPublicKey = crate::XOnlyPublicKey;
|
||||||
|
|
||||||
/// Tweaked BIP-340 X-coord-only public key
|
/// Tweaked BIP-340 X-coord-only public key
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
#[cfg_attr(feature = "serde", serde(transparent))]
|
#[cfg_attr(feature = "serde", serde(transparent))]
|
||||||
pub struct TweakedPublicKey(::XOnlyPublicKey);
|
pub struct TweakedPublicKey(crate::XOnlyPublicKey);
|
||||||
|
|
||||||
impl fmt::LowerHex for TweakedPublicKey {
|
impl fmt::LowerHex for TweakedPublicKey {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
@ -55,13 +55,13 @@ impl fmt::Display for TweakedPublicKey {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Untweaked BIP-340 key pair
|
/// Untweaked BIP-340 key pair
|
||||||
pub type UntweakedKeyPair = ::KeyPair;
|
pub type UntweakedKeyPair = crate::KeyPair;
|
||||||
|
|
||||||
/// Tweaked BIP-340 key pair
|
/// Tweaked BIP-340 key pair
|
||||||
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
|
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
#[cfg_attr(feature = "serde", serde(transparent))]
|
#[cfg_attr(feature = "serde", serde(transparent))]
|
||||||
pub struct TweakedKeyPair(::KeyPair);
|
pub struct TweakedKeyPair(crate::KeyPair);
|
||||||
|
|
||||||
/// A trait for tweaking BIP340 key types (x-only public keys and key pairs).
|
/// A trait for tweaking BIP340 key types (x-only public keys and key pairs).
|
||||||
pub trait TapTweak {
|
pub trait TapTweak {
|
||||||
|
@ -138,7 +138,7 @@ impl TapTweak for UntweakedKeyPair {
|
||||||
/// # Returns
|
/// # Returns
|
||||||
/// The tweaked key and its parity.
|
/// The tweaked key and its parity.
|
||||||
fn tap_tweak<C: Verification>(mut self, secp: &Secp256k1<C>, merkle_root: Option<TapBranchHash>) -> TweakedKeyPair {
|
fn tap_tweak<C: Verification>(mut self, secp: &Secp256k1<C>, merkle_root: Option<TapBranchHash>) -> TweakedKeyPair {
|
||||||
let pubkey = ::XOnlyPublicKey::from_keypair(&self);
|
let pubkey = crate::XOnlyPublicKey::from_keypair(&self);
|
||||||
let tweak_value = TapTweakHash::from_key_and_tweak(pubkey, merkle_root).into_inner();
|
let tweak_value = TapTweakHash::from_key_and_tweak(pubkey, merkle_root).into_inner();
|
||||||
self.tweak_add_assign(&secp, &tweak_value).expect("Tap tweak failed");
|
self.tweak_add_assign(&secp, &tweak_value).expect("Tap tweak failed");
|
||||||
TweakedKeyPair(self)
|
TweakedKeyPair(self)
|
||||||
|
@ -156,17 +156,17 @@ impl TweakedPublicKey {
|
||||||
/// This method is dangerous and can lead to loss of funds if used incorrectly.
|
/// This method is dangerous and can lead to loss of funds if used incorrectly.
|
||||||
/// Specifically, in multi-party protocols a peer can provide a value that allows them to steal.
|
/// Specifically, in multi-party protocols a peer can provide a value that allows them to steal.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn dangerous_assume_tweaked(key: ::XOnlyPublicKey) -> TweakedPublicKey {
|
pub fn dangerous_assume_tweaked(key: crate::XOnlyPublicKey) -> TweakedPublicKey {
|
||||||
TweakedPublicKey(key)
|
TweakedPublicKey(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the underlying public key.
|
/// Returns the underlying public key.
|
||||||
pub fn to_inner(self) -> ::XOnlyPublicKey {
|
pub fn to_inner(self) -> crate::XOnlyPublicKey {
|
||||||
self.0
|
self.0
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a reference to underlying public key.
|
/// Returns a reference to underlying public key.
|
||||||
pub fn as_inner(&self) -> &::XOnlyPublicKey {
|
pub fn as_inner(&self) -> &crate::XOnlyPublicKey {
|
||||||
&self.0
|
&self.0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,25 +186,25 @@ impl TweakedKeyPair {
|
||||||
/// This method is dangerous and can lead to loss of funds if used incorrectly.
|
/// This method is dangerous and can lead to loss of funds if used incorrectly.
|
||||||
/// Specifically, in multi-party protocols a peer can provide a value that allows them to steal.
|
/// Specifically, in multi-party protocols a peer can provide a value that allows them to steal.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn dangerous_assume_tweaked(pair: ::KeyPair) -> TweakedKeyPair {
|
pub fn dangerous_assume_tweaked(pair: crate::KeyPair) -> TweakedKeyPair {
|
||||||
TweakedKeyPair(pair)
|
TweakedKeyPair(pair)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the underlying key pair
|
/// Returns the underlying key pair
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn into_inner(self) -> ::KeyPair {
|
pub fn into_inner(self) -> crate::KeyPair {
|
||||||
self.0
|
self.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<TweakedPublicKey> for ::XOnlyPublicKey {
|
impl From<TweakedPublicKey> for crate::XOnlyPublicKey {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from(pair: TweakedPublicKey) -> Self {
|
fn from(pair: TweakedPublicKey) -> Self {
|
||||||
pair.0
|
pair.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<TweakedKeyPair> for ::KeyPair {
|
impl From<TweakedKeyPair> for crate::KeyPair {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from(pair: TweakedKeyPair) -> Self {
|
fn from(pair: TweakedKeyPair) -> Self {
|
||||||
pair.0
|
pair.0
|
||||||
|
|
|
@ -20,19 +20,19 @@
|
||||||
//! and legacy (before Bip143).
|
//! and legacy (before Bip143).
|
||||||
//!
|
//!
|
||||||
|
|
||||||
use prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
pub use blockdata::transaction::{EcdsaSighashType, SighashTypeParseError};
|
pub use crate::blockdata::transaction::{EcdsaSighashType, SighashTypeParseError};
|
||||||
use blockdata::witness::Witness;
|
use crate::blockdata::witness::Witness;
|
||||||
use consensus::{encode, Encodable};
|
use crate::consensus::{encode, Encodable};
|
||||||
use core::{str, fmt};
|
use core::{str, fmt};
|
||||||
use core::ops::{Deref, DerefMut};
|
use core::ops::{Deref, DerefMut};
|
||||||
use core::borrow::Borrow;
|
use core::borrow::Borrow;
|
||||||
use hashes::{sha256, sha256d, Hash};
|
use crate::hashes::{sha256, sha256d, Hash};
|
||||||
use io;
|
use crate::io;
|
||||||
use util::taproot::{TapLeafHash, TAPROOT_ANNEX_PREFIX, TapSighashHash};
|
use crate::util::taproot::{TapLeafHash, TAPROOT_ANNEX_PREFIX, TapSighashHash};
|
||||||
use Sighash;
|
use crate::Sighash;
|
||||||
use {Script, Transaction, TxOut};
|
use crate::{Script, Transaction, TxOut};
|
||||||
|
|
||||||
use super::taproot::LeafVersion;
|
use super::taproot::LeafVersion;
|
||||||
|
|
||||||
|
@ -790,17 +790,17 @@ impl<'a> Encodable for Annex<'a> {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use consensus::deserialize;
|
use crate::consensus::deserialize;
|
||||||
use hashes::hex::FromHex;
|
use crate::hashes::hex::FromHex;
|
||||||
use hashes::{Hash, HashEngine};
|
use crate::hashes::{Hash, HashEngine};
|
||||||
use util::sighash::{Annex, Error, Prevouts, ScriptPath, SighashCache};
|
use crate::util::sighash::{Annex, Error, Prevouts, ScriptPath, SighashCache};
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use hashes::hex::ToHex;
|
use crate::hashes::hex::ToHex;
|
||||||
use util::taproot::{TapTweakHash, TapSighashHash, TapBranchHash, TapLeafHash};
|
use crate::util::taproot::{TapTweakHash, TapSighashHash, TapBranchHash, TapLeafHash};
|
||||||
use secp256k1::{self, SecretKey, XOnlyPublicKey};
|
use secp256k1::{self, SecretKey, XOnlyPublicKey};
|
||||||
extern crate serde_json;
|
extern crate serde_json;
|
||||||
|
|
||||||
use {Script, Transaction, TxIn, TxOut};
|
use crate::{Script, Transaction, TxIn, TxOut};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_tap_sighash_hash() {
|
fn test_tap_sighash_hash() {
|
||||||
|
|
|
@ -16,8 +16,8 @@
|
||||||
//! This module provides support for taproot tagged hashes.
|
//! This module provides support for taproot tagged hashes.
|
||||||
//!
|
//!
|
||||||
|
|
||||||
use prelude::*;
|
use crate::prelude::*;
|
||||||
use io;
|
use crate::io;
|
||||||
use secp256k1::{self, Secp256k1};
|
use secp256k1::{self, Secp256k1};
|
||||||
|
|
||||||
use core::fmt;
|
use core::fmt;
|
||||||
|
@ -25,12 +25,12 @@ use core::cmp::Reverse;
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
use std::error;
|
use std::error;
|
||||||
|
|
||||||
use hashes::{sha256, sha256t, Hash, HashEngine};
|
use crate::hashes::{sha256, sha256t, Hash, HashEngine};
|
||||||
use schnorr::{TweakedPublicKey, UntweakedPublicKey, TapTweak};
|
use crate::schnorr::{TweakedPublicKey, UntweakedPublicKey, TapTweak};
|
||||||
use util::key::XOnlyPublicKey;
|
use crate::util::key::XOnlyPublicKey;
|
||||||
use Script;
|
use crate::Script;
|
||||||
|
|
||||||
use consensus::Encodable;
|
use crate::consensus::Encodable;
|
||||||
|
|
||||||
/// The SHA-256 midstate value for the TapLeaf hash.
|
/// The SHA-256 midstate value for the TapLeaf hash.
|
||||||
const MIDSTATE_TAPLEAF: [u8; 32] = [
|
const MIDSTATE_TAPLEAF: [u8; 32] = [
|
||||||
|
@ -1096,13 +1096,13 @@ impl fmt::Display for TaprootError {
|
||||||
impl error::Error for TaprootError {}
|
impl error::Error for TaprootError {}
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use {Address, Network};
|
use crate::{Address, Network};
|
||||||
use schnorr::TapTweak;
|
use crate::schnorr::TapTweak;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use hashes::hex::{FromHex, ToHex};
|
use crate::hashes::hex::{FromHex, ToHex};
|
||||||
use hashes::sha256t::Tag;
|
use crate::hashes::sha256t::Tag;
|
||||||
use hashes::{sha256, Hash, HashEngine};
|
use crate::hashes::{sha256, Hash, HashEngine};
|
||||||
use secp256k1::{VerifyOnly, XOnlyPublicKey};
|
use secp256k1::{VerifyOnly, XOnlyPublicKey};
|
||||||
use core::str::FromStr;
|
use core::str::FromStr;
|
||||||
extern crate serde_json;
|
extern crate serde_json;
|
||||||
|
|
|
@ -541,9 +541,9 @@ impl Uint256 {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use consensus::{deserialize, serialize};
|
use crate::consensus::{deserialize, serialize};
|
||||||
use util::uint::{Uint256, Uint128};
|
use crate::util::uint::{Uint256, Uint128};
|
||||||
use util::BitArray;
|
use crate::util::BitArray;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
pub fn uint256_bits_test() {
|
pub fn uint256_bits_test() {
|
||||||
|
|
Loading…
Reference in New Issue