Skip to content

Commit

Permalink
Delete StaticPaymentOutputDescriptor::witness_script
Browse files Browse the repository at this point in the history
  • Loading branch information
tankyleo committed Jan 16, 2025
1 parent 5ef0795 commit 8a20905
Showing 1 changed file with 15 additions and 20 deletions.
35 changes: 15 additions & 20 deletions lightning/src/sign/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,22 +165,6 @@ pub struct StaticPaymentOutputDescriptor {
pub witness_weight: u64,
}

impl StaticPaymentOutputDescriptor {
/// Returns the `witness_script` of the spendable output.
///
/// Note that this will only return `Some` for [`StaticPaymentOutputDescriptor`]s that
/// originated from an anchor outputs channel, as they take the form of a P2WSH script.
pub fn witness_script(&self) -> Option<ScriptBuf> {
self.channel_transaction_parameters.as_ref().and_then(|channel_params| {
if channel_params.supports_anchors() {
let payment_point = channel_params.holder_pubkeys.payment_point;
Some(chan_utils::get_to_countersignatory_with_anchors_redeemscript(&payment_point))
} else {
None
}
})
}
}
impl_writeable_tlv_based!(StaticPaymentOutputDescriptor, {
(0, outpoint, required),
(2, output, required),
Expand Down Expand Up @@ -405,10 +389,21 @@ impl SpendableOutputDescriptor {
..Default::default()
}
},
SpendableOutputDescriptor::StaticPaymentOutput(descriptor) => bitcoin::psbt::Input {
witness_utxo: Some(descriptor.output.clone()),
witness_script: descriptor.witness_script(),
..Default::default()
SpendableOutputDescriptor::StaticPaymentOutput(descriptor) => {
let witness_script =
descriptor.channel_transaction_parameters.as_ref().and_then(|channel_params| {
channel_params.supports_anchors().then(|| {
let payment_point = channel_params.holder_pubkeys.payment_point;
chan_utils::get_to_countersignatory_with_anchors_redeemscript(
&payment_point,
)
})
});
bitcoin::psbt::Input {
witness_utxo: Some(descriptor.output.clone()),
witness_script,
..Default::default()
}
},
}
}
Expand Down

0 comments on commit 8a20905

Please sign in to comment.