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:
    ACK 4057c26829
  sanket1729:
    code review ACK 4057c26829

Tree-SHA512: 889d78817f60b8d038d631059432b37940e97299b9fd3f0055b2ede61b5f87cce4824ac0be239fc3897ff6da8068749c8504aa0714aab35cc0faf519606771bf
This commit is contained in:
Andrew Poelstra 2022-10-19 12:31:15 +00:00
commit 938b61bf66
No known key found for this signature in database
GPG Key ID: C588D63CE41B97C1
8 changed files with 13 additions and 16 deletions

View File

@ -382,7 +382,7 @@ mod psbt_sign {
use std::ops::Deref;
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::{EcdsaSig, EcdsaSigError, PrivateKey, Script, Transaction, TxOut};
use secp256k1::{Message, Secp256k1, Signing};

View File

@ -5,18 +5,17 @@
//! Implementation of compact blocks data structure and algorithms.
//!
use crate::prelude::*;
use crate::io;
use core::{convert, convert::TryFrom, fmt, mem};
use core::convert::TryFrom;
use core::{convert, fmt, mem};
#[cfg(feature = "std")]
use std::error;
use crate::consensus::encode::{self, Decodable, Encodable, VarInt};
use crate::hashes::{sha256, siphash24, Hash};
use crate::internal_macros::{impl_array_newtype, impl_bytes_newtype, impl_consensus_encoding};
use crate::prelude::*;
use crate::util::endian;
use crate::{Block, BlockHash, BlockHeader, Transaction};
use crate::{io, Block, BlockHash, BlockHeader, Transaction};
/// A BIP-152 error
#[derive(Clone, PartialEq, Eq, Debug, Copy, PartialOrd, Ord, Hash)]
@ -69,9 +68,7 @@ pub struct PrefilledTransaction {
}
impl convert::AsRef<Transaction> for PrefilledTransaction {
fn as_ref(&self) -> &Transaction {
&self.tx
}
fn as_ref(&self) -> &Transaction { &self.tx }
}
impl Encodable for PrefilledTransaction {
@ -376,8 +373,8 @@ mod test {
use crate::consensus::encode::{deserialize, serialize};
use crate::hashes::hex::FromHex;
use crate::{
Block, BlockHash, BlockHeader, BlockVersion, OutPoint, Script, Sequence, Transaction, TxIn,
TxMerkleNode, TxOut, Txid, Witness, CompactTarget,
Block, BlockHash, BlockHeader, BlockVersion, CompactTarget, OutPoint, Script, Sequence,
Transaction, TxIn, TxMerkleNode, TxOut, Txid, Witness,
};
fn dummy_tx(nonce: &[u8]) -> Transaction {

View File

@ -28,7 +28,7 @@ use crate::io::{self, Cursor, Read};
use crate::util::endian;
use crate::util::psbt;
use crate::util::bip152::{ShortId, PrefilledTransaction};
use crate::bip152::{ShortId, PrefilledTransaction};
use crate::util::taproot::TapLeafHash;
use crate::hashes::hex::ToHex;

View File

@ -80,6 +80,7 @@ mod serde_utils;
#[macro_use]
pub mod network;
pub mod address;
pub mod bip152;
pub mod bip158;
pub mod bip32;
pub mod blockdata;

View File

@ -486,7 +486,7 @@ mod test {
use crate::network::message_bloom::{FilterAdd, FilterLoad, BloomFlags};
use crate::MerkleBlock;
use crate::network::message_compact_blocks::{GetBlockTxn, SendCmpct};
use crate::util::bip152::BlockTransactionsRequest;
use crate::bip152::BlockTransactionsRequest;
fn hash(slice: [u8;32]) -> Hash {
Hash::from_slice(&slice).unwrap()

View File

@ -3,7 +3,7 @@
//!
use crate::internal_macros::impl_consensus_encoding;
use crate::util::bip152;
use crate::bip152;
/// sendcmpct message
#[derive(PartialEq, Eq, Clone, Debug, Copy, PartialOrd, Ord, Hash)]

View File

@ -11,7 +11,6 @@ pub mod ecdsa;
pub mod schnorr;
pub mod amount;
pub mod base58;
pub mod bip152;
pub mod hash;
pub mod merkleblock;
pub mod psbt;

View File

@ -2,7 +2,7 @@ extern crate bitcoin;
fn do_test(data: &[u8]) {
// 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 {
Err(_) => {},