What changed, and why it matters
This is a purely cosmetic code-formatting commit. It only reorders imports, rewraps long lines, and collapses or expands function bodies to match the latest rustfmt nightly style. No program logic, behavior, or security properties were changed.
No action required. This is a formatting-only change and can be treated as non-security relevant.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit applies an automated rustfmt pass across 10 Rust source files. Changes are limited to import reordering, line wrapping, and brace placement. No functional code, control flow, arithmetic, cryptographic operations, parsing logic, or API signatures were modified. There is no security-relevant change.
Changed components
Inspect captured patch +120 / −60
diff --git a/crypto/src/taproot.rs b/crypto/src/taproot.rs
index 47bc628d..7188b777 100644
--- a/crypto/src/taproot.rs
+++ b/crypto/src/taproot.rs
@@ -213,9 +213,7 @@ impl fmt::Display for SerializedSignature {
impl fmt::LowerHex for SerializedSignature {
#[inline]
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- self.fmt_internal(f, hex::Case::Lower)
- }
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { self.fmt_internal(f, hex::Case::Lower) }
}
#[cfg(feature = "alloc")]
impl_to_hex_from_lower_hex!(SerializedSignature, |signature: &SerializedSignature| signature.len
@@ -223,9 +221,7 @@ impl_to_hex_from_lower_hex!(SerializedSignature, |signature: &SerializedSignatur
impl fmt::UpperHex for SerializedSignature {
#[inline]
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- self.fmt_internal(f, hex::Case::Upper)
- }
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { self.fmt_internal(f, hex::Case::Upper) }
}
impl PartialEq for SerializedSignature {
@@ -488,10 +484,12 @@ pub mod error {
impl fmt::Display for ParseSignatureError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
- Self::InvalidLength(len) =>
- write!(f, "signature must be 128 or 130 ASCII characters long but it had {} bytes", len),
- Self::InvalidChar(ref e) =>
- write_err!(f, "invalid character in signature"; e),
+ Self::InvalidLength(len) => write!(
+ f,
+ "signature must be 128 or 130 ASCII characters long but it had {} bytes",
+ len
+ ),
+ Self::InvalidChar(ref e) => write_err!(f, "invalid character in signature"; e),
Self::Decode(ref e) => write_err!(f, "signature byte slice decoding error"; e),
}
}
diff --git a/io/src/lib.rs b/io/src/lib.rs
index 72f1d41c..da50f544 100644
--- a/io/src/lib.rs
+++ b/io/src/lib.rs
@@ -818,7 +818,10 @@ mod tests {
type Output = TestArray;
type Error = UnexpectedEofError;
- fn push_bytes(&mut self, bytes: &mut &[u8]) -> core::result::Result<encoding::DecoderStatus, Self::Error> {
+ fn push_bytes(
+ &mut self,
+ bytes: &mut &[u8],
+ ) -> core::result::Result<encoding::DecoderStatus, Self::Error> {
self.inner.push_bytes(bytes)
}
diff --git a/p2p/src/address.rs b/p2p/src/address.rs
index b3abb3eb..a0c9d93c 100644
--- a/p2p/src/address.rs
+++ b/p2p/src/address.rs
@@ -13,7 +13,7 @@ use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV
use arbitrary::{Arbitrary, Unstructured};
use encoding::{
ArrayDecoder, ArrayEncoder, ByteVecDecoder, BytesEncoder, CompactSizeEncoder,
- CompactSizeU64Decoder, Decoder2, Decoder4, EncoderStatus, Encoder2, Encoder4,
+ CompactSizeU64Decoder, Decoder2, Decoder4, Encoder2, Encoder4, EncoderStatus,
};
use internals::array::ArrayExt;
diff --git a/p2p/src/merkle_tree.rs b/p2p/src/merkle_tree.rs
index 063d495a..242d2ade 100644
--- a/p2p/src/merkle_tree.rs
+++ b/p2p/src/merkle_tree.rs
@@ -15,8 +15,8 @@ use alloc::vec::Vec;
#[cfg(feature = "arbitrary")]
use arbitrary::{Arbitrary, Unstructured};
use encoding::{
- ArrayDecoder, ArrayEncoder, ByteVecDecoder, CompactSizeEncoder, Decoder2, Decoder3,
- EncoderStatus, Encoder2, Encoder3, SliceEncoder, VecDecoder,
+ ArrayDecoder, ArrayEncoder, ByteVecDecoder, CompactSizeEncoder, Decoder2, Decoder3, Encoder2,
+ Encoder3, EncoderStatus, SliceEncoder, VecDecoder,
};
use internals::ToU64 as _;
use primitives::block::{self, Block, Checked, Header, HeaderDecoder, HeaderEncoder};
diff --git a/p2p/src/message.rs b/p2p/src/message.rs
index c5b05411..2aaaeb25 100644
--- a/p2p/src/message.rs
+++ b/p2p/src/message.rs
@@ -14,8 +14,8 @@ use core::{fmt, mem};
#[cfg(feature = "arbitrary")]
use arbitrary::{Arbitrary, Unstructured};
use encoding::{
- self, ArrayDecoder, ArrayEncoder, BytesEncoder, CompactSizeEncoder, Decoder2, EncoderStatus,
- Encoder2, SliceEncoder, VecDecoder, VecDecoderError,
+ self, ArrayDecoder, ArrayEncoder, BytesEncoder, CompactSizeEncoder, Decoder2, Encoder2,
+ EncoderStatus, SliceEncoder, VecDecoder, VecDecoderError,
};
use hashes::{sha256d, HashEngine};
use primitives::block::{self, Header, HeaderDecoder, HeaderEncoder};
@@ -1161,7 +1161,11 @@ impl encoding::Decoder for NetworkMessageDecoderInner {
buffer.extend_from_slice(to_copy);
*bytes = rest;
*remaining -= copy_len;
- Ok(if *remaining > 0 { encoding::DecoderStatus::NeedsMore } else { encoding::DecoderStatus::Ready })
+ Ok(if *remaining > 0 {
+ encoding::DecoderStatus::NeedsMore
+ } else {
+ encoding::DecoderStatus::Ready
+ })
}
}
}
diff --git a/p2p/src/message_erlay.rs b/p2p/src/message_erlay.rs
index 3d4c47ae..2a07840f 100644
--- a/p2p/src/message_erlay.rs
+++ b/p2p/src/message_erlay.rs
@@ -23,14 +23,10 @@ impl SendTxRcnCl {
pub const VERSION_ONE: u32 = 1;
/// Build a new announcement for erlay with salt.
- pub fn from_salt(salt: u64) -> Self {
- Self { version: Self::VERSION_ONE, salt }
- }
+ pub fn from_salt(salt: u64) -> Self { Self { version: Self::VERSION_ONE, salt } }
/// Get the transaction reconciliation protocol version.
- pub fn version(&self) -> u32 {
- self.version
- }
+ pub fn version(&self) -> u32 { self.version }
}
encoding::encoder_newtype_exact! {
@@ -74,6 +70,7 @@ impl encoding::Decode for SendTxRcnCl {
pub mod error {
use core::convert::Infallible;
use core::fmt;
+
use internals::write_err;
/// An error occurring when decoding a [`SendTxRcnCl`](super) message.
@@ -83,9 +80,7 @@ pub mod error {
);
impl From<Infallible> for SendTxRcnClDecoderError {
- fn from(never: Infallible) -> Self {
- match never {}
- }
+ fn from(never: Infallible) -> Self { match never {} }
}
impl fmt::Display for SendTxRcnClDecoderError {
@@ -96,8 +91,6 @@ pub mod error {
#[cfg(feature = "std")]
impl std::error::Error for SendTxRcnClDecoderError {
- fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
- Some(&self.0)
- }
+ fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { Some(&self.0) }
}
}
diff --git a/primitives/src/script/push_bytes.rs b/primitives/src/script/push_bytes.rs
index d267c02b..db6a4829 100644
--- a/primitives/src/script/push_bytes.rs
+++ b/primitives/src/script/push_bytes.rs
@@ -2,8 +2,8 @@
//! Contains `PushBytes` & co
-use core::convert::Infallible;
use core::borrow::{Borrow, BorrowMut};
+use core::convert::Infallible;
use core::ops::{Deref, DerefMut};
#[rustfmt::skip] // Keep public re-exports separate.
diff --git a/primitives/src/transaction.rs b/primitives/src/transaction.rs
index 8bc93ce9..bcacd0d0 100644
--- a/primitives/src/transaction.rs
+++ b/primitives/src/transaction.rs
@@ -19,8 +19,8 @@ use arbitrary::{Arbitrary, Unstructured};
use encoding::{ArrayEncoder, BytesEncoder, Encoder2};
#[cfg(feature = "alloc")]
use encoding::{
- CompactSizeEncoder, Decoder2, Decoder3, DecoderStatus, Encode as _, Encoder3, Encoder6, EncoderStatus, SliceEncoder,
- VecDecoder,
+ CompactSizeEncoder, Decoder2, Decoder3, DecoderStatus, Encode as _, Encoder3, Encoder6,
+ EncoderStatus, SliceEncoder, VecDecoder,
};
#[cfg(feature = "alloc")]
use hashes::sha256d;
diff --git a/primitives/src/witness.rs b/primitives/src/witness.rs
index 9323172b..28ab7747 100644
--- a/primitives/src/witness.rs
+++ b/primitives/src/witness.rs
@@ -12,7 +12,8 @@ use arbitrary::{Arbitrary, Unstructured};
#[cfg(doc)]
use encoding::Decoder4;
use encoding::{
- self, BytesEncoder, CompactSizeDecoder, CompactSizeEncoder, Decoder as _, DecoderStatus, EncoderStatus, Encoder2,
+ self, BytesEncoder, CompactSizeDecoder, CompactSizeEncoder, Decoder as _, DecoderStatus,
+ Encoder2, EncoderStatus,
};
#[cfg(feature = "hex")]
use hex::DecodeVariableLengthBytesError;
@@ -1006,9 +1007,9 @@ mod test {
#[cfg(feature = "std")]
use std::error::Error as _;
+ use encoding::check_encode;
#[cfg(feature = "alloc")]
use encoding::Decode as _;
- use encoding::check_encode;
use super::*;
diff --git a/primitives/tests/encoding.rs b/primitives/tests/encoding.rs
index b856f7b7..a317a321 100644
--- a/primitives/tests/encoding.rs
+++ b/primitives/tests/encoding.rs
@@ -99,7 +99,16 @@ fn encode_tx_out() {
#[test]
fn encode_tx_in() {
let txin = segwit_tx_in();
- check_encode(&txin, &concat_slices!(&TC_TXID_BYTES, &TC_VOUT_BYTES, &[3u8], &TC_SCRIPT_BYTES, &TC_SEQ_MAX_BYTES));
+ check_encode(
+ &txin,
+ &concat_slices!(
+ &TC_TXID_BYTES,
+ &TC_VOUT_BYTES,
+ &[3u8],
+ &TC_SCRIPT_BYTES,
+ &TC_SEQ_MAX_BYTES
+ ),
+ );
}
#[test]
@@ -111,7 +120,26 @@ fn encode_segwit_transaction() {
outputs: vec![tx_out()],
};
- check_encode(&tx, &concat_slices!(&[2u8, 0, 0, 0], &TC_SEGWIT_MARKER_AND_FLAG, &[1u8], &TC_TXID_BYTES, &TC_VOUT_BYTES, &[3u8], &TC_SCRIPT_BYTES, &TC_SEQ_MAX_BYTES, &[1u8], &TC_ONE_SAT_BYTES, &[3u8], &TC_SCRIPT_BYTES, &[1u8], &TC_WITNESS_ELEM_LEN_AND_DATA, &TC_LOCK_TIME_ZERO_BYTES));
+ check_encode(
+ &tx,
+ &concat_slices!(
+ &[2u8, 0, 0, 0],
+ &TC_SEGWIT_MARKER_AND_FLAG,
+ &[1u8],
+ &TC_TXID_BYTES,
+ &TC_VOUT_BYTES,
+ &[3u8],
+ &TC_SCRIPT_BYTES,
+ &TC_SEQ_MAX_BYTES,
+ &[1u8],
+ &TC_ONE_SAT_BYTES,
+ &[3u8],
+ &TC_SCRIPT_BYTES,
+ &[1u8],
+ &TC_WITNESS_ELEM_LEN_AND_DATA,
+ &TC_LOCK_TIME_ZERO_BYTES
+ ),
+ );
}
#[test]
@@ -126,7 +154,23 @@ fn encode_non_segwit_transaction() {
outputs: vec![tx_out()],
};
- check_encode(&tx, &concat_slices!(&[2u8, 0, 0, 0], &[1u8], &TC_TXID_BYTES, &TC_VOUT_BYTES, &[3u8], &TC_SCRIPT_BYTES, &TC_SEQ_MAX_BYTES, &[1u8], &TC_ONE_SAT_BYTES, &[3u8], &TC_SCRIPT_BYTES, &TC_LOCK_TIME_ZERO_BYTES));
+ check_encode(
+ &tx,
+ &concat_slices!(
+ &[2u8, 0, 0, 0],
+ &[1u8],
+ &TC_TXID_BYTES,
+ &TC_VOUT_BYTES,
+ &[3u8],
+ &TC_SCRIPT_BYTES,
+ &TC_SEQ_MAX_BYTES,
+ &[1u8],
+ &TC_ONE_SAT_BYTES,
+ &[3u8],
+ &TC_SCRIPT_BYTES,
+ &TC_LOCK_TIME_ZERO_BYTES
+ ),
+ );
}
#[test]
@@ -150,29 +194,46 @@ fn encode_block() {
};
let block = Block::new_unchecked(header, vec![tx]);
- check_encode(&block, &concat_slices!(
- // The block version.
- &[2u8, 0, 0, 0],
- // The previous block's blockhash.
- &[
- 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171,
- 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171
- ],
- &[
- 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205,
- 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205
- ],
- // The block time.
- &[80, 195, 137, 98],
- // The target (bits).
- &[239, 190, 0, 0],
- // The nonce.
- &[254, 202, 0, 0],
- // The transaction list length prefix.
- &[1u8],
- // The transaction (same as tested above).
- &[2u8, 0, 0, 0], &TC_SEGWIT_MARKER_AND_FLAG, &[1u8], &TC_TXID_BYTES, &TC_VOUT_BYTES, &[3u8], &TC_SCRIPT_BYTES, &TC_SEQ_MAX_BYTES, &[1u8], &TC_ONE_SAT_BYTES, &[3u8], &TC_SCRIPT_BYTES, &[1u8], &TC_WITNESS_ELEM_LEN_AND_DATA, &TC_LOCK_TIME_ZERO_BYTES
- ));
+ check_encode(
+ &block,
+ &concat_slices!(
+ // The block version.
+ &[2u8, 0, 0, 0],
+ // The previous block's blockhash.
+ &[
+ 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171,
+ 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171
+ ],
+ &[
+ 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205,
+ 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205
+ ],
+ // The block time.
+ &[80, 195, 137, 98],
+ // The target (bits).
+ &[239, 190, 0, 0],
+ // The nonce.
+ &[254, 202, 0, 0],
+ // The transaction list length prefix.
+ &[1u8],
+ // The transaction (same as tested above).
+ &[2u8, 0, 0, 0],
+ &TC_SEGWIT_MARKER_AND_FLAG,
+ &[1u8],
+ &TC_TXID_BYTES,
+ &TC_VOUT_BYTES,
+ &[3u8],
+ &TC_SCRIPT_BYTES,
+ &TC_SEQ_MAX_BYTES,
+ &[1u8],
+ &TC_ONE_SAT_BYTES,
+ &[3u8],
+ &TC_SCRIPT_BYTES,
+ &[1u8],
+ &TC_WITNESS_ELEM_LEN_AND_DATA,
+ &TC_LOCK_TIME_ZERO_BYTES
+ ),
+ );
}
#[test]
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.