Skip to content

Commit 6e6fc14

Browse files
committed
Merge rust-bitcoin#2804: Enable getting the witness program from an address
e384f67 Enable getting the witness program from an address (Tobin C. Harding) Pull request description: We have getters for the pubkey hash and script hash but we forgot one for the witness program - add it. This is a backport of rust-bitcoin#2796 without the update to api files which don't exist yet on this release branch. ACKs for top commit: apoelstra: ACK e384f67 Tree-SHA512: a11cd7cbfcc3b5606651a04395779834a3d70c00c69aef7451f2e8c0321832effe0f1b0ed45e6b132fb9ba7312dcabefa8eb7603f5ab5c66c985a4b01e5c6e1e
2 parents a3f7667 + e384f67 commit 6e6fc14

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

bitcoin/src/address/mod.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,16 @@ impl Address {
490490
}
491491
}
492492

493+
/// Gets the witness program for this address if this is a segwit address.
494+
pub fn witness_program(&self) -> Option<WitnessProgram> {
495+
use AddressInner::*;
496+
497+
match self.0 {
498+
Segwit { ref program, hrp: _ } => Some(*program),
499+
_ => None,
500+
}
501+
}
502+
493503
/// Checks whether or not the address is following Bitcoin standardness rules when
494504
/// *spending* from this address. *NOT* to be called by senders.
495505
///

0 commit comments

Comments
 (0)