diff --git a/bitcoin/src/address/mod.rs b/bitcoin/src/address/mod.rs index 89658144b..c2cdb9ccd 100644 --- a/bitcoin/src/address/mod.rs +++ b/bitcoin/src/address/mod.rs @@ -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 { + 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. ///