Skip to content

Commit 9113ea3

Browse files
committed
Expose witness_script for StaticPaymentOutputDescriptor
1 parent f191fa3 commit 9113ea3

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

lightning/src/sign/mod.rs

+17
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,23 @@ pub struct StaticPaymentOutputDescriptor {
133133
pub channel_transaction_parameters: Option<ChannelTransactionParameters>,
134134
}
135135
impl StaticPaymentOutputDescriptor {
136+
/// Returns the `witness_script` of the spendable output.
137+
///
138+
/// Note that this will only return some for [`StaticPaymentOutputDescriptor`]s that originated
139+
/// from an anchor outputs channel, as they take the form of a P2WSH script.
140+
pub fn witness_script(&self) -> Option<Script> {
141+
self.channel_transaction_parameters.as_ref()
142+
.map(|channel_params|
143+
if channel_params.channel_type_features.supports_anchors_zero_fee_htlc_tx() {
144+
let payment_point = channel_params.as_holder_broadcastable().broadcaster_pubkeys().payment_point;
145+
Some(chan_utils::get_to_countersignatory_with_anchors_redeemscript(&payment_point))
146+
} else {
147+
None
148+
}
149+
)
150+
.flatten()
151+
}
152+
136153
/// The maximum length a well-formed witness spending one of these should have.
137154
/// Note: If you have the grind_signatures feature enabled, this will be at least 1 byte
138155
/// shorter.

0 commit comments

Comments
 (0)