Skip to content

Commit 163ad99

Browse files
committed
Expose witness_script for StaticPaymentOutputDescriptor
1 parent 58a84c6 commit 163ad99

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

lightning/src/sign/mod.rs

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

0 commit comments

Comments
 (0)