Skip to content

Commit 947a051

Browse files
committed
Drop ChannelTransactionParameters::supports_anchors
...as it is ambiguous now that we have multiple types of anchors. Its clearer to check the specific features at the callsites now.
1 parent 8b34ea2 commit 947a051

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

lightning/src/ln/chan_utils.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -934,11 +934,6 @@ impl ChannelTransactionParameters {
934934
self.counterparty_parameters.is_some() && self.funding_outpoint.is_some()
935935
}
936936

937-
/// Whether the channel supports zero-fee HTLC transaction anchors.
938-
pub(crate) fn supports_anchors(&self) -> bool {
939-
self.channel_type_features.supports_anchors_zero_fee_htlc_tx()
940-
}
941-
942937
/// Convert the holder/counterparty parameters to broadcaster/countersignatory-organized parameters,
943938
/// given that the holder is the broadcaster.
944939
///

lightning/src/sign/mod.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ impl StaticPaymentOutputDescriptor {
164164
/// originated from an anchor outputs channel, as they take the form of a P2WSH script.
165165
pub fn witness_script(&self) -> Option<ScriptBuf> {
166166
self.channel_transaction_parameters.as_ref().and_then(|channel_params| {
167-
if channel_params.supports_anchors() {
167+
if channel_params.channel_type_features.supports_anchors_zero_fee_htlc_tx() {
168168
let payment_point = channel_params.holder_pubkeys.payment_point;
169169
Some(chan_utils::get_to_countersignatory_with_anchors_redeemscript(&payment_point))
170170
} else {
@@ -177,7 +177,7 @@ impl StaticPaymentOutputDescriptor {
177177
/// Note: If you have the grind_signatures feature enabled, this will be at least 1 byte
178178
/// shorter.
179179
pub fn max_witness_length(&self) -> u64 {
180-
if self.channel_transaction_parameters.as_ref().map_or(false, |p| p.supports_anchors()) {
180+
if self.needs_csv_1_for_spend() {
181181
let witness_script_weight = 1 /* pubkey push */ + 33 /* pubkey */ +
182182
1 /* OP_CHECKSIGVERIFY */ + 1 /* OP_1 */ + 1 /* OP_CHECKSEQUENCEVERIFY */;
183183
1 /* num witness items */ + 1 /* sig push */ + 73 /* sig including sighash flag */ +
@@ -186,6 +186,13 @@ impl StaticPaymentOutputDescriptor {
186186
P2WPKH_WITNESS_WEIGHT
187187
}
188188
}
189+
190+
/// Returns true if spending this output requires a transaction with a CheckSequenceVerify
191+
/// value of at least 1.
192+
pub fn needs_csv_1_for_spend(&self) -> bool {
193+
let chan_params = self.channel_transaction_parameters.as_ref();
194+
chan_params.map_or(false, |p| p.channel_type_features.supports_anchors_zero_fee_htlc_tx())
195+
}
189196
}
190197
impl_writeable_tlv_based!(StaticPaymentOutputDescriptor, {
191198
(0, outpoint, required),
@@ -440,11 +447,7 @@ impl SpendableOutputDescriptor {
440447
if !output_set.insert(descriptor.outpoint) {
441448
return Err(());
442449
}
443-
let sequence = if descriptor
444-
.channel_transaction_parameters
445-
.as_ref()
446-
.map_or(false, |p| p.supports_anchors())
447-
{
450+
let sequence = if descriptor.needs_csv_1_for_spend() {
448451
Sequence::from_consensus(1)
449452
} else {
450453
Sequence::ZERO

0 commit comments

Comments
 (0)