Merge rust-bitcoin/rust-bitcoin#1210: Move bip152 module to crate root
4057c26829
Run formmater on bip152 (Tobin C. Harding)facd8ba556
Move bip152 module to crate root (Tobin C. Harding) Pull request description: We are attempting to flatten the `util` module. Move the `bip152` module to the crate root out of `util`. Currently `src/util/` is ignored by the formatter so this move requires `bip152` module to be formatted. Formatting is done as a separate patch so reviewers can run `cargo +nightly fmt` and compare the diffs if so desired. ACKs for top commit: apoelstra: ACK4057c26829
sanket1729: code review ACK4057c26829
Tree-SHA512: 889d78817f60b8d038d631059432b37940e97299b9fd3f0055b2ede61b5f87cce4824ac0be239fc3897ff6da8068749c8504aa0714aab35cc0faf519606771bf
This commit is contained in:
commit
938b61bf66
|
@ -382,7 +382,7 @@ mod psbt_sign {
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
|
|
||||||
use bitcoin::psbt::{Input, Prevouts, Psbt, PsbtSighashType};
|
use bitcoin::psbt::{Input, Prevouts, Psbt, PsbtSighashType};
|
||||||
use bitcoin::sighash::{self, SighashCache, EcdsaSighashType, SchnorrSighashType};
|
use bitcoin::sighash::{self, EcdsaSighashType, SchnorrSighashType, SighashCache};
|
||||||
use bitcoin::util::taproot::TapLeafHash;
|
use bitcoin::util::taproot::TapLeafHash;
|
||||||
use bitcoin::{EcdsaSig, EcdsaSigError, PrivateKey, Script, Transaction, TxOut};
|
use bitcoin::{EcdsaSig, EcdsaSigError, PrivateKey, Script, Transaction, TxOut};
|
||||||
use secp256k1::{Message, Secp256k1, Signing};
|
use secp256k1::{Message, Secp256k1, Signing};
|
||||||
|
|
|
@ -5,18 +5,17 @@
|
||||||
//! Implementation of compact blocks data structure and algorithms.
|
//! Implementation of compact blocks data structure and algorithms.
|
||||||
//!
|
//!
|
||||||
|
|
||||||
use crate::prelude::*;
|
use core::convert::TryFrom;
|
||||||
|
use core::{convert, fmt, mem};
|
||||||
use crate::io;
|
|
||||||
use core::{convert, convert::TryFrom, fmt, mem};
|
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
use std::error;
|
use std::error;
|
||||||
|
|
||||||
use crate::consensus::encode::{self, Decodable, Encodable, VarInt};
|
use crate::consensus::encode::{self, Decodable, Encodable, VarInt};
|
||||||
use crate::hashes::{sha256, siphash24, Hash};
|
use crate::hashes::{sha256, siphash24, Hash};
|
||||||
use crate::internal_macros::{impl_array_newtype, impl_bytes_newtype, impl_consensus_encoding};
|
use crate::internal_macros::{impl_array_newtype, impl_bytes_newtype, impl_consensus_encoding};
|
||||||
|
use crate::prelude::*;
|
||||||
use crate::util::endian;
|
use crate::util::endian;
|
||||||
use crate::{Block, BlockHash, BlockHeader, Transaction};
|
use crate::{io, Block, BlockHash, BlockHeader, Transaction};
|
||||||
|
|
||||||
/// A BIP-152 error
|
/// A BIP-152 error
|
||||||
#[derive(Clone, PartialEq, Eq, Debug, Copy, PartialOrd, Ord, Hash)]
|
#[derive(Clone, PartialEq, Eq, Debug, Copy, PartialOrd, Ord, Hash)]
|
||||||
|
@ -69,9 +68,7 @@ pub struct PrefilledTransaction {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl convert::AsRef<Transaction> for PrefilledTransaction {
|
impl convert::AsRef<Transaction> for PrefilledTransaction {
|
||||||
fn as_ref(&self) -> &Transaction {
|
fn as_ref(&self) -> &Transaction { &self.tx }
|
||||||
&self.tx
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Encodable for PrefilledTransaction {
|
impl Encodable for PrefilledTransaction {
|
||||||
|
@ -376,8 +373,8 @@ mod test {
|
||||||
use crate::consensus::encode::{deserialize, serialize};
|
use crate::consensus::encode::{deserialize, serialize};
|
||||||
use crate::hashes::hex::FromHex;
|
use crate::hashes::hex::FromHex;
|
||||||
use crate::{
|
use crate::{
|
||||||
Block, BlockHash, BlockHeader, BlockVersion, OutPoint, Script, Sequence, Transaction, TxIn,
|
Block, BlockHash, BlockHeader, BlockVersion, CompactTarget, OutPoint, Script, Sequence,
|
||||||
TxMerkleNode, TxOut, Txid, Witness, CompactTarget,
|
Transaction, TxIn, TxMerkleNode, TxOut, Txid, Witness,
|
||||||
};
|
};
|
||||||
|
|
||||||
fn dummy_tx(nonce: &[u8]) -> Transaction {
|
fn dummy_tx(nonce: &[u8]) -> Transaction {
|
|
@ -28,7 +28,7 @@ use crate::io::{self, Cursor, Read};
|
||||||
|
|
||||||
use crate::util::endian;
|
use crate::util::endian;
|
||||||
use crate::util::psbt;
|
use crate::util::psbt;
|
||||||
use crate::util::bip152::{ShortId, PrefilledTransaction};
|
use crate::bip152::{ShortId, PrefilledTransaction};
|
||||||
use crate::util::taproot::TapLeafHash;
|
use crate::util::taproot::TapLeafHash;
|
||||||
use crate::hashes::hex::ToHex;
|
use crate::hashes::hex::ToHex;
|
||||||
|
|
||||||
|
|
|
@ -80,6 +80,7 @@ mod serde_utils;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
pub mod network;
|
pub mod network;
|
||||||
pub mod address;
|
pub mod address;
|
||||||
|
pub mod bip152;
|
||||||
pub mod bip158;
|
pub mod bip158;
|
||||||
pub mod bip32;
|
pub mod bip32;
|
||||||
pub mod blockdata;
|
pub mod blockdata;
|
||||||
|
|
|
@ -486,7 +486,7 @@ mod test {
|
||||||
use crate::network::message_bloom::{FilterAdd, FilterLoad, BloomFlags};
|
use crate::network::message_bloom::{FilterAdd, FilterLoad, BloomFlags};
|
||||||
use crate::MerkleBlock;
|
use crate::MerkleBlock;
|
||||||
use crate::network::message_compact_blocks::{GetBlockTxn, SendCmpct};
|
use crate::network::message_compact_blocks::{GetBlockTxn, SendCmpct};
|
||||||
use crate::util::bip152::BlockTransactionsRequest;
|
use crate::bip152::BlockTransactionsRequest;
|
||||||
|
|
||||||
fn hash(slice: [u8;32]) -> Hash {
|
fn hash(slice: [u8;32]) -> Hash {
|
||||||
Hash::from_slice(&slice).unwrap()
|
Hash::from_slice(&slice).unwrap()
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
//!
|
//!
|
||||||
|
|
||||||
use crate::internal_macros::impl_consensus_encoding;
|
use crate::internal_macros::impl_consensus_encoding;
|
||||||
use crate::util::bip152;
|
use crate::bip152;
|
||||||
|
|
||||||
/// sendcmpct message
|
/// sendcmpct message
|
||||||
#[derive(PartialEq, Eq, Clone, Debug, Copy, PartialOrd, Ord, Hash)]
|
#[derive(PartialEq, Eq, Clone, Debug, Copy, PartialOrd, Ord, Hash)]
|
||||||
|
|
|
@ -11,7 +11,6 @@ pub mod ecdsa;
|
||||||
pub mod schnorr;
|
pub mod schnorr;
|
||||||
pub mod amount;
|
pub mod amount;
|
||||||
pub mod base58;
|
pub mod base58;
|
||||||
pub mod bip152;
|
|
||||||
pub mod hash;
|
pub mod hash;
|
||||||
pub mod merkleblock;
|
pub mod merkleblock;
|
||||||
pub mod psbt;
|
pub mod psbt;
|
||||||
|
|
|
@ -2,7 +2,7 @@ extern crate bitcoin;
|
||||||
|
|
||||||
fn do_test(data: &[u8]) {
|
fn do_test(data: &[u8]) {
|
||||||
// We already fuzz Transactions in `./deserialize_transaction.rs`.
|
// We already fuzz Transactions in `./deserialize_transaction.rs`.
|
||||||
let tx_result: Result<bitcoin::util::bip152::PrefilledTransaction, _> = bitcoin::consensus::encode::deserialize(data);
|
let tx_result: Result<bitcoin::bip152::PrefilledTransaction, _> = bitcoin::consensus::encode::deserialize(data);
|
||||||
|
|
||||||
match tx_result {
|
match tx_result {
|
||||||
Err(_) => {},
|
Err(_) => {},
|
||||||
|
|
Loading…
Reference in New Issue