@@ -3514,23 +3514,26 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
3514
3514
( payment_preimage. clone ( ) , payment_info. clone ( ) . into_iter ( ) . collect ( ) )
3515
3515
} ) ;
3516
3516
3517
- let confirmed_spend_txid = self . funding_spend_confirmed . or_else ( || {
3518
- self . onchain_events_awaiting_threshold_conf . iter ( ) . find_map ( |event| match event. event {
3519
- OnchainEvent :: FundingSpendConfirmation { .. } => Some ( event. txid ) ,
3520
- _ => None ,
3521
- } )
3522
- } ) ;
3523
- let confirmed_spend_txid = if let Some ( txid) = confirmed_spend_txid {
3524
- txid
3525
- } else {
3526
- return ;
3527
- } ;
3517
+ let confirmed_spend_info = self . funding_spend_confirmed
3518
+ . map ( |txid| ( txid, None ) )
3519
+ . or_else ( || {
3520
+ self . onchain_events_awaiting_threshold_conf . iter ( ) . find_map ( |event| match event. event {
3521
+ OnchainEvent :: FundingSpendConfirmation { .. } => Some ( ( event. txid , Some ( event. height ) ) ) ,
3522
+ _ => None ,
3523
+ } )
3524
+ } ) ;
3525
+ let ( confirmed_spend_txid, confirmed_spend_height) =
3526
+ if let Some ( ( txid, height) ) = confirmed_spend_info {
3527
+ ( txid, height)
3528
+ } else {
3529
+ return ;
3530
+ } ;
3528
3531
3529
3532
// If the channel is force closed, try to claim the output from this preimage.
3530
3533
// First check if a counterparty commitment transaction has been broadcasted:
3531
3534
macro_rules! claim_htlcs {
3532
3535
( $commitment_number: expr, $txid: expr, $htlcs: expr) => {
3533
- let ( htlc_claim_reqs, _) = self . get_counterparty_output_claim_info( $commitment_number, $txid, None , $htlcs) ;
3536
+ let ( htlc_claim_reqs, _) = self . get_counterparty_output_claim_info( $commitment_number, $txid, None , $htlcs, confirmed_spend_height ) ;
3534
3537
let conf_target = self . closure_conf_target( ) ;
3535
3538
self . onchain_tx_handler. update_claims_view_from_requests(
3536
3539
htlc_claim_reqs, self . best_block. height, self . best_block. height, broadcaster,
@@ -4226,6 +4229,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
4226
4229
per_commitment_point, per_commitment_key, outp. value ,
4227
4230
self . funding . channel_parameters . channel_type_features . supports_anchors_zero_fee_htlc_tx ( ) ,
4228
4231
self . funding . channel_parameters . clone ( ) ,
4232
+ height,
4229
4233
) ;
4230
4234
let justice_package = PackageTemplate :: build_package (
4231
4235
commitment_txid, idx as u32 ,
@@ -4250,6 +4254,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
4250
4254
let revk_htlc_outp = RevokedHTLCOutput :: build (
4251
4255
per_commitment_point, per_commitment_key, htlc. clone ( ) ,
4252
4256
self . funding . channel_parameters . clone ( ) ,
4257
+ height,
4253
4258
) ;
4254
4259
let counterparty_spendable_height = if htlc. offered {
4255
4260
htlc. cltv_expiry
@@ -4304,7 +4309,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
4304
4309
( htlc, htlc_source. as_ref( ) . map( |htlc_source| htlc_source. as_ref( ) ) )
4305
4310
) , logger) ;
4306
4311
let ( htlc_claim_reqs, counterparty_output_info) =
4307
- self . get_counterparty_output_claim_info ( commitment_number, commitment_txid, Some ( tx) , per_commitment_option) ;
4312
+ self . get_counterparty_output_claim_info ( commitment_number, commitment_txid, Some ( tx) , per_commitment_option, Some ( height ) ) ;
4308
4313
to_counterparty_output_info = counterparty_output_info;
4309
4314
for req in htlc_claim_reqs {
4310
4315
claimable_outpoints. push ( req) ;
@@ -4316,8 +4321,11 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
4316
4321
4317
4322
/// Returns the HTLC claim package templates and the counterparty output info
4318
4323
#[ rustfmt:: skip]
4319
- 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 > > ) > > )
4320
- -> ( Vec < PackageTemplate > , CommitmentTxCounterpartyOutputInfo ) {
4324
+ fn get_counterparty_output_claim_info (
4325
+ & self , commitment_number : u64 , commitment_txid : Txid , tx : Option < & Transaction > ,
4326
+ per_commitment_option : Option < & Vec < ( HTLCOutputInCommitment , Option < Box < HTLCSource > > ) > > ,
4327
+ confirmation_height : Option < u32 > ,
4328
+ ) -> ( Vec < PackageTemplate > , CommitmentTxCounterpartyOutputInfo ) {
4321
4329
let mut claimable_outpoints = Vec :: new ( ) ;
4322
4330
let mut to_counterparty_output_info: CommitmentTxCounterpartyOutputInfo = None ;
4323
4331
@@ -4374,15 +4382,19 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
4374
4382
let counterparty_htlc_outp = if htlc. offered {
4375
4383
PackageSolvingData :: CounterpartyOfferedHTLCOutput (
4376
4384
CounterpartyOfferedHTLCOutput :: build (
4377
- * per_commitment_point, preimage. unwrap ( ) , htlc. clone ( ) ,
4385
+ * per_commitment_point, preimage. unwrap ( ) ,
4386
+ htlc. clone ( ) ,
4378
4387
self . funding . channel_parameters . clone ( ) ,
4388
+ confirmation_height,
4379
4389
)
4380
4390
)
4381
4391
} else {
4382
4392
PackageSolvingData :: CounterpartyReceivedHTLCOutput (
4383
4393
CounterpartyReceivedHTLCOutput :: build (
4384
- * per_commitment_point, htlc. clone ( ) ,
4394
+ * per_commitment_point,
4395
+ htlc. clone ( ) ,
4385
4396
self . funding . channel_parameters . clone ( ) ,
4397
+ confirmation_height,
4386
4398
)
4387
4399
)
4388
4400
} ;
@@ -4426,6 +4438,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
4426
4438
let revk_outp = RevokedOutput :: build (
4427
4439
per_commitment_point, per_commitment_key, tx. output [ idx] . value , false ,
4428
4440
self . funding . channel_parameters . clone ( ) ,
4441
+ height,
4429
4442
) ;
4430
4443
let justice_package = PackageTemplate :: build_package (
4431
4444
htlc_txid, idx as u32 , PackageSolvingData :: RevokedOutput ( revk_outp) ,
@@ -4507,7 +4520,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
4507
4520
. expect ( "Expected transaction output index for non-dust HTLC" ) ;
4508
4521
PackageTemplate :: build_package (
4509
4522
tx. txid ( ) , transaction_output_index,
4510
- PackageSolvingData :: HolderHTLCOutput ( HolderHTLCOutput :: build ( htlc_descriptor) ) ,
4523
+ PackageSolvingData :: HolderHTLCOutput ( HolderHTLCOutput :: build ( htlc_descriptor, conf_height ) ) ,
4511
4524
counterparty_spendable_height,
4512
4525
)
4513
4526
} )
@@ -4687,7 +4700,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
4687
4700
let txid = self . funding . current_holder_commitment_tx . trust ( ) . txid ( ) ;
4688
4701
let vout = htlc_descriptor. htlc . transaction_output_index
4689
4702
. expect ( "Expected transaction output index for non-dust HTLC" ) ;
4690
- let htlc_output = HolderHTLCOutput :: build ( htlc_descriptor) ;
4703
+ let htlc_output = HolderHTLCOutput :: build ( htlc_descriptor, 0 ) ;
4691
4704
if let Some ( htlc_tx) = htlc_output. get_maybe_signed_htlc_tx (
4692
4705
& mut self . onchain_tx_handler , & :: bitcoin:: OutPoint { txid, vout } ,
4693
4706
) {
0 commit comments