Skip to content

Commit 3f07ed7

Browse files
committed
Add ChannelTransactionParameters::channel_type_features
1 parent 10eb627 commit 3f07ed7

File tree

4 files changed

+17
-13
lines changed

4 files changed

+17
-13
lines changed

lightning/src/chain/onchaintx.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1272,7 +1272,7 @@ impl<Signer: ChannelSigner> OnchainTxHandler<Signer> {
12721272
}
12731273

12741274
pub(crate) fn channel_type_features(&self) -> &ChannelTypeFeatures {
1275-
&self.channel_transaction_parameters.channel_type_features
1275+
self.channel_transaction_parameters.channel_type_features()
12761276
}
12771277
}
12781278

lightning/src/ln/chan_utils.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -949,6 +949,10 @@ impl ChannelTransactionParameters {
949949
channel_type_features: ChannelTypeFeatures::empty(),
950950
}
951951
}
952+
953+
pub(crate) fn channel_type_features(&self) -> &ChannelTypeFeatures {
954+
&self.channel_type_features
955+
}
952956
}
953957

954958
impl_writeable_tlv_based!(CounterpartyChannelTransactionParameters, {

lightning/src/ln/channel.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3093,8 +3093,8 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
30933093
broadcaster_max_commitment_tx_output.1 = cmp::max(broadcaster_max_commitment_tx_output.1, value_to_remote_msat as u64);
30943094
}
30953095

3096-
let total_fee_sat = commit_tx_fee_sat(feerate_per_kw, included_non_dust_htlcs.len(), &self.channel_transaction_parameters.channel_type_features);
3097-
let anchors_val = if self.channel_transaction_parameters.channel_type_features.supports_anchors_zero_fee_htlc_tx() { ANCHOR_OUTPUT_VALUE_SATOSHI * 2 } else { 0 } as i64;
3096+
let total_fee_sat = commit_tx_fee_sat(feerate_per_kw, included_non_dust_htlcs.len(), self.channel_transaction_parameters.channel_type_features());
3097+
let anchors_val = if self.channel_transaction_parameters.channel_type_features().supports_anchors_zero_fee_htlc_tx() { ANCHOR_OUTPUT_VALUE_SATOSHI * 2 } else { 0 } as i64;
30983098
let (value_to_self, value_to_remote) = if self.is_outbound() {
30993099
(value_to_self_msat / 1000 - anchors_val - total_fee_sat as i64, value_to_remote_msat / 1000)
31003100
} else {
@@ -3948,7 +3948,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
39483948
if self.channel_type.supports_anchors_zero_fee_htlc_tx() {
39493949
self.channel_type.clear_anchors_zero_fee_htlc_tx();
39503950
self.feerate_per_kw = fee_estimator.bounded_sat_per_1000_weight(ConfirmationTarget::NonAnchorChannelFee);
3951-
assert!(!self.channel_transaction_parameters.channel_type_features.supports_anchors_nonzero_fee_htlc_tx());
3951+
assert!(!self.channel_transaction_parameters.channel_type_features().supports_anchors_nonzero_fee_htlc_tx());
39523952
} else if self.channel_type.supports_scid_privacy() {
39533953
self.channel_type.clear_scid_privacy();
39543954
} else {

lightning/src/sign/mod.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ impl HTLCDescriptor {
630630
chan_utils::build_htlc_input(
631631
&self.commitment_txid,
632632
&self.htlc,
633-
&self.channel_derivation_parameters.transaction_parameters.channel_type_features,
633+
self.channel_derivation_parameters.transaction_parameters.channel_type_features(),
634634
)
635635
}
636636

@@ -640,7 +640,7 @@ impl HTLCDescriptor {
640640
chan_utils::build_htlc_output(
641641
self.feerate_per_kw,
642642
&self.htlc,
643-
&self.channel_derivation_parameters.transaction_parameters.channel_type_features,
643+
self.channel_derivation_parameters.transaction_parameters.channel_type_features(),
644644
revokeable_spk,
645645
)
646646
}
@@ -685,7 +685,7 @@ impl HTLCDescriptor {
685685
&self.counterparty_sig,
686686
&self.preimage,
687687
witness_script,
688-
&self.channel_derivation_parameters.transaction_parameters.channel_type_features,
688+
self.channel_derivation_parameters.transaction_parameters.channel_type_features(),
689689
)
690690
}
691691

@@ -917,7 +917,7 @@ pub trait ChannelSigner {
917917
/// Return the total weight of the witness required to spend the justice path of a HTLC output in a
918918
/// commitment transaction.
919919
fn get_htlc_punishment_witness_weight(&self, offered: bool) -> u64 {
920-
let features = &self.get_channel_parameters().unwrap().channel_type_features;
920+
let features = self.get_channel_parameters().unwrap().channel_type_features();
921921
if offered {
922922
weight_revoked_offered_htlc(features)
923923
} else {
@@ -935,7 +935,7 @@ pub trait ChannelSigner {
935935

936936
/// Weight of the witness that sweeps htlc outputs in counterparty commitment transactions
937937
fn counterparty_htlc_output_witness_weight(&self, offered: bool) -> u64 {
938-
let features = &self.get_channel_parameters().unwrap().channel_type_features;
938+
let features = self.get_channel_parameters().unwrap().channel_type_features();
939939
if offered {
940940
weight_offered_htlc(features)
941941
} else {
@@ -1027,7 +1027,7 @@ pub trait ChannelSigner {
10271027
/// Get the anchor output of a commit tx
10281028
fn get_anchor_txout(&self, is_holder_tx: bool, is_broadcaster_anchor: bool) -> Option<TxOut> {
10291029
let channel_parameters = self.get_channel_parameters().unwrap();
1030-
if channel_parameters.channel_type_features.supports_anchors_zero_fee_htlc_tx() {
1030+
if channel_parameters.channel_type_features().supports_anchors_zero_fee_htlc_tx() {
10311031
let params = if is_holder_tx {
10321032
channel_parameters.as_holder_broadcastable()
10331033
} else {
@@ -1432,7 +1432,7 @@ impl InMemorySigner {
14321432
/// Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called.
14331433
/// In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation.
14341434
pub fn channel_type_features(&self) -> Option<&ChannelTypeFeatures> {
1435-
self.get_channel_parameters().map(|params| &params.channel_type_features)
1435+
self.get_channel_parameters().map(|params| params.channel_type_features())
14361436
}
14371437

14381438
/// Sign the single input of `spend_tx` at index `input_idx`, which spends the output described
@@ -1797,7 +1797,7 @@ impl ChannelSigner for InMemorySigner {
17971797
let sighash = hash_to_message!(sighash.as_byte_array());
17981798
let sig = sign_with_aux_rand(&secp_ctx, &sighash, &our_htlc_private_key, &self);
17991799

1800-
let features = &self.channel_parameters.as_ref().unwrap().channel_type_features;
1800+
let features = self.channel_parameters.as_ref().unwrap().channel_type_features();
18011801
Ok(chan_utils::build_htlc_input_witness(
18021802
&sig,
18031803
&htlc_descriptor.counterparty_sig,
@@ -1852,7 +1852,7 @@ impl EcdsaChannelSigner for InMemorySigner {
18521852
);
18531853
for htlc in commitment_tx.htlcs() {
18541854
let channel_parameters = self.get_channel_parameters().expect(MISSING_PARAMS_ERR);
1855-
let chan_type = &channel_parameters.channel_type_features;
1855+
let chan_type = channel_parameters.channel_type_features();
18561856
let htlc_tx = chan_utils::build_htlc_transaction(
18571857
&commitment_txid,
18581858
commitment_tx.feerate_per_kw(),

0 commit comments

Comments
 (0)