What changed, and why it matters
This commit only adds documentation comments and a single Clippy lint suppression to fix code-style warnings. It does not change any program logic, data validation, or behavior, so it has no security impact.
No security action needed; treat as routine documentation/lint cleanup.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff adds # Errors documentation to two constructors (WitnessProgram::new and WitnessProgram::p2wsh) and an #[allow(clippy::missing_panics_doc)] attribute on WitnessProgram::program. No executable code, bounds checks, error handling, or cryptographic operations are modified.
Changed components
addresses/src/witness_program.rsInspect captured patch +12 / −0
diff --git a/addresses/src/witness_program.rs b/addresses/src/witness_program.rs
index a299c305..651791ac 100644
--- a/addresses/src/witness_program.rs
+++ b/addresses/src/witness_program.rs
@@ -41,6 +41,13 @@ pub struct WitnessProgram {
impl WitnessProgram {
/// Constructs a new witness program, copying the content from the given byte slice.
+ ///
+ /// # Errors
+ ///
+ /// - [`Error::InvalidLength`] if the given bytes are shorter than [`MIN_SIZE`], or
+ /// longer than [`MAX_SIZE`].
+ /// - [`Error::InvalidSegwitV0Length`] if the given version is [`WitnessVersion::V0`] and
+ /// bytes is not 20 or 32 bytes long.
pub fn new(version: WitnessVersion, bytes: &[u8]) -> Result<Self, Error> {
let program_len = bytes.len();
if program_len < MIN_SIZE || program_len > MAX_SIZE {
@@ -78,6 +85,10 @@ impl WitnessProgram {
}
/// Constructs a new [`WitnessProgram`] from `script` for a P2WSH output.
+ ///
+ /// # Errors
+ ///
+ /// Returns an error if the script exceeds 10,000 bytes.
pub fn p2wsh(script: &WitnessScript) -> Result<Self, WitnessScriptSizeError> {
WScriptHash::from_script(script).map(Self::p2wsh_from_hash)
}
@@ -114,6 +125,7 @@ impl WitnessProgram {
pub fn version(&self) -> WitnessVersion { self.version }
/// Returns the witness program.
+ #[allow(clippy::missing_panics_doc)] // expect panic is unreachable by witness program limit
pub fn program(&self) -> &PushBytes {
self.program
.as_slice()
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.