@@ -3008,23 +3008,26 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
3008
3008
( payment_preimage. clone ( ) , payment_info. clone ( ) . into_iter ( ) . collect ( ) )
3009
3009
} ) ;
3010
3010
3011
- let confirmed_spend_txid = self . funding_spend_confirmed . or_else ( || {
3012
- self . onchain_events_awaiting_threshold_conf . iter ( ) . find_map ( |event| match event. event {
3013
- OnchainEvent :: FundingSpendConfirmation { .. } => Some ( event. txid ) ,
3014
- _ => None ,
3015
- } )
3016
- } ) ;
3017
- let confirmed_spend_txid = if let Some ( txid) = confirmed_spend_txid {
3018
- txid
3019
- } else {
3020
- return ;
3021
- } ;
3011
+ let confirmed_spend_info = self . funding_spend_confirmed
3012
+ . map ( |txid| ( txid, None ) )
3013
+ . or_else ( || {
3014
+ self . onchain_events_awaiting_threshold_conf . iter ( ) . find_map ( |event| match event. event {
3015
+ OnchainEvent :: FundingSpendConfirmation { .. } => Some ( ( event. txid , Some ( event. height ) ) ) ,
3016
+ _ => None ,
3017
+ } )
3018
+ } ) ;
3019
+ let ( confirmed_spend_txid, confirmed_spend_height) =
3020
+ if let Some ( ( txid, height) ) = confirmed_spend_info {
3021
+ ( txid, height)
3022
+ } else {
3023
+ return ;
3024
+ } ;
3022
3025
3023
3026
// If the channel is force closed, try to claim the output from this preimage.
3024
3027
// First check if a counterparty commitment transaction has been broadcasted:
3025
3028
macro_rules! claim_htlcs {
3026
3029
( $commitment_number: expr, $txid: expr, $htlcs: expr) => {
3027
- let ( htlc_claim_reqs, _) = self . get_counterparty_output_claim_info( $commitment_number, $txid, None , $htlcs) ;
3030
+ let ( htlc_claim_reqs, _) = self . get_counterparty_output_claim_info( $commitment_number, $txid, None , $htlcs, confirmed_spend_height ) ;
3028
3031
let conf_target = self . closure_conf_target( ) ;
3029
3032
self . onchain_tx_handler. update_claims_view_from_requests( htlc_claim_reqs, self . best_block. height, self . best_block. height, broadcaster, conf_target, fee_estimator, logger) ;
3030
3033
}
@@ -3542,7 +3545,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
3542
3545
// First, process non-htlc outputs (to_holder & to_counterparty)
3543
3546
for ( idx, outp) in tx. output . iter ( ) . enumerate ( ) {
3544
3547
if outp. script_pubkey == revokeable_p2wsh {
3545
- 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 ( ) ) ;
3548
+ 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 ( ) , height ) ;
3546
3549
let justice_package = PackageTemplate :: build_package (
3547
3550
commitment_txid, idx as u32 ,
3548
3551
PackageSolvingData :: RevokedOutput ( revk_outp) ,
@@ -3563,7 +3566,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
3563
3566
// per_commitment_data is corrupt or our commitment signing key leaked!
3564
3567
return ( claimable_outpoints, to_counterparty_output_info) ;
3565
3568
}
3566
- 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 ) ;
3569
+ 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 , height ) ;
3567
3570
let counterparty_spendable_height = if htlc. offered {
3568
3571
htlc. cltv_expiry
3569
3572
} else {
@@ -3617,7 +3620,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
3617
3620
( htlc, htlc_source. as_ref( ) . map( |htlc_source| htlc_source. as_ref( ) ) )
3618
3621
) , logger) ;
3619
3622
let ( htlc_claim_reqs, counterparty_output_info) =
3620
- self . get_counterparty_output_claim_info ( commitment_number, commitment_txid, Some ( tx) , per_commitment_option) ;
3623
+ self . get_counterparty_output_claim_info ( commitment_number, commitment_txid, Some ( tx) , per_commitment_option, Some ( height ) ) ;
3621
3624
to_counterparty_output_info = counterparty_output_info;
3622
3625
for req in htlc_claim_reqs {
3623
3626
claimable_outpoints. push ( req) ;
@@ -3628,7 +3631,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
3628
3631
}
3629
3632
3630
3633
/// Returns the HTLC claim package templates and the counterparty output info
3631
- fn get_counterparty_output_claim_info ( & self , commitment_number : u64 , commitment_txid : Txid , tx : Option < & Transaction > , per_commitment_option : Option < & Vec < ( HTLCOutputInCommitment , Option < Box < HTLCSource > > ) > > )
3634
+ fn get_counterparty_output_claim_info ( & self , commitment_number : u64 , commitment_txid : Txid , tx : Option < & Transaction > , per_commitment_option : Option < & Vec < ( HTLCOutputInCommitment , Option < Box < HTLCSource > > ) > > , confirmation_height : Option < u32 > )
3632
3635
-> ( Vec < PackageTemplate > , CommitmentTxCounterpartyOutputInfo ) {
3633
3636
let mut claimable_outpoints = Vec :: new ( ) ;
3634
3637
let mut to_counterparty_output_info: CommitmentTxCounterpartyOutputInfo = None ;
@@ -3688,13 +3691,15 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
3688
3691
CounterpartyOfferedHTLCOutput :: build ( * per_commitment_point,
3689
3692
self . counterparty_commitment_params . counterparty_delayed_payment_base_key ,
3690
3693
self . counterparty_commitment_params . counterparty_htlc_base_key ,
3691
- preimage. unwrap ( ) , htlc. clone ( ) , self . onchain_tx_handler . channel_type_features ( ) . clone ( ) ) )
3694
+ preimage. unwrap ( ) , htlc. clone ( ) , self . onchain_tx_handler . channel_type_features ( ) . clone ( ) ,
3695
+ confirmation_height) )
3692
3696
} else {
3693
3697
PackageSolvingData :: CounterpartyReceivedHTLCOutput (
3694
3698
CounterpartyReceivedHTLCOutput :: build ( * per_commitment_point,
3695
3699
self . counterparty_commitment_params . counterparty_delayed_payment_base_key ,
3696
3700
self . counterparty_commitment_params . counterparty_htlc_base_key ,
3697
- htlc. clone ( ) , self . onchain_tx_handler . channel_type_features ( ) . clone ( ) ) )
3701
+ htlc. clone ( ) , self . onchain_tx_handler . channel_type_features ( ) . clone ( ) ,
3702
+ confirmation_height) )
3698
3703
} ;
3699
3704
let counterparty_package = PackageTemplate :: build_package ( commitment_txid, transaction_output_index, counterparty_htlc_outp, htlc. cltv_expiry ) ;
3700
3705
claimable_outpoints. push ( counterparty_package) ;
@@ -3736,7 +3741,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
3736
3741
per_commitment_point, self . counterparty_commitment_params . counterparty_delayed_payment_base_key ,
3737
3742
self . counterparty_commitment_params . counterparty_htlc_base_key , per_commitment_key,
3738
3743
tx. output [ idx] . value , self . counterparty_commitment_params . on_counterparty_tx_csv ,
3739
- false
3744
+ false , height ,
3740
3745
) ;
3741
3746
let justice_package = PackageTemplate :: build_package (
3742
3747
htlc_txid, idx as u32 , PackageSolvingData :: RevokedOutput ( revk_outp) ,
@@ -3765,7 +3770,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
3765
3770
if let Some ( transaction_output_index) = htlc. transaction_output_index {
3766
3771
let ( htlc_output, counterparty_spendable_height) = if htlc. offered {
3767
3772
let htlc_output = HolderHTLCOutput :: build_offered (
3768
- htlc. amount_msat , htlc. cltv_expiry , self . onchain_tx_handler . channel_type_features ( ) . clone ( )
3773
+ htlc. amount_msat , htlc. cltv_expiry , self . onchain_tx_handler . channel_type_features ( ) . clone ( ) , conf_height
3769
3774
) ;
3770
3775
( htlc_output, conf_height)
3771
3776
} else {
@@ -3776,7 +3781,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
3776
3781
continue ;
3777
3782
} ;
3778
3783
let htlc_output = HolderHTLCOutput :: build_accepted (
3779
- payment_preimage, htlc. amount_msat , self . onchain_tx_handler . channel_type_features ( ) . clone ( )
3784
+ payment_preimage, htlc. amount_msat , self . onchain_tx_handler . channel_type_features ( ) . clone ( ) , conf_height
3780
3785
) ;
3781
3786
( htlc_output, htlc. cltv_expiry )
3782
3787
} ;
0 commit comments