What changed, and why it matters
This is a small internal code cleanup in the rust-bitcoin library. It changes how an error message about checksum mismatches is formatted, removing a dependency on a feature-flagged helper so the error type can be moved later. The visible output of the error message is unchanged. There is no security issue here.
No security action needed. This is a refactoring/cleanup change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit replaces a DisplayHex-based formatting of the InvalidChecksum error’s expected/actual 4-byte checksum arrays with manual {:02x} formatting of each byte. This removes a use of the hex crate’s DisplayHex trait from the Display implementation of ParseError, because hex is an optional feature and the error type is planned to move to consensus_encoding. The formatting output is asserted to be identical to the prior implementation.
Changed components
bitcoin/src/consensus/error.rsInspect captured patch +5 / −3
diff --git a/bitcoin/src/consensus/error.rs b/bitcoin/src/consensus/error.rs
index 16f6330f..2c394a6d 100644
--- a/bitcoin/src/consensus/error.rs
+++ b/bitcoin/src/consensus/error.rs
@@ -6,7 +6,6 @@ use core::convert::Infallible;
use core::fmt;
use hex::error::{InvalidCharError, OddLengthStringError};
-use hex::DisplayHex as _;
use internals::write_err;
#[cfg(doc)]
@@ -188,8 +187,11 @@ impl fmt::Display for ParseError {
MissingData => write!(f, "missing data (early end of file or slice too short)"),
OversizedVectorAllocation { requested: ref r, max: ref m } =>
write!(f, "allocation of oversized vector: requested {}, maximum {}", r, m),
- InvalidChecksum { expected: ref e, actual: ref a } =>
- write!(f, "invalid checksum: expected {:x}, actual {:x}", e.as_hex(), a.as_hex()),
+ InvalidChecksum { expected: ref e, actual: ref a } => write!(
+ f,
+ "invalid checksum: expected {:02x}{:02x}{:02x}{:02x}, actual {:02x}{:02x}{:02x}{:02x}",
+ e[0], e[1], e[2], e[3], a[0], a[1], a[2], a[3],
+ ),
NonMinimalCompactSize => write!(f, "non-minimal compact size"),
ParseFailed(ref s) => write!(f, "parse failed: {}", s),
UnsupportedSegwitFlag(ref swflag) =>
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.