@@ -1600,7 +1600,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
1600
1600
debug_assert ! ( htlc_input_idx_opt. is_some( ) ) ;
1601
1601
BitcoinOutPoint :: new ( * txid, htlc_input_idx_opt. unwrap_or ( 0 ) )
1602
1602
} else {
1603
- debug_assert ! ( !self . onchain_tx_handler. opt_anchors ( ) ) ;
1603
+ debug_assert ! ( !self . onchain_tx_handler. channel_type_features ( ) . supports_anchors ( ) ) ;
1604
1604
BitcoinOutPoint :: new ( * txid, 0 )
1605
1605
}
1606
1606
} else {
@@ -2459,10 +2459,10 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
2459
2459
// If the channel supports anchor outputs, we'll need to emit an external
2460
2460
// event to be consumed such that a child transaction is broadcast with a
2461
2461
// high enough feerate for the parent commitment transaction to confirm.
2462
- if self . onchain_tx_handler . opt_anchors ( ) {
2462
+ if self . onchain_tx_handler . channel_type_features ( ) . supports_anchors ( ) {
2463
2463
let funding_output = HolderFundingOutput :: build (
2464
2464
self . funding_redeemscript . clone ( ) , self . channel_value_satoshis ,
2465
- self . onchain_tx_handler . opt_anchors ( ) ,
2465
+ self . onchain_tx_handler . channel_type_features ( ) ,
2466
2466
) ;
2467
2467
let best_block_height = self . best_block . height ( ) ;
2468
2468
let commitment_package = PackageTemplate :: build_package (
@@ -2651,7 +2651,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
2651
2651
// First, process non-htlc outputs (to_holder & to_counterparty)
2652
2652
for ( idx, outp) in tx. output . iter ( ) . enumerate ( ) {
2653
2653
if outp. script_pubkey == revokeable_p2wsh {
2654
- let revk_outp = RevokedOutput :: build ( per_commitment_point, self . counterparty_commitment_params . counterparty_delayed_payment_base_key , self . counterparty_commitment_params . counterparty_htlc_base_key , per_commitment_key, outp. value , self . counterparty_commitment_params . on_counterparty_tx_csv , self . onchain_tx_handler . opt_anchors ( ) ) ;
2654
+ let revk_outp = RevokedOutput :: build ( per_commitment_point, self . counterparty_commitment_params . counterparty_delayed_payment_base_key , self . counterparty_commitment_params . counterparty_htlc_base_key , per_commitment_key, outp. value , self . counterparty_commitment_params . on_counterparty_tx_csv , self . onchain_tx_handler . channel_type_features ( ) . supports_anchors ( ) ) ;
2655
2655
let justice_package = PackageTemplate :: build_package ( commitment_txid, idx as u32 , PackageSolvingData :: RevokedOutput ( revk_outp) , height + self . counterparty_commitment_params . on_counterparty_tx_csv as u32 , height) ;
2656
2656
claimable_outpoints. push ( justice_package) ;
2657
2657
to_counterparty_output_info =
@@ -2669,7 +2669,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
2669
2669
return ( claimable_outpoints, ( commitment_txid, watch_outputs) ,
2670
2670
to_counterparty_output_info) ;
2671
2671
}
2672
- let revk_htlc_outp = RevokedHTLCOutput :: build ( per_commitment_point, self . counterparty_commitment_params . counterparty_delayed_payment_base_key , self . counterparty_commitment_params . counterparty_htlc_base_key , per_commitment_key, htlc. amount_msat / 1000 , htlc. clone ( ) , self . onchain_tx_handler . channel_transaction_parameters . opt_anchors . is_some ( ) ) ;
2672
+ let revk_htlc_outp = RevokedHTLCOutput :: build ( per_commitment_point, self . counterparty_commitment_params . counterparty_delayed_payment_base_key , self . counterparty_commitment_params . counterparty_htlc_base_key , per_commitment_key, htlc. amount_msat / 1000 , htlc. clone ( ) , & self . onchain_tx_handler . channel_transaction_parameters . channel_type_features ) ;
2673
2673
let justice_package = PackageTemplate :: build_package ( commitment_txid, transaction_output_index, PackageSolvingData :: RevokedHTLCOutput ( revk_htlc_outp) , htlc. cltv_expiry , height) ;
2674
2674
claimable_outpoints. push ( justice_package) ;
2675
2675
}
@@ -2787,13 +2787,13 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
2787
2787
CounterpartyOfferedHTLCOutput :: build ( * per_commitment_point,
2788
2788
self . counterparty_commitment_params . counterparty_delayed_payment_base_key ,
2789
2789
self . counterparty_commitment_params . counterparty_htlc_base_key ,
2790
- preimage. unwrap ( ) , htlc. clone ( ) , self . onchain_tx_handler . opt_anchors ( ) ) )
2790
+ preimage. unwrap ( ) , htlc. clone ( ) , self . onchain_tx_handler . channel_type_features ( ) ) )
2791
2791
} else {
2792
2792
PackageSolvingData :: CounterpartyReceivedHTLCOutput (
2793
2793
CounterpartyReceivedHTLCOutput :: build ( * per_commitment_point,
2794
2794
self . counterparty_commitment_params . counterparty_delayed_payment_base_key ,
2795
2795
self . counterparty_commitment_params . counterparty_htlc_base_key ,
2796
- htlc. clone ( ) , self . onchain_tx_handler . opt_anchors ( ) ) )
2796
+ htlc. clone ( ) , self . onchain_tx_handler . channel_type_features ( ) ) )
2797
2797
} ;
2798
2798
let counterparty_package = PackageTemplate :: build_package ( commitment_txid, transaction_output_index, counterparty_htlc_outp, htlc. cltv_expiry , 0 ) ;
2799
2799
claimable_outpoints. push ( counterparty_package) ;
@@ -2864,7 +2864,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
2864
2864
if let Some ( transaction_output_index) = htlc. transaction_output_index {
2865
2865
let htlc_output = if htlc. offered {
2866
2866
let htlc_output = HolderHTLCOutput :: build_offered (
2867
- htlc. amount_msat , htlc. cltv_expiry , self . onchain_tx_handler . opt_anchors ( )
2867
+ htlc. amount_msat , htlc. cltv_expiry , self . onchain_tx_handler . channel_type_features ( )
2868
2868
) ;
2869
2869
htlc_output
2870
2870
} else {
@@ -2875,7 +2875,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
2875
2875
continue ;
2876
2876
} ;
2877
2877
let htlc_output = HolderHTLCOutput :: build_accepted (
2878
- payment_preimage, htlc. amount_msat , self . onchain_tx_handler . opt_anchors ( )
2878
+ payment_preimage, htlc. amount_msat , self . onchain_tx_handler . channel_type_features ( )
2879
2879
) ;
2880
2880
htlc_output
2881
2881
} ;
@@ -2959,7 +2959,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
2959
2959
let mut holder_transactions = vec ! [ commitment_tx] ;
2960
2960
// When anchor outputs are present, the HTLC transactions are only valid once the commitment
2961
2961
// transaction confirms.
2962
- if self . onchain_tx_handler . opt_anchors ( ) {
2962
+ if self . onchain_tx_handler . channel_type_features ( ) . supports_anchors ( ) {
2963
2963
return holder_transactions;
2964
2964
}
2965
2965
for htlc in self . current_holder_commitment_tx . htlc_outputs . iter ( ) {
@@ -2997,7 +2997,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
2997
2997
let mut holder_transactions = vec ! [ commitment_tx] ;
2998
2998
// When anchor outputs are present, the HTLC transactions are only final once the commitment
2999
2999
// transaction confirms due to the CSV 1 encumberance.
3000
- if self . onchain_tx_handler . opt_anchors ( ) {
3000
+ if self . onchain_tx_handler . channel_type_features ( ) . supports_anchors ( ) {
3001
3001
return holder_transactions;
3002
3002
}
3003
3003
for htlc in self . current_holder_commitment_tx . htlc_outputs . iter ( ) {
@@ -3221,7 +3221,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
3221
3221
3222
3222
let should_broadcast = self . should_broadcast_holder_commitment_txn ( logger) ;
3223
3223
if should_broadcast {
3224
- let funding_outp = HolderFundingOutput :: build ( self . funding_redeemscript . clone ( ) , self . channel_value_satoshis , self . onchain_tx_handler . opt_anchors ( ) ) ;
3224
+ let funding_outp = HolderFundingOutput :: build ( self . funding_redeemscript . clone ( ) , self . channel_value_satoshis , self . onchain_tx_handler . channel_type_features ( ) ) ;
3225
3225
let commitment_package = PackageTemplate :: build_package ( self . funding_info . 0 . txid . clone ( ) , self . funding_info . 0 . index as u32 , PackageSolvingData :: HolderFundingOutput ( funding_outp) , self . best_block . height ( ) , self . best_block . height ( ) ) ;
3226
3226
claimable_outpoints. push ( commitment_package) ;
3227
3227
self . pending_monitor_events . push ( MonitorEvent :: CommitmentTxConfirmed ( self . funding_info . 0 ) ) ;
@@ -3230,7 +3230,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
3230
3230
// We can't broadcast our HTLC transactions while the commitment transaction is
3231
3231
// unconfirmed. We'll delay doing so until we detect the confirmed commitment in
3232
3232
// `transactions_confirmed`.
3233
- if !self . onchain_tx_handler . opt_anchors ( ) {
3233
+ if !self . onchain_tx_handler . channel_type_features ( ) . supports_anchors ( ) {
3234
3234
// Because we're broadcasting a commitment transaction, we should construct the package
3235
3235
// assuming it gets confirmed in the next block. Sadly, we have code which considers
3236
3236
// "not yet confirmed" things as discardable, so we cannot do that here.
@@ -4158,6 +4158,7 @@ mod tests {
4158
4158
use crate :: sync:: { Arc , Mutex } ;
4159
4159
use crate :: io;
4160
4160
use bitcoin:: { PackedLockTime , Sequence , Witness } ;
4161
+ use crate :: ln:: features:: ChannelTypeFeatures ;
4161
4162
use crate :: prelude:: * ;
4162
4163
4163
4164
fn do_test_funding_spend_refuses_updates ( use_local_txn : bool ) {
@@ -4331,8 +4332,7 @@ mod tests {
4331
4332
selected_contest_delay : 67 ,
4332
4333
} ) ,
4333
4334
funding_outpoint : Some ( funding_outpoint) ,
4334
- opt_anchors : None ,
4335
- opt_non_zero_fee_anchors : None ,
4335
+ channel_type_features : ChannelTypeFeatures :: only_static_remote_key ( )
4336
4336
} ;
4337
4337
// Prune with one old state and a holder commitment tx holding a few overlaps with the
4338
4338
// old state.
@@ -4448,7 +4448,7 @@ mod tests {
4448
4448
let txid = Txid :: from_hex ( "56944c5d3f98413ef45cf54545538103cc9f298e0575820ad3591376e2e0f65d" ) . unwrap ( ) ;
4449
4449
4450
4450
// Justice tx with 1 to_holder, 2 revoked offered HTLCs, 1 revoked received HTLCs
4451
- for & opt_anchors in [ false , true ] . iter ( ) {
4451
+ for channel_type_features in [ ChannelTypeFeatures :: only_static_remote_key ( ) , ChannelTypeFeatures :: static_remote_key_with_anchors ( ) ] . iter ( ) {
4452
4452
let mut claim_tx = Transaction { version : 0 , lock_time : PackedLockTime :: ZERO , input : Vec :: new ( ) , output : Vec :: new ( ) } ;
4453
4453
let mut sum_actual_sigs = 0 ;
4454
4454
for i in 0 ..4 {
@@ -4467,20 +4467,20 @@ mod tests {
4467
4467
value : 0 ,
4468
4468
} ) ;
4469
4469
let base_weight = claim_tx. weight ( ) ;
4470
- let inputs_weight = vec ! [ WEIGHT_REVOKED_OUTPUT , weight_revoked_offered_htlc( opt_anchors ) , weight_revoked_offered_htlc( opt_anchors ) , weight_revoked_received_htlc( opt_anchors ) ] ;
4470
+ let inputs_weight = vec ! [ WEIGHT_REVOKED_OUTPUT , weight_revoked_offered_htlc( channel_type_features ) , weight_revoked_offered_htlc( channel_type_features ) , weight_revoked_received_htlc( channel_type_features ) ] ;
4471
4471
let mut inputs_total_weight = 2 ; // count segwit flags
4472
4472
{
4473
4473
let mut sighash_parts = sighash:: SighashCache :: new ( & mut claim_tx) ;
4474
4474
for ( idx, inp) in inputs_weight. iter ( ) . enumerate ( ) {
4475
- sign_input ! ( sighash_parts, idx, 0 , inp, sum_actual_sigs, opt_anchors ) ;
4475
+ sign_input ! ( sighash_parts, idx, 0 , inp, sum_actual_sigs, channel_type_features ) ;
4476
4476
inputs_total_weight += inp;
4477
4477
}
4478
4478
}
4479
4479
assert_eq ! ( base_weight + inputs_total_weight as usize , claim_tx. weight( ) + /* max_length_sig */ ( 73 * inputs_weight. len( ) - sum_actual_sigs) ) ;
4480
4480
}
4481
4481
4482
4482
// Claim tx with 1 offered HTLCs, 3 received HTLCs
4483
- for & opt_anchors in [ false , true ] . iter ( ) {
4483
+ for channel_type_features in [ ChannelTypeFeatures :: only_static_remote_key ( ) , ChannelTypeFeatures :: static_remote_key_with_anchors ( ) ] . iter ( ) {
4484
4484
let mut claim_tx = Transaction { version : 0 , lock_time : PackedLockTime :: ZERO , input : Vec :: new ( ) , output : Vec :: new ( ) } ;
4485
4485
let mut sum_actual_sigs = 0 ;
4486
4486
for i in 0 ..4 {
@@ -4499,20 +4499,20 @@ mod tests {
4499
4499
value : 0 ,
4500
4500
} ) ;
4501
4501
let base_weight = claim_tx. weight ( ) ;
4502
- let inputs_weight = vec ! [ weight_offered_htlc( opt_anchors ) , weight_received_htlc( opt_anchors ) , weight_received_htlc( opt_anchors ) , weight_received_htlc( opt_anchors ) ] ;
4502
+ let inputs_weight = vec ! [ weight_offered_htlc( channel_type_features ) , weight_received_htlc( channel_type_features ) , weight_received_htlc( channel_type_features ) , weight_received_htlc( channel_type_features ) ] ;
4503
4503
let mut inputs_total_weight = 2 ; // count segwit flags
4504
4504
{
4505
4505
let mut sighash_parts = sighash:: SighashCache :: new ( & mut claim_tx) ;
4506
4506
for ( idx, inp) in inputs_weight. iter ( ) . enumerate ( ) {
4507
- sign_input ! ( sighash_parts, idx, 0 , inp, sum_actual_sigs, opt_anchors ) ;
4507
+ sign_input ! ( sighash_parts, idx, 0 , inp, sum_actual_sigs, channel_type_features ) ;
4508
4508
inputs_total_weight += inp;
4509
4509
}
4510
4510
}
4511
4511
assert_eq ! ( base_weight + inputs_total_weight as usize , claim_tx. weight( ) + /* max_length_sig */ ( 73 * inputs_weight. len( ) - sum_actual_sigs) ) ;
4512
4512
}
4513
4513
4514
4514
// Justice tx with 1 revoked HTLC-Success tx output
4515
- for & opt_anchors in [ false , true ] . iter ( ) {
4515
+ for opt_anchors in [ ChannelTypeFeatures :: only_static_remote_key ( ) , ChannelTypeFeatures :: static_remote_key_with_anchors ( ) ] . iter ( ) {
4516
4516
let mut claim_tx = Transaction { version : 0 , lock_time : PackedLockTime :: ZERO , input : Vec :: new ( ) , output : Vec :: new ( ) } ;
4517
4517
let mut sum_actual_sigs = 0 ;
4518
4518
claim_tx. input . push ( TxIn {
0 commit comments