@@ -1600,7 +1600,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
16001600 debug_assert ! ( htlc_input_idx_opt. is_some( ) ) ;
16011601 BitcoinOutPoint :: new ( * txid, htlc_input_idx_opt. unwrap_or ( 0 ) )
16021602 } else {
1603- debug_assert ! ( !self . onchain_tx_handler. opt_anchors ( ) ) ;
1603+ debug_assert ! ( !self . onchain_tx_handler. channel_type_features ( ) . supports_anchors ( ) ) ;
16041604 BitcoinOutPoint :: new ( * txid, 0 )
16051605 }
16061606 } else {
@@ -2459,10 +2459,10 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
24592459 // If the channel supports anchor outputs, we'll need to emit an external
24602460 // event to be consumed such that a child transaction is broadcast with a
24612461 // 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 ( ) {
24632463 let funding_output = HolderFundingOutput :: build (
24642464 self . funding_redeemscript . clone ( ) , self . channel_value_satoshis ,
2465- self . onchain_tx_handler . opt_anchors ( ) ,
2465+ self . onchain_tx_handler . channel_type_features ( ) ,
24662466 ) ;
24672467 let best_block_height = self . best_block . height ( ) ;
24682468 let commitment_package = PackageTemplate :: build_package (
@@ -2651,7 +2651,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
26512651 // First, process non-htlc outputs (to_holder & to_counterparty)
26522652 for ( idx, outp) in tx. output . iter ( ) . enumerate ( ) {
26532653 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 ( ) ) ;
26552655 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) ;
26562656 claimable_outpoints. push ( justice_package) ;
26572657 to_counterparty_output_info =
@@ -2669,7 +2669,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
26692669 return ( claimable_outpoints, ( commitment_txid, watch_outputs) ,
26702670 to_counterparty_output_info) ;
26712671 }
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 ) ;
26732673 let justice_package = PackageTemplate :: build_package ( commitment_txid, transaction_output_index, PackageSolvingData :: RevokedHTLCOutput ( revk_htlc_outp) , htlc. cltv_expiry , height) ;
26742674 claimable_outpoints. push ( justice_package) ;
26752675 }
@@ -2787,13 +2787,13 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
27872787 CounterpartyOfferedHTLCOutput :: build ( * per_commitment_point,
27882788 self . counterparty_commitment_params . counterparty_delayed_payment_base_key ,
27892789 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 ( ) ) )
27912791 } else {
27922792 PackageSolvingData :: CounterpartyReceivedHTLCOutput (
27932793 CounterpartyReceivedHTLCOutput :: build ( * per_commitment_point,
27942794 self . counterparty_commitment_params . counterparty_delayed_payment_base_key ,
27952795 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 ( ) ) )
27972797 } ;
27982798 let counterparty_package = PackageTemplate :: build_package ( commitment_txid, transaction_output_index, counterparty_htlc_outp, htlc. cltv_expiry , 0 ) ;
27992799 claimable_outpoints. push ( counterparty_package) ;
@@ -2864,7 +2864,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
28642864 if let Some ( transaction_output_index) = htlc. transaction_output_index {
28652865 let htlc_output = if htlc. offered {
28662866 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 ( )
28682868 ) ;
28692869 htlc_output
28702870 } else {
@@ -2875,7 +2875,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
28752875 continue ;
28762876 } ;
28772877 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 ( )
28792879 ) ;
28802880 htlc_output
28812881 } ;
@@ -2959,7 +2959,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
29592959 let mut holder_transactions = vec ! [ commitment_tx] ;
29602960 // When anchor outputs are present, the HTLC transactions are only valid once the commitment
29612961 // transaction confirms.
2962- if self . onchain_tx_handler . opt_anchors ( ) {
2962+ if self . onchain_tx_handler . channel_type_features ( ) . supports_anchors ( ) {
29632963 return holder_transactions;
29642964 }
29652965 for htlc in self . current_holder_commitment_tx . htlc_outputs . iter ( ) {
@@ -2997,7 +2997,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
29972997 let mut holder_transactions = vec ! [ commitment_tx] ;
29982998 // When anchor outputs are present, the HTLC transactions are only final once the commitment
29992999 // 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 ( ) {
30013001 return holder_transactions;
30023002 }
30033003 for htlc in self . current_holder_commitment_tx . htlc_outputs . iter ( ) {
@@ -3221,7 +3221,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
32213221
32223222 let should_broadcast = self . should_broadcast_holder_commitment_txn ( logger) ;
32233223 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 ( ) ) ;
32253225 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 ( ) ) ;
32263226 claimable_outpoints. push ( commitment_package) ;
32273227 self . pending_monitor_events . push ( MonitorEvent :: CommitmentTxConfirmed ( self . funding_info . 0 ) ) ;
@@ -3230,7 +3230,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
32303230 // We can't broadcast our HTLC transactions while the commitment transaction is
32313231 // unconfirmed. We'll delay doing so until we detect the confirmed commitment in
32323232 // `transactions_confirmed`.
3233- if !self . onchain_tx_handler . opt_anchors ( ) {
3233+ if !self . onchain_tx_handler . channel_type_features ( ) . supports_anchors ( ) {
32343234 // Because we're broadcasting a commitment transaction, we should construct the package
32353235 // assuming it gets confirmed in the next block. Sadly, we have code which considers
32363236 // "not yet confirmed" things as discardable, so we cannot do that here.
@@ -4158,6 +4158,7 @@ mod tests {
41584158 use crate :: sync:: { Arc , Mutex } ;
41594159 use crate :: io;
41604160 use bitcoin:: { PackedLockTime , Sequence , Witness } ;
4161+ use crate :: ln:: features:: ChannelTypeFeatures ;
41614162 use crate :: prelude:: * ;
41624163
41634164 fn do_test_funding_spend_refuses_updates ( use_local_txn : bool ) {
@@ -4331,8 +4332,7 @@ mod tests {
43314332 selected_contest_delay : 67 ,
43324333 } ) ,
43334334 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 ( )
43364336 } ;
43374337 // Prune with one old state and a holder commitment tx holding a few overlaps with the
43384338 // old state.
@@ -4448,7 +4448,7 @@ mod tests {
44484448 let txid = Txid :: from_hex ( "56944c5d3f98413ef45cf54545538103cc9f298e0575820ad3591376e2e0f65d" ) . unwrap ( ) ;
44494449
44504450 // 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 ( ) {
44524452 let mut claim_tx = Transaction { version : 0 , lock_time : PackedLockTime :: ZERO , input : Vec :: new ( ) , output : Vec :: new ( ) } ;
44534453 let mut sum_actual_sigs = 0 ;
44544454 for i in 0 ..4 {
@@ -4467,20 +4467,20 @@ mod tests {
44674467 value : 0 ,
44684468 } ) ;
44694469 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 ) ] ;
44714471 let mut inputs_total_weight = 2 ; // count segwit flags
44724472 {
44734473 let mut sighash_parts = sighash:: SighashCache :: new ( & mut claim_tx) ;
44744474 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 ) ;
44764476 inputs_total_weight += inp;
44774477 }
44784478 }
44794479 assert_eq ! ( base_weight + inputs_total_weight as usize , claim_tx. weight( ) + /* max_length_sig */ ( 73 * inputs_weight. len( ) - sum_actual_sigs) ) ;
44804480 }
44814481
44824482 // 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 ( ) {
44844484 let mut claim_tx = Transaction { version : 0 , lock_time : PackedLockTime :: ZERO , input : Vec :: new ( ) , output : Vec :: new ( ) } ;
44854485 let mut sum_actual_sigs = 0 ;
44864486 for i in 0 ..4 {
@@ -4499,20 +4499,20 @@ mod tests {
44994499 value : 0 ,
45004500 } ) ;
45014501 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 ) ] ;
45034503 let mut inputs_total_weight = 2 ; // count segwit flags
45044504 {
45054505 let mut sighash_parts = sighash:: SighashCache :: new ( & mut claim_tx) ;
45064506 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 ) ;
45084508 inputs_total_weight += inp;
45094509 }
45104510 }
45114511 assert_eq ! ( base_weight + inputs_total_weight as usize , claim_tx. weight( ) + /* max_length_sig */ ( 73 * inputs_weight. len( ) - sum_actual_sigs) ) ;
45124512 }
45134513
45144514 // 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 ( ) {
45164516 let mut claim_tx = Transaction { version : 0 , lock_time : PackedLockTime :: ZERO , input : Vec :: new ( ) , output : Vec :: new ( ) } ;
45174517 let mut sum_actual_sigs = 0 ;
45184518 claim_tx. input . push ( TxIn {
0 commit comments