Merge rust-bitcoin/rust-bitcoin#876: Make Script::witness_version public

7554d76dfe Make Script::witness_version public (Dr Maxim Orlovsky)

Pull request description:

  Originally this function was public (at least I was using it in downstream dependency in https://github.com/LNP-BP/descriptor-wallet). Now, in RC1, it became private. It is quite useful to detect witness scriptPubkeys.

ACKs for top commit:
  apoelstra:
    ACK 7554d76dfe
  sanket1729:
    utACK 7554d76dfe. I also found needing this rust-miniscript and had to some work-around.

Tree-SHA512: 27ae8fbbb5f19d7b3553fb05f193488c4096aa0e4949a5cdd96b9fda89f1983e45855598c4507131848e0ff2086a5b91b2201e9aed3ed8fcb66034a36715a434
This commit is contained in:
sanket1729 2022-03-13 11:33:50 -07:00
commit efa9555ebd
No known key found for this signature in database
GPG Key ID: 648FFB183E0870A2
1 changed files with 2 additions and 1 deletions

View File

@ -410,8 +410,9 @@ impl Script {
Script::new_v1_p2tr(&secp, internal_key, Some(merkle_root)) Script::new_v1_p2tr(&secp, internal_key, Some(merkle_root))
} }
/// Returns witness version of the script, if any, assuming the script is a `scriptPubkey`.
#[inline] #[inline]
fn witness_version(&self) -> Option<WitnessVersion> { pub fn witness_version(&self) -> Option<WitnessVersion> {
self.0.get(0).and_then(|opcode| WitnessVersion::from_opcode(opcodes::All::from(*opcode)).ok()) self.0.get(0).and_then(|opcode| WitnessVersion::from_opcode(opcodes::All::from(*opcode)).ok())
} }