What changed, and why it matters
This commit is a routine API cleanup, not a security fix. It removes two automatic error-conversion shortcuts (From impls) from a Bitcoin library's witness-version parsing error type and replaces them with explicit error mapping. The behavior of parsing errors remains the same.
No security action needed. Treat as normal refactoring/API-stabilization work.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch removes impl From
Changed components
primitives/src/witness_version.rsFromStrErrorWitnessVersion::from_strInspect captured patch +2 / −11
diff --git a/primitives/src/witness_version.rs b/primitives/src/witness_version.rs
index 960d0547..ee129e59 100644
--- a/primitives/src/witness_version.rs
+++ b/primitives/src/witness_version.rs
@@ -85,8 +85,8 @@ impl FromStr for WitnessVersion {
type Err = FromStrError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
- let version: u8 = parse_int::int_from_str(s)?;
- Ok(Self::try_from(version)?)
+ let version: u8 = parse_int::int_from_str(s).map_err(FromStrError::Unparsable)?;
+ Self::try_from(version).map_err(FromStrError::Invalid)
}
}
@@ -181,15 +181,6 @@ pub mod error {
}
}
}
-
- impl From<ParseIntError> for FromStrError {
- fn from(e: ParseIntError) -> Self { Self::Unparsable(e) }
- }
-
- impl From<TryFromError> for FromStrError {
- fn from(e: TryFromError) -> Self { Self::Invalid(e) }
- }
-
/// Error attempting to create a [`WitnessVersion`] from an integer.
///
/// [`WitnessVersion`]: super::WitnessVersion
Why this scored 19/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.