@@ -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_zero_fee_htlc_tx ( ) ) ;
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_zero_fee_htlc_tx ( ) {
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 (
@@ -2653,7 +2653,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
2653
2653
// First, process non-htlc outputs (to_holder & to_counterparty)
2654
2654
for ( idx, outp) in tx. output . iter ( ) . enumerate ( ) {
2655
2655
if outp. script_pubkey == revokeable_p2wsh {
2656
- 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 ( ) ) ;
2656
+ 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_zero_fee_htlc_tx ( ) ) ;
2657
2657
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) ;
2658
2658
claimable_outpoints. push ( justice_package) ;
2659
2659
to_counterparty_output_info =
@@ -2671,7 +2671,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
2671
2671
return ( claimable_outpoints, ( commitment_txid, watch_outputs) ,
2672
2672
to_counterparty_output_info) ;
2673
2673
}
2674
- 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 ( ) ) ;
2674
+ 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 ) ;
2675
2675
let justice_package = PackageTemplate :: build_package ( commitment_txid, transaction_output_index, PackageSolvingData :: RevokedHTLCOutput ( revk_htlc_outp) , htlc. cltv_expiry , height) ;
2676
2676
claimable_outpoints. push ( justice_package) ;
2677
2677
}
@@ -2789,13 +2789,13 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
2789
2789
CounterpartyOfferedHTLCOutput :: build ( * per_commitment_point,
2790
2790
self . counterparty_commitment_params . counterparty_delayed_payment_base_key ,
2791
2791
self . counterparty_commitment_params . counterparty_htlc_base_key ,
2792
- preimage. unwrap ( ) , htlc. clone ( ) , self . onchain_tx_handler . opt_anchors ( ) ) )
2792
+ preimage. unwrap ( ) , htlc. clone ( ) , self . onchain_tx_handler . channel_type_features ( ) ) )
2793
2793
} else {
2794
2794
PackageSolvingData :: CounterpartyReceivedHTLCOutput (
2795
2795
CounterpartyReceivedHTLCOutput :: build ( * per_commitment_point,
2796
2796
self . counterparty_commitment_params . counterparty_delayed_payment_base_key ,
2797
2797
self . counterparty_commitment_params . counterparty_htlc_base_key ,
2798
- htlc. clone ( ) , self . onchain_tx_handler . opt_anchors ( ) ) )
2798
+ htlc. clone ( ) , self . onchain_tx_handler . channel_type_features ( ) ) )
2799
2799
} ;
2800
2800
let counterparty_package = PackageTemplate :: build_package ( commitment_txid, transaction_output_index, counterparty_htlc_outp, htlc. cltv_expiry , 0 ) ;
2801
2801
claimable_outpoints. push ( counterparty_package) ;
@@ -2866,7 +2866,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
2866
2866
if let Some ( transaction_output_index) = htlc. transaction_output_index {
2867
2867
let htlc_output = if htlc. offered {
2868
2868
let htlc_output = HolderHTLCOutput :: build_offered (
2869
- htlc. amount_msat , htlc. cltv_expiry , self . onchain_tx_handler . opt_anchors ( )
2869
+ htlc. amount_msat , htlc. cltv_expiry , self . onchain_tx_handler . channel_type_features ( )
2870
2870
) ;
2871
2871
htlc_output
2872
2872
} else {
@@ -2877,7 +2877,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
2877
2877
continue ;
2878
2878
} ;
2879
2879
let htlc_output = HolderHTLCOutput :: build_accepted (
2880
- payment_preimage, htlc. amount_msat , self . onchain_tx_handler . opt_anchors ( )
2880
+ payment_preimage, htlc. amount_msat , self . onchain_tx_handler . channel_type_features ( )
2881
2881
) ;
2882
2882
htlc_output
2883
2883
} ;
@@ -2961,7 +2961,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
2961
2961
let mut holder_transactions = vec ! [ commitment_tx] ;
2962
2962
// When anchor outputs are present, the HTLC transactions are only valid once the commitment
2963
2963
// transaction confirms.
2964
- if self . onchain_tx_handler . opt_anchors ( ) {
2964
+ if self . onchain_tx_handler . channel_type_features ( ) . supports_anchors_zero_fee_htlc_tx ( ) {
2965
2965
return holder_transactions;
2966
2966
}
2967
2967
for htlc in self . current_holder_commitment_tx . htlc_outputs . iter ( ) {
@@ -2999,7 +2999,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
2999
2999
let mut holder_transactions = vec ! [ commitment_tx] ;
3000
3000
// When anchor outputs are present, the HTLC transactions are only final once the commitment
3001
3001
// transaction confirms due to the CSV 1 encumberance.
3002
- if self . onchain_tx_handler . opt_anchors ( ) {
3002
+ if self . onchain_tx_handler . channel_type_features ( ) . supports_anchors_zero_fee_htlc_tx ( ) {
3003
3003
return holder_transactions;
3004
3004
}
3005
3005
for htlc in self . current_holder_commitment_tx . htlc_outputs . iter ( ) {
@@ -3223,7 +3223,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
3223
3223
3224
3224
let should_broadcast = self . should_broadcast_holder_commitment_txn ( logger) ;
3225
3225
if should_broadcast {
3226
- let funding_outp = HolderFundingOutput :: build ( self . funding_redeemscript . clone ( ) , self . channel_value_satoshis , self . onchain_tx_handler . opt_anchors ( ) ) ;
3226
+ let funding_outp = HolderFundingOutput :: build ( self . funding_redeemscript . clone ( ) , self . channel_value_satoshis , self . onchain_tx_handler . channel_type_features ( ) ) ;
3227
3227
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 ( ) ) ;
3228
3228
claimable_outpoints. push ( commitment_package) ;
3229
3229
self . pending_monitor_events . push ( MonitorEvent :: CommitmentTxConfirmed ( self . funding_info . 0 ) ) ;
@@ -3232,7 +3232,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
3232
3232
// We can't broadcast our HTLC transactions while the commitment transaction is
3233
3233
// unconfirmed. We'll delay doing so until we detect the confirmed commitment in
3234
3234
// `transactions_confirmed`.
3235
- if !self . onchain_tx_handler . opt_anchors ( ) {
3235
+ if !self . onchain_tx_handler . channel_type_features ( ) . supports_anchors_zero_fee_htlc_tx ( ) {
3236
3236
// Because we're broadcasting a commitment transaction, we should construct the package
3237
3237
// assuming it gets confirmed in the next block. Sadly, we have code which considers
3238
3238
// "not yet confirmed" things as discardable, so we cannot do that here.
@@ -4160,6 +4160,7 @@ mod tests {
4160
4160
use crate :: sync:: { Arc , Mutex } ;
4161
4161
use crate :: io;
4162
4162
use bitcoin:: { PackedLockTime , Sequence , Witness } ;
4163
+ use crate :: ln:: features:: ChannelTypeFeatures ;
4163
4164
use crate :: prelude:: * ;
4164
4165
4165
4166
fn do_test_funding_spend_refuses_updates ( use_local_txn : bool ) {
@@ -4333,8 +4334,7 @@ mod tests {
4333
4334
selected_contest_delay : 67 ,
4334
4335
} ) ,
4335
4336
funding_outpoint : Some ( funding_outpoint) ,
4336
- opt_anchors : None ,
4337
- opt_non_zero_fee_anchors : None ,
4337
+ channel_type_features : ChannelTypeFeatures :: only_static_remote_key ( )
4338
4338
} ;
4339
4339
// Prune with one old state and a holder commitment tx holding a few overlaps with the
4340
4340
// old state.
@@ -4450,7 +4450,7 @@ mod tests {
4450
4450
let txid = Txid :: from_hex ( "56944c5d3f98413ef45cf54545538103cc9f298e0575820ad3591376e2e0f65d" ) . unwrap ( ) ;
4451
4451
4452
4452
// Justice tx with 1 to_holder, 2 revoked offered HTLCs, 1 revoked received HTLCs
4453
- for & opt_anchors in [ false , true ] . iter ( ) {
4453
+ for channel_type_features in [ ChannelTypeFeatures :: only_static_remote_key ( ) , ChannelTypeFeatures :: anchors_zero_htlc_fee_and_dependencies ( ) ] . iter ( ) {
4454
4454
let mut claim_tx = Transaction { version : 0 , lock_time : PackedLockTime :: ZERO , input : Vec :: new ( ) , output : Vec :: new ( ) } ;
4455
4455
let mut sum_actual_sigs = 0 ;
4456
4456
for i in 0 ..4 {
@@ -4469,20 +4469,20 @@ mod tests {
4469
4469
value : 0 ,
4470
4470
} ) ;
4471
4471
let base_weight = claim_tx. weight ( ) ;
4472
- 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 ) ] ;
4472
+ 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 ) ] ;
4473
4473
let mut inputs_total_weight = 2 ; // count segwit flags
4474
4474
{
4475
4475
let mut sighash_parts = sighash:: SighashCache :: new ( & mut claim_tx) ;
4476
4476
for ( idx, inp) in inputs_weight. iter ( ) . enumerate ( ) {
4477
- sign_input ! ( sighash_parts, idx, 0 , inp, sum_actual_sigs, opt_anchors ) ;
4477
+ sign_input ! ( sighash_parts, idx, 0 , inp, sum_actual_sigs, channel_type_features ) ;
4478
4478
inputs_total_weight += inp;
4479
4479
}
4480
4480
}
4481
4481
assert_eq ! ( base_weight + inputs_total_weight as usize , claim_tx. weight( ) + /* max_length_sig */ ( 73 * inputs_weight. len( ) - sum_actual_sigs) ) ;
4482
4482
}
4483
4483
4484
4484
// Claim tx with 1 offered HTLCs, 3 received HTLCs
4485
- for & opt_anchors in [ false , true ] . iter ( ) {
4485
+ for channel_type_features in [ ChannelTypeFeatures :: only_static_remote_key ( ) , ChannelTypeFeatures :: anchors_zero_htlc_fee_and_dependencies ( ) ] . iter ( ) {
4486
4486
let mut claim_tx = Transaction { version : 0 , lock_time : PackedLockTime :: ZERO , input : Vec :: new ( ) , output : Vec :: new ( ) } ;
4487
4487
let mut sum_actual_sigs = 0 ;
4488
4488
for i in 0 ..4 {
@@ -4501,20 +4501,20 @@ mod tests {
4501
4501
value : 0 ,
4502
4502
} ) ;
4503
4503
let base_weight = claim_tx. weight ( ) ;
4504
- let inputs_weight = vec ! [ weight_offered_htlc( opt_anchors ) , weight_received_htlc( opt_anchors ) , weight_received_htlc( opt_anchors ) , weight_received_htlc( opt_anchors ) ] ;
4504
+ 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 ) ] ;
4505
4505
let mut inputs_total_weight = 2 ; // count segwit flags
4506
4506
{
4507
4507
let mut sighash_parts = sighash:: SighashCache :: new ( & mut claim_tx) ;
4508
4508
for ( idx, inp) in inputs_weight. iter ( ) . enumerate ( ) {
4509
- sign_input ! ( sighash_parts, idx, 0 , inp, sum_actual_sigs, opt_anchors ) ;
4509
+ sign_input ! ( sighash_parts, idx, 0 , inp, sum_actual_sigs, channel_type_features ) ;
4510
4510
inputs_total_weight += inp;
4511
4511
}
4512
4512
}
4513
4513
assert_eq ! ( base_weight + inputs_total_weight as usize , claim_tx. weight( ) + /* max_length_sig */ ( 73 * inputs_weight. len( ) - sum_actual_sigs) ) ;
4514
4514
}
4515
4515
4516
4516
// Justice tx with 1 revoked HTLC-Success tx output
4517
- for & opt_anchors in [ false , true ] . iter ( ) {
4517
+ for channel_type_features in [ ChannelTypeFeatures :: only_static_remote_key ( ) , ChannelTypeFeatures :: anchors_zero_htlc_fee_and_dependencies ( ) ] . iter ( ) {
4518
4518
let mut claim_tx = Transaction { version : 0 , lock_time : PackedLockTime :: ZERO , input : Vec :: new ( ) , output : Vec :: new ( ) } ;
4519
4519
let mut sum_actual_sigs = 0 ;
4520
4520
claim_tx. input . push ( TxIn {
@@ -4536,7 +4536,7 @@ mod tests {
4536
4536
{
4537
4537
let mut sighash_parts = sighash:: SighashCache :: new ( & mut claim_tx) ;
4538
4538
for ( idx, inp) in inputs_weight. iter ( ) . enumerate ( ) {
4539
- sign_input ! ( sighash_parts, idx, 0 , inp, sum_actual_sigs, opt_anchors ) ;
4539
+ sign_input ! ( sighash_parts, idx, 0 , inp, sum_actual_sigs, channel_type_features ) ;
4540
4540
inputs_total_weight += inp;
4541
4541
}
4542
4542
}
0 commit comments