@@ -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,
@@ -4230,6 +4233,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
4230
4233
per_commitment_point, per_commitment_key, outp. value ,
4231
4234
self . funding . channel_parameters . channel_type_features . supports_anchors_zero_fee_htlc_tx ( ) ,
4232
4235
self . funding . channel_parameters . clone ( ) ,
4236
+ height,
4233
4237
) ;
4234
4238
let justice_package = PackageTemplate :: build_package (
4235
4239
commitment_txid, idx as u32 ,
@@ -4254,6 +4258,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
4254
4258
let revk_htlc_outp = RevokedHTLCOutput :: build (
4255
4259
per_commitment_point, per_commitment_key, htlc. clone ( ) ,
4256
4260
self . funding . channel_parameters . clone ( ) ,
4261
+ height,
4257
4262
) ;
4258
4263
let counterparty_spendable_height = if htlc. offered {
4259
4264
htlc. cltv_expiry
@@ -4308,7 +4313,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
4308
4313
( htlc, htlc_source. as_ref( ) . map( |htlc_source| htlc_source. as_ref( ) ) )
4309
4314
) , logger) ;
4310
4315
let ( htlc_claim_reqs, counterparty_output_info) =
4311
- self . get_counterparty_output_claim_info ( commitment_number, commitment_txid, Some ( tx) , per_commitment_option) ;
4316
+ self . get_counterparty_output_claim_info ( commitment_number, commitment_txid, Some ( tx) , per_commitment_option, Some ( height ) ) ;
4312
4317
to_counterparty_output_info = counterparty_output_info;
4313
4318
for req in htlc_claim_reqs {
4314
4319
claimable_outpoints. push ( req) ;
@@ -4320,8 +4325,11 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
4320
4325
4321
4326
/// Returns the HTLC claim package templates and the counterparty output info
4322
4327
#[ rustfmt:: skip]
4323
- 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 > > ) > > )
4324
- -> ( Vec < PackageTemplate > , CommitmentTxCounterpartyOutputInfo ) {
4328
+ fn get_counterparty_output_claim_info (
4329
+ & self , commitment_number : u64 , commitment_txid : Txid , tx : Option < & Transaction > ,
4330
+ per_commitment_option : Option < & Vec < ( HTLCOutputInCommitment , Option < Box < HTLCSource > > ) > > ,
4331
+ confirmation_height : Option < u32 > ,
4332
+ ) -> ( Vec < PackageTemplate > , CommitmentTxCounterpartyOutputInfo ) {
4325
4333
let mut claimable_outpoints = Vec :: new ( ) ;
4326
4334
let mut to_counterparty_output_info: CommitmentTxCounterpartyOutputInfo = None ;
4327
4335
@@ -4378,15 +4386,19 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
4378
4386
let counterparty_htlc_outp = if htlc. offered {
4379
4387
PackageSolvingData :: CounterpartyOfferedHTLCOutput (
4380
4388
CounterpartyOfferedHTLCOutput :: build (
4381
- * per_commitment_point, preimage. unwrap ( ) , htlc. clone ( ) ,
4389
+ * per_commitment_point, preimage. unwrap ( ) ,
4390
+ htlc. clone ( ) ,
4382
4391
self . funding . channel_parameters . clone ( ) ,
4392
+ confirmation_height,
4383
4393
)
4384
4394
)
4385
4395
} else {
4386
4396
PackageSolvingData :: CounterpartyReceivedHTLCOutput (
4387
4397
CounterpartyReceivedHTLCOutput :: build (
4388
- * per_commitment_point, htlc. clone ( ) ,
4398
+ * per_commitment_point,
4399
+ htlc. clone ( ) ,
4389
4400
self . funding . channel_parameters . clone ( ) ,
4401
+ confirmation_height,
4390
4402
)
4391
4403
)
4392
4404
} ;
@@ -4430,6 +4442,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
4430
4442
let revk_outp = RevokedOutput :: build (
4431
4443
per_commitment_point, per_commitment_key, tx. output [ idx] . value , false ,
4432
4444
self . funding . channel_parameters . clone ( ) ,
4445
+ height,
4433
4446
) ;
4434
4447
let justice_package = PackageTemplate :: build_package (
4435
4448
htlc_txid, idx as u32 , PackageSolvingData :: RevokedOutput ( revk_outp) ,
@@ -4511,7 +4524,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
4511
4524
. expect ( "Expected transaction output index for non-dust HTLC" ) ;
4512
4525
PackageTemplate :: build_package (
4513
4526
tx. txid ( ) , transaction_output_index,
4514
- PackageSolvingData :: HolderHTLCOutput ( HolderHTLCOutput :: build ( htlc_descriptor) ) ,
4527
+ PackageSolvingData :: HolderHTLCOutput ( HolderHTLCOutput :: build ( htlc_descriptor, conf_height ) ) ,
4515
4528
counterparty_spendable_height,
4516
4529
)
4517
4530
} )
@@ -4691,7 +4704,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
4691
4704
let txid = self . funding . current_holder_commitment_tx . trust ( ) . txid ( ) ;
4692
4705
let vout = htlc_descriptor. htlc . transaction_output_index
4693
4706
. expect ( "Expected transaction output index for non-dust HTLC" ) ;
4694
- let htlc_output = HolderHTLCOutput :: build ( htlc_descriptor) ;
4707
+ let htlc_output = HolderHTLCOutput :: build ( htlc_descriptor, 0 ) ;
4695
4708
if let Some ( htlc_tx) = htlc_output. get_maybe_signed_htlc_tx (
4696
4709
& mut self . onchain_tx_handler , & :: bitcoin:: OutPoint { txid, vout } ,
4697
4710
) {
0 commit comments