What changed, and why it matters
This commit is an automated code-formatting run by rustfmt. It only changes whitespace, import order, line breaks, and similar stylistic details across 12 files. There are no functional changes, bug fixes, or security-related alterations.
No security action needed. Treat as routine formatting cleanup.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff consists entirely of rustfmt-generated formatting changes: collapsing multi-line assert_eq!/function bodies to single lines, reordering use/re-export lists alphabetically, removing blank lines, adding a trailing newline, and rewrapping match arms. No logic, API, or behavior changes are present.
Changed components
Inspect captured patch +33 / −61
### bitcoin/examples/script.rs
@@ -41,10 +41,7 @@ fn main() {
// And so does `from_hex_prefixed`.
assert!(ScriptPubKeyBuf::from_hex_prefixed(&hex_lower_hex_trait).is_err());
// But we provide an explicit constructor that does not.
- assert_eq!(
- ScriptPubKeyBuf::from_hex_no_length_prefix(&hex_lower_hex_trait).unwrap(),
- script
- );
+ assert_eq!(ScriptPubKeyBuf::from_hex_no_length_prefix(&hex_lower_hex_trait).unwrap(), script);
// This is consensus encoding i.e., includes the length prefix.
let hex_inherent = script.to_hex_string_prefixed(); // Defined in `ScriptExt`.
### bitcoin/src/blockdata/script/mod.rs
@@ -77,10 +77,10 @@ pub use primitives::script::ScriptBufDecoderError;
#[doc(inline)]
pub use primitives::script::{
RedeemScript, RedeemScriptBuf, RedeemScriptTag, Script, ScriptBuf, ScriptBufDecoder,
- ScriptEncoder, ScriptHash, ScriptHashableTag, ScriptPubKey, ScriptPubKeyBuf, ScriptPubKeyTag,
- ScriptSig, ScriptSigBuf, ScriptSigTag, SignetBlockScript, SignetBlockScriptBuf,
- SignetBlockScriptTag, Tag, TapScript, TapScriptBuf, TapScriptTag, WScriptHash, WitnessScript,
- WitnessScriptBuf, WitnessScriptTag, ScriptCode, ScriptCodeTag,
+ ScriptCode, ScriptCodeTag, ScriptEncoder, ScriptHash, ScriptHashableTag, ScriptPubKey,
+ ScriptPubKeyBuf, ScriptPubKeyTag, ScriptSig, ScriptSigBuf, ScriptSigTag, SignetBlockScript,
+ SignetBlockScriptBuf, SignetBlockScriptTag, Tag, TapScript, TapScriptBuf, TapScriptTag,
+ WScriptHash, WitnessScript, WitnessScriptBuf, WitnessScriptTag,
};
pub(crate) use self::borrowed::ScriptExtPriv;
### bitcoin/src/blockdata/script/script_code.rs
@@ -6,11 +6,8 @@ use core::ops::Deref;
use arbitrary::{Arbitrary, Unstructured};
use crate::key::WPubkeyHash;
+use crate::opcodes::all::{OP_CHECKSIG, OP_DUP, OP_EQUALVERIFY, OP_HASH160, OP_PUSHBYTES_20};
use crate::script::ScriptCode;
-
-use crate::opcodes::all::{
- OP_CHECKSIG, OP_DUP, OP_EQUALVERIFY, OP_HASH160, OP_PUSHBYTES_20,
-};
const P2WPKH_SCRIPT_CODE_LEN: usize = 25;
/// Owned script code used for P2WPKH sighash computation.
@@ -33,23 +30,17 @@ impl P2wpkhScriptCode {
}
/// Borrows the script code without modifying or copying its bytes.
- pub fn as_script(&self) -> &ScriptCode {
- ScriptCode::from_bytes(&self.0)
- }
+ pub fn as_script(&self) -> &ScriptCode { ScriptCode::from_bytes(&self.0) }
}
impl AsRef<ScriptCode> for P2wpkhScriptCode {
- fn as_ref(&self) -> &ScriptCode {
- self.as_script()
- }
+ fn as_ref(&self) -> &ScriptCode { self.as_script() }
}
impl Deref for P2wpkhScriptCode {
type Target = ScriptCode;
-
- fn deref(&self) -> &Self::Target {
- self.as_script()
- }
+
+ fn deref(&self) -> &Self::Target { self.as_script() }
}
#[cfg(feature = "arbitrary")]
### bitcoin/src/blockdata/script/tests.rs
@@ -1038,16 +1038,11 @@ fn instruction_indices_nth_extended() {
#[test]
fn p2wpkh_script_code() {
- let wpkh = WPubkeyHash::from_byte_array(
- hex!("1d0f172a0ecb48aee1be1f2687d2963ae33f71a1"),
- );
+ let wpkh = WPubkeyHash::from_byte_array(hex!("1d0f172a0ecb48aee1be1f2687d2963ae33f71a1"));
let owned = P2wpkhScriptCode::new_p2wpkh(wpkh);
let script_code: &ScriptCode = &owned;
- assert_eq!(
- script_code.as_bytes(),
- &hex!("76a9141d0f172a0ecb48aee1be1f2687d2963ae33f71a188ac"),
- );
+ assert_eq!(script_code.as_bytes(), &hex!("76a9141d0f172a0ecb48aee1be1f2687d2963ae33f71a188ac"),);
// Check that encoding includes the CompactSize prefix.
assert_eq!(
### bitcoin/src/crypto/sighash.rs
@@ -30,9 +30,7 @@ use crate::transaction::TransactionExt as _;
use crate::witness::Witness;
#[cfg(doc)]
use crate::ScriptPubKey;
-use crate::{
- transaction, Amount, Sequence, TapScript, Transaction, TxOut, ScriptCode
-};
+use crate::{transaction, Amount, ScriptCode, Sequence, TapScript, Transaction, TxOut};
#[rustfmt::skip] // Keep public re-exports separate.
#[doc(no_inline)]
@@ -1397,7 +1395,8 @@ pub mod error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
Self::Io(error) => write_err!(f, "failed to write sighash data"; error),
- Self::Sighash(error) => write_err_unchecked_source!(f, "failed to compute sighash data"; error),
+ Self::Sighash(error) =>
+ write_err_unchecked_source!(f, "failed to compute sighash data"; error),
}
}
}
### bitcoin/src/lib.rs
@@ -142,10 +142,10 @@ pub use primitives::{
},
merkle_tree::{TxMerkleNode, WitnessMerkleNode},
script::{
- RedeemScript, RedeemScriptBuf, RedeemScriptTag, ScriptHashableTag, ScriptPubKey,
- ScriptPubKeyBuf, ScriptPubKeyTag, ScriptSig, ScriptSigBuf, ScriptSigTag, SignetBlockScript,
- SignetBlockScriptBuf, SignetBlockScriptTag, Tag, TapScript, TapScriptBuf, TapScriptTag,
- WitnessScript, WitnessScriptBuf, WitnessScriptTag, ScriptCode, ScriptCodeTag,
+ RedeemScript, RedeemScriptBuf, RedeemScriptTag, ScriptCode, ScriptCodeTag,
+ ScriptHashableTag, ScriptPubKey, ScriptPubKeyBuf, ScriptPubKeyTag, ScriptSig, ScriptSigBuf,
+ ScriptSigTag, SignetBlockScript, SignetBlockScriptBuf, SignetBlockScriptTag, Tag,
+ TapScript, TapScriptBuf, TapScriptTag, WitnessScript, WitnessScriptBuf, WitnessScriptTag,
},
transaction::{OutPoint, Transaction, TxIn, TxOut, Txid, Version as TransactionVersion, Wtxid},
witness::Witness,
@@ -202,9 +202,9 @@ pub use crate::{
blockdata::opcodes::{self, Opcode},
blockdata::script::witness_program::{self, WitnessProgram},
blockdata::script::witness_version::{self, WitnessVersion},
+ blockdata::script::P2wpkhScriptCode,
// These modules also re-export all the respective `primitives` types.
blockdata::{block, constants, fee_rate, locktime, script, transaction, weight, witness},
- blockdata::script::P2wpkhScriptCode,
};
#[rustfmt::skip]
### internals/src/error/mod.rs
@@ -24,7 +24,7 @@ pub trait ErrorExt: std::error::Error + 'static {
#[doc(hidden)]
#[cfg(feature = "std")]
-impl<T: std::error::Error + 'static> ErrorExt for T { }
+impl<T: std::error::Error + 'static> ErrorExt for T {}
/// Formats error.
///
### primitives/src/lib.rs
@@ -120,9 +120,9 @@ pub use self::{
Block, Checked as BlockChecked, Unchecked as BlockUnchecked, Validation as BlockValidation,
},
script::{
- RedeemScript, RedeemScriptBuf, ScriptPubKey, ScriptPubKeyBuf, ScriptSig, ScriptSigBuf,
- SignetBlockScript, SignetBlockScriptBuf, TapScript, TapScriptBuf, WitnessScript,
- WitnessScriptBuf, ScriptCode,
+ RedeemScript, RedeemScriptBuf, ScriptCode, ScriptPubKey, ScriptPubKeyBuf, ScriptSig,
+ ScriptSigBuf, SignetBlockScript, SignetBlockScriptBuf, TapScript, TapScriptBuf,
+ WitnessScript, WitnessScriptBuf,
},
transaction::{Transaction, TxIn, TxOut},
witness::Witness,
### primitives/src/script/mod.rs
@@ -224,9 +224,7 @@ impl TryFrom<&WitnessScript> for WScriptHash {
/// Borrows the entire witness script as `ScriptCode`.
impl AsRef<ScriptCode> for WitnessScript {
- fn as_ref(&self) -> &ScriptCode {
- ScriptCode::from_bytes(self.as_bytes())
- }
+ fn as_ref(&self) -> &ScriptCode { ScriptCode::from_bytes(self.as_bytes()) }
}
impl AsRef<ScriptCode> for WitnessScriptBuf {
@@ -239,9 +237,7 @@ impl AsRef<ScriptCode> for WitnessScriptBuf {
/// Borrows the entire redeem script as `ScriptCode`.
impl AsRef<ScriptCode> for RedeemScript {
- fn as_ref(&self) -> &ScriptCode {
- ScriptCode::from_bytes(self.as_bytes())
- }
+ fn as_ref(&self) -> &ScriptCode { ScriptCode::from_bytes(self.as_bytes()) }
}
impl AsRef<ScriptCode> for RedeemScriptBuf {
@@ -253,9 +249,7 @@ impl AsRef<ScriptCode> for RedeemScriptBuf {
/// Borrows the entire script pubkey as `ScriptCode`.
impl AsRef<ScriptCode> for ScriptPubKey {
- fn as_ref(&self) -> &ScriptCode {
- ScriptCode::from_bytes(self.as_bytes())
- }
+ fn as_ref(&self) -> &ScriptCode { ScriptCode::from_bytes(self.as_bytes()) }
}
impl AsRef<ScriptCode> for ScriptPubKeyBuf {
### primitives/src/script/tag.rs
@@ -52,4 +52,4 @@ impl Tag for WitnessScriptTag {}
/// A script code (scriptCode) used in sighash computation.
#[derive(Debug, Clone, PartialOrd, Ord, PartialEq, Eq, Hash)]
pub enum ScriptCodeTag {}
-impl Tag for ScriptCodeTag {}
\ No newline at end of file
+impl Tag for ScriptCodeTag {}
### primitives/src/witness.rs
@@ -1071,8 +1071,7 @@ pub mod error {
match self.0 {
E::LengthPrefixDecode(ref e) =>
write_err!(f, "failed to decode witness length prefix"; e),
- E::UnexpectedEof(ref e) =>
- write_err!(f, "failed to decode witness"; e),
+ E::UnexpectedEof(ref e) => write_err!(f, "failed to decode witness"; e),
E::WitnessTooLarge(size) => write!(
f,
"serialized witness size of {} bytes exceeds the maximum of {}",
### units/src/amount/serde.rs
@@ -25,10 +25,11 @@
#[cfg(feature = "alloc")]
use core::fmt;
+use sealed::Token;
+
#[cfg(feature = "alloc")]
use super::ParseAmountError;
use crate::{Amount, SignedAmount};
-use sealed::Token;
#[cfg(feature = "alloc")]
struct DisplayFullError(ParseAmountError);
@@ -71,15 +72,11 @@ mod sealed {
}
impl AmountOps for Amount {
- fn is_signed(_: Token) -> bool {
- false
- }
+ fn is_signed(_: Token) -> bool { false }
}
impl AmountOps for SignedAmount {
- fn is_signed(_: Token) -> bool {
- true
- }
+ fn is_signed(_: Token) -> bool { true }
}
#[doc(hidden)]Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.