From fa71b0e0445f74e42b49e8ce0dfe476a6e13ad27 Mon Sep 17 00:00:00 2001 From: Fmt Bot Date: Sun, 1 Sep 2024 01:22:04 +0000 Subject: [PATCH] 2024-09-01 automated rustfmt nightly --- base58/src/lib.rs | 1 + bitcoin/examples/ecdsa-psbt.rs | 3 ++- bitcoin/examples/sign-tx-segwit-v0.rs | 3 ++- bitcoin/examples/sign-tx-taproot.rs | 3 ++- bitcoin/examples/taproot-psbt-simple.rs | 27 +++++++++++++------------ bitcoin/examples/taproot-psbt.rs | 12 +++++------ bitcoin/src/blockdata/script/owned.rs | 5 ++--- bitcoin/src/blockdata/transaction.rs | 10 +++------ units/src/amount.rs | 5 ++--- units/src/fee_rate.rs | 5 ++--- units/src/weight.rs | 5 ++--- 11 files changed, 38 insertions(+), 41 deletions(-) diff --git a/base58/src/lib.rs b/base58/src/lib.rs index ffda3179e..19ed85306 100644 --- a/base58/src/lib.rs +++ b/base58/src/lib.rs @@ -248,6 +248,7 @@ where #[cfg(test)] mod tests { use alloc::vec; + use hex::test_hex_unwrap as hex; use super::*; diff --git a/bitcoin/examples/ecdsa-psbt.rs b/bitcoin/examples/ecdsa-psbt.rs index 14a898145..d7813518c 100644 --- a/bitcoin/examples/ecdsa-psbt.rs +++ b/bitcoin/examples/ecdsa-psbt.rs @@ -174,7 +174,8 @@ impl WatchOnly { /// Creates the PSBT, in BIP174 parlance this is the 'Creator'. fn create_psbt(&self, secp: &Secp256k1) -> Result { - let to_address = RECEIVE_ADDRESS.parse::>()?.require_network(Network::Regtest)?; + let to_address = + RECEIVE_ADDRESS.parse::>()?.require_network(Network::Regtest)?; let to_amount = OUTPUT_AMOUNT_BTC.parse::()?; let (_, change_address, _) = self.change_address(secp)?; diff --git a/bitcoin/examples/sign-tx-segwit-v0.rs b/bitcoin/examples/sign-tx-segwit-v0.rs index ebada8279..932663c94 100644 --- a/bitcoin/examples/sign-tx-segwit-v0.rs +++ b/bitcoin/examples/sign-tx-segwit-v0.rs @@ -100,7 +100,8 @@ fn senders_keys(secp: &Secp256k1) -> (SecretKey, WPubkeyHash) { /// /// (FWIW this is a random mainnet address from block 80219.) fn receivers_address() -> Address { - "bc1q7cyrfmck2ffu2ud3rn5l5a8yv6f0chkp0zpemf".parse::>() + "bc1q7cyrfmck2ffu2ud3rn5l5a8yv6f0chkp0zpemf" + .parse::>() .expect("a valid address") .require_network(Network::Bitcoin) .expect("valid address for mainnet") diff --git a/bitcoin/examples/sign-tx-taproot.rs b/bitcoin/examples/sign-tx-taproot.rs index 857385837..23b8b2923 100644 --- a/bitcoin/examples/sign-tx-taproot.rs +++ b/bitcoin/examples/sign-tx-taproot.rs @@ -97,7 +97,8 @@ fn senders_keys(secp: &Secp256k1) -> Keypair { /// /// (FWIW this is an arbitrary mainnet address from block 805222.) fn receivers_address() -> Address { - "bc1p0dq0tzg2r780hldthn5mrznmpxsxc0jux5f20fwj0z3wqxxk6fpqm7q0va".parse::>() + "bc1p0dq0tzg2r780hldthn5mrznmpxsxc0jux5f20fwj0z3wqxxk6fpqm7q0va" + .parse::>() .expect("a valid address") .require_network(Network::Bitcoin) .expect("valid address for mainnet") diff --git a/bitcoin/examples/taproot-psbt-simple.rs b/bitcoin/examples/taproot-psbt-simple.rs index 81bf759c6..edd375ec6 100644 --- a/bitcoin/examples/taproot-psbt-simple.rs +++ b/bitcoin/examples/taproot-psbt-simple.rs @@ -94,7 +94,8 @@ fn get_tap_key_origin( // The address to send to. fn receivers_address() -> Address { - "bc1p0dq0tzg2r780hldthn5mrznmpxsxc0jux5f20fwj0z3wqxxk6fpqm7q0va".parse::>() + "bc1p0dq0tzg2r780hldthn5mrznmpxsxc0jux5f20fwj0z3wqxxk6fpqm7q0va" + .parse::>() .expect("a valid address") .require_network(Network::Bitcoin) .expect("valid address for mainnet") @@ -102,12 +103,12 @@ fn receivers_address() -> Address { // The dummy unspent transaction outputs that we control. fn dummy_unspent_transaction_outputs() -> Vec<(OutPoint, TxOut)> { - let script_pubkey_1 = - "bc1p80lanj0xee8q667aqcnn0xchlykllfsz3gu5skfv9vjsytaujmdqtv52vu".parse::>() - .unwrap() - .require_network(Network::Bitcoin) - .unwrap() - .script_pubkey(); + let script_pubkey_1 = "bc1p80lanj0xee8q667aqcnn0xchlykllfsz3gu5skfv9vjsytaujmdqtv52vu" + .parse::>() + .unwrap() + .require_network(Network::Bitcoin) + .unwrap() + .script_pubkey(); let out_point_1 = OutPoint { txid: Txid::all_zeros(), // Obviously invalid. @@ -116,12 +117,12 @@ fn dummy_unspent_transaction_outputs() -> Vec<(OutPoint, TxOut)> { let utxo_1 = TxOut { value: DUMMY_UTXO_AMOUNT_INPUT_1, script_pubkey: script_pubkey_1 }; - let script_pubkey_2 = - "bc1pfd0jmmdnp278vppcw68tkkmquxtq50xchy7f6wdmjtjm7fgsr8dszdcqce".parse::>() - .unwrap() - .require_network(Network::Bitcoin) - .unwrap() - .script_pubkey(); + let script_pubkey_2 = "bc1pfd0jmmdnp278vppcw68tkkmquxtq50xchy7f6wdmjtjm7fgsr8dszdcqce" + .parse::>() + .unwrap() + .require_network(Network::Bitcoin) + .unwrap() + .script_pubkey(); let out_point_2 = OutPoint { txid: Txid::all_zeros(), // Obviously invalid. diff --git a/bitcoin/examples/taproot-psbt.rs b/bitcoin/examples/taproot-psbt.rs index ddfcc28f4..3fd25ecc2 100644 --- a/bitcoin/examples/taproot-psbt.rs +++ b/bitcoin/examples/taproot-psbt.rs @@ -99,12 +99,12 @@ fn main() -> Result<(), Box> { println!("\nSTART EXAMPLE 1 - P2TR with a BIP86 commitment, signed with internal key\n"); // Just some addresses for outputs from our wallets. Not really important. - let to_address = - "bcrt1p0p3rvwww0v9znrclp00uneq8ytre9kj922v8fxhnezm3mgsmn9usdxaefc".parse::>()? - .require_network(Network::Regtest)?; - let change_address = - "bcrt1pz449kexzydh2kaypatup5ultru3ej284t6eguhnkn6wkhswt0l7q3a7j76".parse::>()? - .require_network(Network::Regtest)?; + let to_address = "bcrt1p0p3rvwww0v9znrclp00uneq8ytre9kj922v8fxhnezm3mgsmn9usdxaefc" + .parse::>()? + .require_network(Network::Regtest)?; + let change_address = "bcrt1pz449kexzydh2kaypatup5ultru3ej284t6eguhnkn6wkhswt0l7q3a7j76" + .parse::>()? + .require_network(Network::Regtest)?; let amount_to_send_in_sats = Amount::ONE_BTC; let change_amount = UTXO_1 .amount_in_sats diff --git a/bitcoin/src/blockdata/script/owned.rs b/bitcoin/src/blockdata/script/owned.rs index 69c67f969..2f3a713c5 100644 --- a/bitcoin/src/blockdata/script/owned.rs +++ b/bitcoin/src/blockdata/script/owned.rs @@ -3,6 +3,8 @@ #[cfg(doc)] use core::ops::Deref; +#[cfg(feature = "arbitrary")] +use arbitrary::{Arbitrary, Unstructured}; use hex::FromHex; use internals::ToU64 as _; @@ -11,9 +13,6 @@ use crate::opcodes::all::*; use crate::opcodes::{self, Opcode}; use crate::prelude::{Box, Vec}; -#[cfg(feature = "arbitrary")] -use arbitrary::{Arbitrary, Unstructured}; - /// An owned, growable script. /// /// `ScriptBuf` is the most common script type that has the ownership over the contents of the diff --git a/bitcoin/src/blockdata/transaction.rs b/bitcoin/src/blockdata/transaction.rs index f21389d6f..63858e6d8 100644 --- a/bitcoin/src/blockdata/transaction.rs +++ b/bitcoin/src/blockdata/transaction.rs @@ -12,6 +12,8 @@ use core::{cmp, fmt, str}; +#[cfg(feature = "arbitrary")] +use arbitrary::{Arbitrary, Unstructured}; use hashes::sha256d; use internals::{write_err, ToU64 as _}; use io::{BufRead, Write}; @@ -29,9 +31,6 @@ use crate::sighash::{EcdsaSighashType, TapSighashType}; use crate::witness::Witness; use crate::{Amount, FeeRate, SignedAmount, VarInt}; -#[cfg(feature = "arbitrary")] -use arbitrary::{Arbitrary, Unstructured}; - hashes::hash_newtype! { /// A bitcoin transaction hash/transaction ID. /// @@ -411,10 +410,7 @@ crate::internal_macros::define_extension_trait! { #[cfg(feature = "arbitrary")] impl<'a> Arbitrary<'a> for TxOut { fn arbitrary(u: &mut Unstructured<'a>) -> arbitrary::Result { - Ok(TxOut { - value: Amount::arbitrary(u)?, - script_pubkey: ScriptBuf::arbitrary(u)?, - }) + Ok(TxOut { value: Amount::arbitrary(u)?, script_pubkey: ScriptBuf::arbitrary(u)? }) } } diff --git a/units/src/amount.rs b/units/src/amount.rs index c4195a3ec..1670df600 100644 --- a/units/src/amount.rs +++ b/units/src/amount.rs @@ -13,11 +13,10 @@ use core::{default, fmt, ops}; #[cfg(feature = "serde")] use ::serde::{Deserialize, Serialize}; -use internals::error::InputString; -use internals::write_err; - #[cfg(feature = "arbitrary")] use arbitrary::{Arbitrary, Unstructured}; +use internals::error::InputString; +use internals::write_err; /// A set of denominations in which amounts can be expressed. /// diff --git a/units/src/fee_rate.rs b/units/src/fee_rate.rs index 8b8c32334..02e84dfe7 100644 --- a/units/src/fee_rate.rs +++ b/units/src/fee_rate.rs @@ -5,15 +5,14 @@ use core::fmt; use core::ops::{Div, Mul}; +#[cfg(feature = "arbitrary")] +use arbitrary::{Arbitrary, Unstructured}; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; use crate::amount::Amount; use crate::weight::Weight; -#[cfg(feature = "arbitrary")] -use arbitrary::{Arbitrary, Unstructured}; - /// Represents fee rate. /// /// This is an integer newtype representing fee rate in `sat/kwu`. It provides protection against mixing diff --git a/units/src/weight.rs b/units/src/weight.rs index f3ab73cb2..f9022ed38 100644 --- a/units/src/weight.rs +++ b/units/src/weight.rs @@ -5,11 +5,10 @@ use core::fmt; use core::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Sub, SubAssign}; -#[cfg(feature = "serde")] -use serde::{Deserialize, Serialize}; - #[cfg(feature = "arbitrary")] use arbitrary::{Arbitrary, Unstructured}; +#[cfg(feature = "serde")] +use serde::{Deserialize, Serialize}; /// The factor that non-witness serialization data is multiplied by during weight calculation. pub const WITNESS_SCALE_FACTOR: usize = 4;