2025-03-02 automated rustfmt nightly

This commit is contained in:
Fmt Bot 2025-03-02 01:22:29 +00:00 committed by github-actions[bot]
parent c2741c8eee
commit 166e37161a
8 changed files with 29 additions and 28 deletions

View File

@ -92,7 +92,7 @@ pub enum AddressType {
/// Pay to taproot.
P2tr,
/// Pay to anchor.
P2a
P2a,
}
impl fmt::Display for AddressType {
@ -1531,7 +1531,6 @@ mod tests {
assert_eq!(rinsed, foo_unchecked);
}
#[test]
fn pay_to_anchor_address_regtest() {
// Verify that p2a uses the expected address for regtest.

View File

@ -10,9 +10,8 @@ use crate::key::{
XOnlyPublicKey,
};
use crate::opcodes::all::*;
use crate::script::witness_program::WitnessProgram;
use crate::script::witness_program::{WitnessProgram, P2A_PROGRAM};
use crate::script::witness_version::WitnessVersion;
use crate::script::witness_program::P2A_PROGRAM;
use crate::script::{
self, Builder, PushBytes, RedeemScriptSizeError, Script, ScriptBuf, ScriptExt as _, ScriptHash,
WScriptHash, WitnessScriptSizeError,

View File

@ -26,7 +26,7 @@ pub const MIN_SIZE: usize = 2;
pub const MAX_SIZE: usize = 40;
/// The P2A program which is given by 0x4e73.
pub(crate) const P2A_PROGRAM: [u8;2] = [78, 115];
pub(crate) const P2A_PROGRAM: [u8; 2] = [78, 115];
/// The segregated witness program.
///
@ -110,7 +110,7 @@ impl WitnessProgram {
/// Constructs a new pay to anchor address
pub const fn p2a() -> Self {
WitnessProgram { version: WitnessVersion::V1, program: ArrayVec::from_slice(&P2A_PROGRAM)}
WitnessProgram { version: WitnessVersion::V1, program: ArrayVec::from_slice(&P2A_PROGRAM) }
}
/// Returns the witness program version.

View File

@ -13,7 +13,10 @@ use crate::crypto::ecdsa;
use crate::prelude::Vec;
#[cfg(doc)]
use crate::script::ScriptExt as _;
use crate::taproot::{self, LeafScript, LeafVersion, TAPROOT_ANNEX_PREFIX, TAPROOT_CONTROL_BASE_SIZE, TAPROOT_LEAF_MASK};
use crate::taproot::{
self, LeafScript, LeafVersion, TAPROOT_ANNEX_PREFIX, TAPROOT_CONTROL_BASE_SIZE,
TAPROOT_LEAF_MASK,
};
use crate::Script;
#[rustfmt::skip] // Keep public re-exports separate.
@ -249,14 +252,16 @@ impl<'a> P2TrSpend<'a> {
// for the fact that annex is still there.
match witness.len() {
0 => None,
1 => Some(P2TrSpend::Key { /* signature: witness.last().expect("len > 0") ,*/ annex: None }),
1 => Some(P2TrSpend::Key {
/* signature: witness.last().expect("len > 0") ,*/ annex: None,
}),
2 if witness.last().expect("len > 0").starts_with(&[TAPROOT_ANNEX_PREFIX]) => {
let spend = P2TrSpend::Key {
// signature: witness.second_to_last().expect("len > 1"),
annex: witness.last(),
};
Some(spend)
},
}
// 2 => this is script spend without annex - same as when there are 3+ elements and the
// last one does NOT start with TAPROOT_ANNEX_PREFIX. This is handled in the catchall
// arm.
@ -267,7 +272,7 @@ impl<'a> P2TrSpend<'a> {
annex: witness.last(),
};
Some(spend)
},
}
_ => {
let spend = P2TrSpend::Script {
leaf_script: Script::from_bytes(witness.second_to_last().expect("len > 1")),
@ -275,7 +280,7 @@ impl<'a> P2TrSpend<'a> {
annex: None,
};
Some(spend)
},
}
}
}
@ -390,7 +395,8 @@ mod test {
#[test]
fn get_taproot_leaf_script() {
let tapscript = hex!("deadbeef");
let control_block = hex!("c0ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
let control_block =
hex!("c0ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
// annex starting with 0x50 causes the branching logic.
let annex = hex!("50");
@ -403,10 +409,8 @@ mod test {
let witness = deserialize::<Witness>(&witness_serialized[..]).unwrap();
let witness_annex = deserialize::<Witness>(&witness_serialized_annex[..]).unwrap();
let expected_leaf_script = LeafScript {
version: LeafVersion::TapScript,
script: Script::from_bytes(&tapscript),
};
let expected_leaf_script =
LeafScript { version: LeafVersion::TapScript, script: Script::from_bytes(&tapscript) };
// With or without annex, the tapscript should be returned.
assert_eq!(witness.taproot_leaf_script().unwrap(), expected_leaf_script);
@ -451,7 +455,8 @@ mod test {
let witness = deserialize::<Witness>(&witness_serialized[..]).unwrap();
let witness_annex = deserialize::<Witness>(&witness_serialized_annex[..]).unwrap();
let witness_key_spend_annex = deserialize::<Witness>(&witness_serialized_key_spend_annex[..]).unwrap();
let witness_key_spend_annex =
deserialize::<Witness>(&witness_serialized_key_spend_annex[..]).unwrap();
// With or without annex, the tapscript should be returned.
assert_eq!(witness.taproot_control_block(), Some(&control_block[..]));

View File

@ -435,9 +435,7 @@ impl EcdsaSighashType {
/// type (after masking with 0x1f), regardless of the ANYONECANPAY flag.
///
/// See: <https://github.com/bitcoin/bitcoin/blob/e486597/src/script/interpreter.cpp#L1618-L1619>
pub fn is_single(&self) -> bool {
matches!(self, Self::Single | Self::SinglePlusAnyoneCanPay)
}
pub fn is_single(&self) -> bool { matches!(self, Self::Single | Self::SinglePlusAnyoneCanPay) }
/// Constructs a new [`EcdsaSighashType`] from a raw `u32`.
///

View File

@ -129,9 +129,7 @@ impl<T: Tag> Default for HashEngine<T> {
}
impl<T: Tag> Clone for HashEngine<T> {
fn clone(&self) -> Self {
Self(self.0.clone(), PhantomData)
}
fn clone(&self) -> Self { Self(self.0.clone(), PhantomData) }
}
impl<T: Tag> crate::HashEngine for HashEngine<T> {

View File

@ -61,7 +61,9 @@ impl ScriptBuf {
/// Constructs a new empty script with pre-allocated capacity.
#[inline]
pub fn with_capacity(capacity: usize) -> Self { ScriptBuf::from_bytes(Vec::with_capacity(capacity)) }
pub fn with_capacity(capacity: usize) -> Self {
ScriptBuf::from_bytes(Vec::with_capacity(capacity))
}
/// Pre-allocates at least `additional_len` bytes if needed.
///
@ -96,9 +98,7 @@ impl ScriptBuf {
///
/// It is guaranteed that `script.capacity() >= script.len()` always holds.
#[inline]
pub fn capacity(&self) -> usize {
self.0.capacity()
}
pub fn capacity(&self) -> usize { self.0.capacity() }
}
impl Deref for ScriptBuf {

View File

@ -547,7 +547,9 @@ impl Version {
/// As of Bitcoin Core 28.0 ([release notes](https://bitcoincore.org/en/releases/28.0/)),
/// versions 1, 2, and 3 are considered standard.
#[inline]
pub fn is_standard(&self) -> bool { *self == Version::ONE || *self == Version::TWO || *self == Version::THREE }
pub fn is_standard(&self) -> bool {
*self == Version::ONE || *self == Version::TWO || *self == Version::THREE
}
}
impl fmt::Display for Version {