From 552f19abe3c3b97894b4160976fa2b844046c5d2 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Thu, 13 Jul 2023 09:53:33 +1000 Subject: [PATCH] Add more rustdocs to WitnessProgram Add rustdocs to `WitnessProgram` commenting on why we carry the witness version number around with the witness program. This is mainly a dev comment but it helps document the invariants so make it a rustdoc comment. --- bitcoin/src/blockdata/script/witness_program.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bitcoin/src/blockdata/script/witness_program.rs b/bitcoin/src/blockdata/script/witness_program.rs index aa95c730..446e44c5 100644 --- a/bitcoin/src/blockdata/script/witness_program.rs +++ b/bitcoin/src/blockdata/script/witness_program.rs @@ -14,9 +14,13 @@ use crate::blockdata::script::witness_version::WitnessVersion; use crate::blockdata::script::{PushBytes, PushBytesBuf, PushBytesErrorReport}; /// The segregated witness program. +/// +/// The segregated witness program is technically only the program bytes _excluding_ the witness +/// version, however we maintain length invariants on the `program` that are governed by the version +/// number, therefore we carry the version number around along with the program bytes. #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct WitnessProgram { - /// The witness program version number. + /// The segwit version associated with this witness program. version: WitnessVersion, /// The witness program (between 2 and 40 bytes). program: PushBytesBuf,