What changed, and why it matters
This commit is a routine automated code-formatting run using the nightly version of rustfmt. It only changes whitespace, line breaks, import order, and comment alignment across 19 files. No program logic, security behavior, or API semantics were altered.
No security action needed. Treat as a normal formatting-only commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff consists entirely of rustfmt style changes: rewrapping long lines, reordering/re-grouping use statements, adjusting indentation, and aligning comments. There are no functional code changes, no new unsafe blocks, no changes to consensus serialization logic beyond formatting, and no bug fixes. The single unsafe block in bitcoin/src/consensus/encode.rs is unchanged in content; only its surrounding whitespace was reformatted.
Changed components
Inspect captured patch +67 / −63
diff --git a/bitcoin/examples/sign-tx-segwit-v0.rs b/bitcoin/examples/sign-tx-segwit-v0.rs
index 7c2808d2..de41c91c 100644
--- a/bitcoin/examples/sign-tx-segwit-v0.rs
+++ b/bitcoin/examples/sign-tx-segwit-v0.rs
@@ -51,8 +51,8 @@ fn main() {
let mut unsigned_tx = Transaction {
version: transaction::Version::TWO, // Post BIP-68.
lock_time: absolute::LockTime::ZERO, // Ignore the locktime.
- inputs: vec![input], // Input goes into index 0.
- outputs: vec![spend, change], // Outputs, order does not matter.
+ inputs: vec![input], // Input goes into index 0.
+ outputs: vec![spend, change], // Outputs, order does not matter.
};
let input_index = 0;
diff --git a/bitcoin/examples/sign-tx-taproot.rs b/bitcoin/examples/sign-tx-taproot.rs
index 7f1ab505..eaa312e3 100644
--- a/bitcoin/examples/sign-tx-taproot.rs
+++ b/bitcoin/examples/sign-tx-taproot.rs
@@ -51,8 +51,8 @@ fn main() {
let mut unsigned_tx = Transaction {
version: transaction::Version::TWO, // Post BIP-68.
lock_time: absolute::LockTime::ZERO, // Ignore the locktime.
- inputs: vec![input], // Input goes into index 0.
- outputs: vec![spend, change], // Outputs, order does not matter.
+ inputs: vec![input], // Input goes into index 0.
+ outputs: vec![spend, change], // Outputs, order does not matter.
};
let input_index = 0;
diff --git a/bitcoin/examples/taproot-psbt-simple.rs b/bitcoin/examples/taproot-psbt-simple.rs
index f9e5814d..8ba75a05 100644
--- a/bitcoin/examples/taproot-psbt-simple.rs
+++ b/bitcoin/examples/taproot-psbt-simple.rs
@@ -197,7 +197,7 @@ fn main() {
version: transaction::Version::TWO, // Post BIP 68.
lock_time: absolute::LockTime::ZERO, // Ignore the locktime.
inputs, // Input is 0-indexed.
- outputs: vec![spend, change], // Outputs, order does not matter.
+ outputs: vec![spend, change], // Outputs, order does not matter.
};
// Now we'll start the PSBT workflow.
diff --git a/bitcoin/src/blockdata/block.rs b/bitcoin/src/blockdata/block.rs
index 3e3a38b9..eb38d43b 100644
--- a/bitcoin/src/blockdata/block.rs
+++ b/bitcoin/src/blockdata/block.rs
@@ -18,14 +18,13 @@ use super::transaction::Coinbase;
use super::Weight;
use crate::consensus::encode::WriteExt as _;
use crate::consensus::{encode, Decodable, Encodable};
-use crate::internal_macros;
use crate::merkle_tree::{MerkleNode as _, TxMerkleNode, WitnessMerkleNode};
use crate::network::Params;
use crate::pow::{Target, Work};
use crate::prelude::Vec;
use crate::script::{self, ScriptExt as _};
use crate::transaction::{Transaction, TransactionExt as _, Wtxid};
-use crate::BlockTime;
+use crate::{internal_macros, BlockTime};
#[rustfmt::skip] // Keep public re-exports separate.
#[doc(inline)]
diff --git a/bitcoin/src/blockdata/witness.rs b/bitcoin/src/blockdata/witness.rs
index dcc7718f..1d20f8bb 100644
--- a/bitcoin/src/blockdata/witness.rs
+++ b/bitcoin/src/blockdata/witness.rs
@@ -492,7 +492,10 @@ mod test {
assert_eq!(expected_wit[i], wit_el.to_lower_hex_string());
}
assert_eq!(expected_wit[1], tx.inputs[0].witness.last().unwrap().to_lower_hex_string());
- assert_eq!(expected_wit[0], tx.inputs[0].witness.get_back(1).unwrap().to_lower_hex_string());
+ assert_eq!(
+ expected_wit[0],
+ tx.inputs[0].witness.get_back(1).unwrap().to_lower_hex_string()
+ );
assert_eq!(expected_wit[0], tx.inputs[0].witness.get(0).unwrap().to_lower_hex_string());
assert_eq!(expected_wit[1], tx.inputs[0].witness.get(1).unwrap().to_lower_hex_string());
assert_eq!(None, tx.inputs[0].witness.get(2));
diff --git a/bitcoin/src/consensus/encode.rs b/bitcoin/src/consensus/encode.rs
index ab14b298..23c2bc26 100644
--- a/bitcoin/src/consensus/encode.rs
+++ b/bitcoin/src/consensus/encode.rs
@@ -468,18 +468,13 @@ impl Encodable for [u16; 8] {
impl<T: Encodable + 'static> Encodable for Vec<T> {
#[inline]
- fn consensus_encode<W: Write + ?Sized>(
- &self,
- w: &mut W,
- ) -> Result<usize, io::Error> {
+ fn consensus_encode<W: Write + ?Sized>(&self, w: &mut W) -> Result<usize, io::Error> {
if TypeId::of::<T>() == TypeId::of::<u8>() {
let len = self.len();
let ptr = self.as_ptr();
// unsafe: We've just checked that T is `u8`.
- let v = unsafe {
- slice::from_raw_parts(ptr.cast::<u8>(), len)
- };
+ let v = unsafe { slice::from_raw_parts(ptr.cast::<u8>(), len) };
consensus_encode_with_size(v, w)
} else {
let mut len = 0;
@@ -944,8 +939,7 @@ mod tests {
// Check serialization that `if len > MAX_VEC_SIZE {return err}` isn't inclusive,
// by making sure it fails with `MissingData` and not an `OversizedVectorAllocation` Error.
- let err =
- deserialize::<BlockHash>(&serialize(&(super::MAX_VEC_SIZE as u32))).unwrap_err();
+ let err = deserialize::<BlockHash>(&serialize(&(super::MAX_VEC_SIZE as u32))).unwrap_err();
assert_eq!(err, DeserializeError::Parse(ParseError::MissingData));
test_len_is_max_vec::<u8>();
diff --git a/bitcoin/src/crypto/sighash.rs b/bitcoin/src/crypto/sighash.rs
index 8ffeb730..92d1a72e 100644
--- a/bitcoin/src/crypto/sighash.rs
+++ b/bitcoin/src/crypto/sighash.rs
@@ -853,7 +853,8 @@ impl<R: Borrow<Transaction>> SighashCache<R> {
if sighash != EcdsaSighashType::Single && sighash != EcdsaSighashType::None {
self.segwit_cache().outputs.consensus_encode(writer)?;
- } else if sighash == EcdsaSighashType::Single && input_index < self.tx.borrow().outputs.len()
+ } else if sighash == EcdsaSighashType::Single
+ && input_index < self.tx.borrow().outputs.len()
{
let mut single_enc = LegacySighash::engine();
self.tx.borrow().outputs[input_index].consensus_encode(&mut single_enc)?;
diff --git a/bitcoin/src/psbt/error.rs b/bitcoin/src/psbt/error.rs
index c2745e59..2993e6dc 100644
--- a/bitcoin/src/psbt/error.rs
+++ b/bitcoin/src/psbt/error.rs
@@ -9,7 +9,7 @@ use crate::bip32::Xpub;
use crate::consensus::encode;
use crate::prelude::Box;
use crate::psbt::raw;
-use crate::{key, ecdsa, taproot, Txid, Transaction, OutPoint};
+use crate::{ecdsa, key, taproot, OutPoint, Transaction, Txid};
/// Enum for marking psbt hash error.
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
diff --git a/bitcoin/tests/serde.rs b/bitcoin/tests/serde.rs
index d0f7871c..34467f86 100644
--- a/bitcoin/tests/serde.rs
+++ b/bitcoin/tests/serde.rs
@@ -32,8 +32,8 @@ use bitcoin::sighash::{EcdsaSighashType, TapSighashType};
use bitcoin::taproot::{self, ControlBlock, LeafVersion, TapTree, TaprootBuilder};
use bitcoin::witness::Witness;
use bitcoin::{
- ecdsa, transaction, Address, Amount, NetworkKind, OutPoint, PrivateKey, PublicKey,
- ScriptBuf, Sequence, Target, Transaction, TxIn, TxOut, Txid, Work,
+ ecdsa, transaction, Address, Amount, NetworkKind, OutPoint, PrivateKey, PublicKey, ScriptBuf,
+ Sequence, Target, Transaction, TxIn, TxOut, Txid, Work,
};
#[test]
diff --git a/p2p/src/message.rs b/p2p/src/message.rs
index b28cf903..451bf269 100644
--- a/p2p/src/message.rs
+++ b/p2p/src/message.rs
@@ -8,13 +8,14 @@
use alloc::borrow::{Cow, ToOwned};
use alloc::boxed::Box;
use alloc::string::String;
-use alloc::vec::Vec;
use alloc::vec;
+use alloc::vec::Vec;
use core::{cmp, fmt};
+use bitcoin::block::HeaderExt;
use bitcoin::consensus::encode::{self, Decodable, Encodable, ReadExt, WriteExt};
use bitcoin::merkle_tree::MerkleBlock;
-use bitcoin::{block, block::HeaderExt, transaction};
+use bitcoin::{block, transaction};
use hashes::sha256d;
use internals::ToU64 as _;
use io::{self, BufRead, Read, Write};
@@ -421,8 +422,7 @@ impl Encodable for NetworkMessage {
NetworkMessage::GetHeaders(ref dat) => dat.consensus_encode(writer),
NetworkMessage::Tx(ref dat) => dat.consensus_encode(writer),
NetworkMessage::Block(ref dat) => dat.consensus_encode(writer),
- NetworkMessage::Headers(ref dat) =>
- dat.consensus_encode(writer),
+ NetworkMessage::Headers(ref dat) => dat.consensus_encode(writer),
NetworkMessage::Ping(ref dat) => dat.consensus_encode(writer),
NetworkMessage::Pong(ref dat) => dat.consensus_encode(writer),
NetworkMessage::MerkleBlock(ref dat) => dat.consensus_encode(writer),
@@ -538,13 +538,11 @@ impl HeadersMessage {
/// Each header passes its own proof-of-work target.
pub fn all_targets_satisfied(&self) -> bool {
- !self.0
- .iter()
- .any(|header| {
- let target = header.target();
- let valid_pow = header.validate_pow(target);
- valid_pow.is_err()
- })
+ !self.0.iter().any(|header| {
+ let target = header.target();
+ let valid_pow = header.validate_pow(target);
+ valid_pow.is_err()
+ })
}
}
@@ -732,9 +730,8 @@ impl Decodable for V2NetworkMessage {
10u8 => NetworkMessage::GetBlockTxn(Decodable::consensus_decode_from_finite_reader(r)?),
11u8 => NetworkMessage::GetData(Decodable::consensus_decode_from_finite_reader(r)?),
12u8 => NetworkMessage::GetHeaders(Decodable::consensus_decode_from_finite_reader(r)?),
- 13u8 => NetworkMessage::Headers(
- HeadersMessage::consensus_decode_from_finite_reader(r)?,
- ),
+ 13u8 =>
+ NetworkMessage::Headers(HeadersMessage::consensus_decode_from_finite_reader(r)?),
14u8 => NetworkMessage::Inv(Decodable::consensus_decode_from_finite_reader(r)?),
15u8 => NetworkMessage::MemPool,
16u8 => NetworkMessage::MerkleBlock(Decodable::consensus_decode_from_finite_reader(r)?),
@@ -803,7 +800,9 @@ impl Encodable for CheckedData {
impl Decodable for CheckedData {
#[inline]
- fn consensus_decode_from_finite_reader<R: BufRead + ?Sized>(r: &mut R) -> Result<Self, encode::Error> {
+ fn consensus_decode_from_finite_reader<R: BufRead + ?Sized>(
+ r: &mut R,
+ ) -> Result<Self, encode::Error> {
let len = u32::consensus_decode_from_finite_reader(r)? as usize;
let checksum = <[u8; 4]>::consensus_decode_from_finite_reader(r)?;
@@ -811,8 +810,11 @@ impl Decodable for CheckedData {
let data = read_bytes_from_finite_reader(r, opts)?;
let expected_checksum = sha2_checksum(&data);
if expected_checksum != checksum {
- Err(encode::ParseError::InvalidChecksum { expected: expected_checksum, actual: checksum }
- .into())
+ Err(encode::ParseError::InvalidChecksum {
+ expected: expected_checksum,
+ actual: checksum,
+ }
+ .into())
} else {
Ok(CheckedData { data, checksum })
}
diff --git a/primitives/src/block.rs b/primitives/src/block.rs
index ded539ae..00ac2a88 100644
--- a/primitives/src/block.rs
+++ b/primitives/src/block.rs
@@ -395,11 +395,11 @@ impl<'a> Arbitrary<'a> for Version {
#[cfg(test)]
mod tests {
- use super::*;
-
- #[cfg(feature = "alloc")]
+ #[cfg(feature = "alloc")]
use alloc::{format, vec};
+ use super::*;
+
fn dummy_header() -> Header {
Header {
version: Version::ONE,
diff --git a/primitives/src/opcodes.rs b/primitives/src/opcodes.rs
index 376478ff..6def038d 100644
--- a/primitives/src/opcodes.rs
+++ b/primitives/src/opcodes.rs
@@ -545,11 +545,11 @@ impl Ordinary {
#[cfg(test)]
mod tests {
- use super::*;
-
#[cfg(feature = "alloc")]
use alloc::{collections::BTreeSet, format};
+ use super::*;
+
#[cfg(feature = "alloc")]
macro_rules! roundtrip {
($unique:expr, $op:ident) => {
diff --git a/primitives/src/pow.rs b/primitives/src/pow.rs
index 00ec8629..3cffa64c 100644
--- a/primitives/src/pow.rs
+++ b/primitives/src/pow.rs
@@ -50,10 +50,10 @@ impl fmt::UpperHex for CompactTarget {
#[cfg(test)]
mod tests {
- use super::*;
-
#[cfg(feature = "alloc")]
- use alloc::{format};
+ use alloc::format;
+
+ use super::*;
#[test]
fn compact_target_ordering() {
diff --git a/primitives/src/script/borrowed.rs b/primitives/src/script/borrowed.rs
index 349cfddc..cf662aa2 100644
--- a/primitives/src/script/borrowed.rs
+++ b/primitives/src/script/borrowed.rs
@@ -188,10 +188,10 @@ delegate_index!(
#[cfg(test)]
mod tests {
- use super::*;
-
#[cfg(feature = "alloc")]
- use alloc::{vec};
+ use alloc::vec;
+
+ use super::*;
#[test]
fn script_from_bytes() {
diff --git a/primitives/src/script/mod.rs b/primitives/src/script/mod.rs
index 2f2b3afd..233cede0 100644
--- a/primitives/src/script/mod.rs
+++ b/primitives/src/script/mod.rs
@@ -611,11 +611,11 @@ impl<'de> serde::Deserialize<'de> for ScriptBuf {
#[cfg(test)]
mod tests {
- use super::*;
-
#[cfg(feature = "alloc")]
use alloc::{format, vec};
+ use super::*;
+
#[test]
fn scriptbuf_from_vec_u8() {
let vec = vec![0x51, 0x52, 0x53];
diff --git a/primitives/src/script/owned.rs b/primitives/src/script/owned.rs
index 916276f9..9fb73fae 100644
--- a/primitives/src/script/owned.rs
+++ b/primitives/src/script/owned.rs
@@ -148,10 +148,10 @@ impl<'a> Arbitrary<'a> for ScriptBuf {
#[cfg(test)]
mod tests {
- use super::*;
-
#[cfg(feature = "alloc")]
- use alloc::{vec};
+ use alloc::vec;
+
+ use super::*;
#[test]
fn script_buf_from_bytes() {
diff --git a/primitives/src/transaction.rs b/primitives/src/transaction.rs
index 3ca18d15..80db09ca 100644
--- a/primitives/src/transaction.rs
+++ b/primitives/src/transaction.rs
@@ -642,11 +642,11 @@ impl<'a> Arbitrary<'a> for Wtxid {
#[cfg(feature = "alloc")]
#[cfg(test)]
mod tests {
- use super::*;
-
#[cfg(feature = "alloc")]
use alloc::{format, vec};
+ use super::*;
+
#[test]
fn sanity_check() {
let version = Version(123);
diff --git a/primitives/src/witness.rs b/primitives/src/witness.rs
index 7d506f34..47b73dbc 100644
--- a/primitives/src/witness.rs
+++ b/primitives/src/witness.rs
@@ -575,14 +575,13 @@ impl<'a> Arbitrary<'a> for Witness {
#[cfg(test)]
mod test {
- use super::*;
-
#[cfg(feature = "alloc")]
- use alloc::{vec};
-
+ use alloc::vec;
#[cfg(feature = "std")]
use std::println;
+ use super::*;
+
// Appends all the indices onto the end of a list of elements.
fn append_u32_vec(elements: &[u8], indices: &[u32]) -> Vec<u8> {
let mut v = elements.to_vec();
diff --git a/units/src/fee_rate/mod.rs b/units/src/fee_rate/mod.rs
index 4472e3a0..bcf690b7 100644
--- a/units/src/fee_rate/mod.rs
+++ b/units/src/fee_rate/mod.rs
@@ -106,19 +106,25 @@ impl FeeRate {
pub const fn to_sat_per_kwu_floor(self) -> u64 { self.to_sat_per_mvb() / 4_000 }
/// Converts to sat/kwu rounding up.
- pub const fn to_sat_per_kwu_ceil(self) -> u64 { self.to_sat_per_mvb().saturating_add(3_999) / 4_000 }
+ pub const fn to_sat_per_kwu_ceil(self) -> u64 {
+ self.to_sat_per_mvb().saturating_add(3_999) / 4_000
+ }
/// Converts to sat/vB rounding down.
pub const fn to_sat_per_vb_floor(self) -> u64 { self.to_sat_per_mvb() / 1_000_000 }
/// Converts to sat/vB rounding up.
- pub const fn to_sat_per_vb_ceil(self) -> u64 { self.to_sat_per_mvb().saturating_add(999_999) / 1_000_000 }
+ pub const fn to_sat_per_vb_ceil(self) -> u64 {
+ self.to_sat_per_mvb().saturating_add(999_999) / 1_000_000
+ }
/// Converts to sat/kvb rounding down.
pub const fn to_sat_per_kvb_floor(self) -> u64 { self.to_sat_per_mvb() / 1_000 }
/// Converts to sat/kvb rounding up.
- pub const fn to_sat_per_kvb_ceil(self) -> u64 { self.to_sat_per_mvb().saturating_add(999) / 1_000 }
+ pub const fn to_sat_per_kvb_ceil(self) -> u64 {
+ self.to_sat_per_mvb().saturating_add(999) / 1_000
+ }
/// Checked multiplication.
///
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.