Enable getting the witness program from an address

We have getters for the pubkey hash and script hash but we forgot one
for the witness program - add it.
This commit is contained in:
Tobin C. Harding 2024-05-23 13:02:12 +10:00
parent d0c1eb138c
commit 4f29adf163
No known key found for this signature in database
GPG Key ID: 40BF9E4C269D6607
1 changed files with 10 additions and 0 deletions

View File

@ -490,6 +490,16 @@ impl Address {
}
}
/// Gets the witness program for this address if this is a segwit address.
pub fn witness_program(&self) -> Option<WitnessProgram> {
use AddressInner::*;
match self.0 {
Segwit { ref program, hrp: _ } => Some(*program),
_ => None,
}
}
/// Checks whether or not the address is following Bitcoin standardness rules when
/// *spending* from this address. *NOT* to be called by senders.
///