witness: Add Witness::witness_script inspector

This commit is contained in:
Steven Roose 2024-03-21 21:48:26 +00:00
parent 6cc6c8621a
commit ac4db6369d
No known key found for this signature in database
GPG Key ID: 2F2A88D7F8D68E87
1 changed files with 9 additions and 0 deletions

View File

@ -450,6 +450,15 @@ impl Witness {
} }
}) })
} }
/// Get the p2wsh witness script following BIP141 rules.
///
/// This does not guarantee that this represents a P2WS [`Witness`]. See
/// [Script::is_p2wsh](crate::blockdata::script::Script::is_p2wsh) to
/// check whether this is actually a P2WSH witness.
pub fn witness_script(&self) -> Option<&Script> {
self.last().map(Script::from_bytes)
}
} }
impl Index<usize> for Witness { impl Index<usize> for Witness {