@@ -360,7 +360,7 @@ enum OnchainEvent {
360
360
onchain_value_satoshis : Option < u64 > ,
361
361
/// None in the second case, above, ie when there is no relevant output in the commitment
362
362
/// transaction which appeared on chain.
363
- input_idx : Option < u32 > ,
363
+ commitment_tx_output_idx : Option < u32 > ,
364
364
} ,
365
365
MaturingOutput {
366
366
descriptor : SpendableOutputDescriptor ,
@@ -381,7 +381,7 @@ enum OnchainEvent {
381
381
/// * a revoked-state HTLC transaction was broadcasted, which was claimed by the revocation
382
382
/// signature.
383
383
HTLCSpendConfirmation {
384
- input_idx : u32 ,
384
+ commitment_tx_output_idx : u32 ,
385
385
/// If the claim was made by either party with a preimage, this is filled in
386
386
preimage : Option < PaymentPreimage > ,
387
387
/// If the claim was made by us on an inbound HTLC against a local commitment transaction,
@@ -425,7 +425,7 @@ impl_writeable_tlv_based_enum_upgradable!(OnchainEvent,
425
425
( 0 , source, required) ,
426
426
( 1 , onchain_value_satoshis, option) ,
427
427
( 2 , payment_hash, required) ,
428
- ( 3 , input_idx , option) ,
428
+ ( 3 , commitment_tx_output_idx , option) ,
429
429
} ,
430
430
( 1 , MaturingOutput ) => {
431
431
( 0 , descriptor, required) ,
@@ -434,7 +434,7 @@ impl_writeable_tlv_based_enum_upgradable!(OnchainEvent,
434
434
( 0 , on_local_output_csv, option) ,
435
435
} ,
436
436
( 5 , HTLCSpendConfirmation ) => {
437
- ( 0 , input_idx , required) ,
437
+ ( 0 , commitment_tx_output_idx , required) ,
438
438
( 2 , preimage, option) ,
439
439
( 4 , on_to_local_output_csv, option) ,
440
440
} ,
@@ -568,13 +568,13 @@ pub enum Balance {
568
568
/// An HTLC which has been irrevocably resolved on-chain, and has reached ANTI_REORG_DELAY.
569
569
#[ derive( PartialEq ) ]
570
570
struct IrrevocablyResolvedHTLC {
571
- input_idx : u32 ,
571
+ commitment_tx_output_idx : u32 ,
572
572
/// Only set if the HTLC claim was ours using a payment preimage
573
573
payment_preimage : Option < PaymentPreimage > ,
574
574
}
575
575
576
576
impl_writeable_tlv_based ! ( IrrevocablyResolvedHTLC , {
577
- ( 0 , input_idx , required) ,
577
+ ( 0 , commitment_tx_output_idx , required) ,
578
578
( 2 , payment_preimage, option) ,
579
579
} ) ;
580
580
@@ -1391,18 +1391,18 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
1391
1391
macro_rules! walk_htlcs {
1392
1392
( $holder_commitment: expr, $htlc_iter: expr) => {
1393
1393
for htlc in $htlc_iter {
1394
- if let Some ( htlc_input_idx ) = htlc. transaction_output_index {
1394
+ if let Some ( htlc_commitment_tx_output_idx ) = htlc. transaction_output_index {
1395
1395
if let Some ( conf_thresh) = us. onchain_events_awaiting_threshold_conf. iter( ) . find_map( |event| {
1396
1396
if let OnchainEvent :: MaturingOutput { descriptor: SpendableOutputDescriptor :: DelayedPaymentOutput ( descriptor) } = & event. event {
1397
- if descriptor. outpoint. index as u32 == htlc_input_idx { Some ( event. confirmation_threshold( ) ) } else { None }
1397
+ if descriptor. outpoint. index as u32 == htlc_commitment_tx_output_idx { Some ( event. confirmation_threshold( ) ) } else { None }
1398
1398
} else { None }
1399
1399
} ) {
1400
1400
debug_assert!( $holder_commitment) ;
1401
1401
res. push( Balance :: ClaimableAwaitingConfirmations {
1402
1402
claimable_amount_satoshis: htlc. amount_msat / 1000 ,
1403
1403
confirmation_height: conf_thresh,
1404
1404
} ) ;
1405
- } else if us. htlcs_resolved_on_chain. iter( ) . any( |v| v. input_idx == htlc_input_idx ) {
1405
+ } else if us. htlcs_resolved_on_chain. iter( ) . any( |v| v. commitment_tx_output_idx == htlc_commitment_tx_output_idx ) {
1406
1406
// Funding transaction spends should be fully confirmed by the time any
1407
1407
// HTLC transactions are resolved, unless we're talking about a holder
1408
1408
// commitment tx, whose resolution is delayed until the CSV timeout is
@@ -1414,8 +1414,9 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
1414
1414
// indicating we have spent this HTLC with a timeout, claiming it back
1415
1415
// and awaiting confirmations on it.
1416
1416
let htlc_update_pending = us. onchain_events_awaiting_threshold_conf. iter( ) . find_map( |event| {
1417
- if let OnchainEvent :: HTLCUpdate { input_idx: Some ( input_idx) , .. } = event. event {
1418
- if input_idx == htlc_input_idx { Some ( event. confirmation_threshold( ) ) } else { None }
1417
+ if let OnchainEvent :: HTLCUpdate { commitment_tx_output_idx: Some ( commitment_tx_output_idx) , .. } = event. event {
1418
+ if commitment_tx_output_idx == htlc_commitment_tx_output_idx {
1419
+ Some ( event. confirmation_threshold( ) ) } else { None }
1419
1420
} else { None }
1420
1421
} ) ;
1421
1422
if let Some ( conf_thresh) = htlc_update_pending {
@@ -1436,8 +1437,8 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
1436
1437
// preimage, we lost funds to our counterparty! We will then continue
1437
1438
// to show it as ContentiousClaimable until ANTI_REORG_DELAY.
1438
1439
let htlc_spend_pending = us. onchain_events_awaiting_threshold_conf. iter( ) . find_map( |event| {
1439
- if let OnchainEvent :: HTLCSpendConfirmation { input_idx , preimage, .. } = event. event {
1440
- if input_idx == htlc_input_idx {
1440
+ if let OnchainEvent :: HTLCSpendConfirmation { commitment_tx_output_idx , preimage, .. } = event. event {
1441
+ if commitment_tx_output_idx == htlc_commitment_tx_output_idx {
1441
1442
Some ( ( event. confirmation_threshold( ) , preimage. is_some( ) ) )
1442
1443
} else { None }
1443
1444
} else { None }
@@ -1546,7 +1547,7 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
1546
1547
macro_rules! walk_htlcs {
1547
1548
( $holder_commitment: expr, $htlc_iter: expr) => {
1548
1549
for ( htlc, source) in $htlc_iter {
1549
- if us. htlcs_resolved_on_chain. iter( ) . any( |v| Some ( v. input_idx ) == htlc. transaction_output_index) {
1550
+ if us. htlcs_resolved_on_chain. iter( ) . any( |v| Some ( v. commitment_tx_output_idx ) == htlc. transaction_output_index) {
1550
1551
// We should assert that funding_spend_confirmed is_some() here, but we
1551
1552
// have some unit tests which violate HTLC transaction CSVs entirely and
1552
1553
// would fail.
@@ -1557,17 +1558,17 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
1557
1558
// indicating we have spent this HTLC with a timeout, claiming it back
1558
1559
// and awaiting confirmations on it.
1559
1560
let htlc_update_confd = us. onchain_events_awaiting_threshold_conf. iter( ) . any( |event| {
1560
- if let OnchainEvent :: HTLCUpdate { input_idx : Some ( input_idx ) , .. } = event. event {
1561
+ if let OnchainEvent :: HTLCUpdate { commitment_tx_output_idx : Some ( commitment_tx_output_idx ) , .. } = event. event {
1561
1562
// If the HTLC was timed out, we wait for ANTI_REORG_DELAY blocks
1562
1563
// before considering it "no longer pending" - this matches when we
1563
1564
// provide the ChannelManager an HTLC failure event.
1564
- Some ( input_idx ) == htlc. transaction_output_index &&
1565
+ Some ( commitment_tx_output_idx ) == htlc. transaction_output_index &&
1565
1566
us. best_block. height( ) >= event. height + ANTI_REORG_DELAY - 1
1566
- } else if let OnchainEvent :: HTLCSpendConfirmation { input_idx , .. } = event. event {
1567
+ } else if let OnchainEvent :: HTLCSpendConfirmation { commitment_tx_output_idx , .. } = event. event {
1567
1568
// If the HTLC was fulfilled with a preimage, we consider the HTLC
1568
1569
// immediately non-pending, matching when we provide ChannelManager
1569
1570
// the preimage.
1570
- Some ( input_idx ) == htlc. transaction_output_index
1571
+ Some ( commitment_tx_output_idx ) == htlc. transaction_output_index
1571
1572
} else { false }
1572
1573
} ) ;
1573
1574
if !htlc_update_confd {
@@ -1689,7 +1690,7 @@ macro_rules! fail_unbroadcast_htlcs {
1689
1690
source: ( * * source) . clone( ) ,
1690
1691
payment_hash: htlc. payment_hash. clone( ) ,
1691
1692
onchain_value_satoshis: Some ( htlc. amount_msat / 1000 ) ,
1692
- input_idx : None ,
1693
+ commitment_tx_output_idx : None ,
1693
1694
} ,
1694
1695
} ;
1695
1696
log_trace!( $logger, "Failing HTLC with payment_hash {} from {} counterparty commitment tx due to broadcast of {} commitment transaction, waiting for confirmation (at height {})" ,
@@ -2522,7 +2523,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2522
2523
// Produce actionable events from on-chain events having reached their threshold.
2523
2524
for entry in onchain_events_reaching_threshold_conf. drain ( ..) {
2524
2525
match entry. event {
2525
- OnchainEvent :: HTLCUpdate { ref source, payment_hash, onchain_value_satoshis, input_idx } => {
2526
+ OnchainEvent :: HTLCUpdate { ref source, payment_hash, onchain_value_satoshis, commitment_tx_output_idx } => {
2526
2527
// Check for duplicate HTLC resolutions.
2527
2528
#[ cfg( debug_assertions) ]
2528
2529
{
@@ -2546,8 +2547,8 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2546
2547
source : source. clone ( ) ,
2547
2548
onchain_value_satoshis,
2548
2549
} ) ) ;
2549
- if let Some ( idx) = input_idx {
2550
- self . htlcs_resolved_on_chain . push ( IrrevocablyResolvedHTLC { input_idx : idx, payment_preimage : None } ) ;
2550
+ if let Some ( idx) = commitment_tx_output_idx {
2551
+ self . htlcs_resolved_on_chain . push ( IrrevocablyResolvedHTLC { commitment_tx_output_idx : idx, payment_preimage : None } ) ;
2551
2552
}
2552
2553
} ,
2553
2554
OnchainEvent :: MaturingOutput { descriptor } => {
@@ -2556,8 +2557,8 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2556
2557
outputs : vec ! [ descriptor]
2557
2558
} ) ;
2558
2559
} ,
2559
- OnchainEvent :: HTLCSpendConfirmation { input_idx , preimage, .. } => {
2560
- self . htlcs_resolved_on_chain . push ( IrrevocablyResolvedHTLC { input_idx , payment_preimage : preimage } ) ;
2560
+ OnchainEvent :: HTLCSpendConfirmation { commitment_tx_output_idx , preimage, .. } => {
2561
+ self . htlcs_resolved_on_chain . push ( IrrevocablyResolvedHTLC { commitment_tx_output_idx , payment_preimage : preimage } ) ;
2561
2562
} ,
2562
2563
OnchainEvent :: FundingSpendConfirmation { .. } => {
2563
2564
self . funding_spend_confirmed = Some ( entry. txid ) ;
@@ -2826,7 +2827,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2826
2827
self . onchain_events_awaiting_threshold_conf. push( OnchainEventEntry {
2827
2828
txid: tx. txid( ) , height,
2828
2829
event: OnchainEvent :: HTLCSpendConfirmation {
2829
- input_idx : input. previous_output. vout,
2830
+ commitment_tx_output_idx : input. previous_output. vout,
2830
2831
preimage: if accepted_preimage_claim || offered_preimage_claim {
2831
2832
Some ( payment_preimage) } else { None } ,
2832
2833
// If this is a payment to us (!outbound_htlc, above),
@@ -2877,7 +2878,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2877
2878
txid : tx. txid ( ) ,
2878
2879
height,
2879
2880
event : OnchainEvent :: HTLCSpendConfirmation {
2880
- input_idx : input. previous_output . vout ,
2881
+ commitment_tx_output_idx : input. previous_output . vout ,
2881
2882
preimage : Some ( payment_preimage) ,
2882
2883
on_to_local_output_csv : None ,
2883
2884
} ,
@@ -2898,7 +2899,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2898
2899
txid : tx. txid ( ) ,
2899
2900
height,
2900
2901
event : OnchainEvent :: HTLCSpendConfirmation {
2901
- input_idx : input. previous_output . vout ,
2902
+ commitment_tx_output_idx : input. previous_output . vout ,
2902
2903
preimage : Some ( payment_preimage) ,
2903
2904
on_to_local_output_csv : None ,
2904
2905
} ,
@@ -2926,7 +2927,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2926
2927
event : OnchainEvent :: HTLCUpdate {
2927
2928
source, payment_hash,
2928
2929
onchain_value_satoshis : Some ( amount_msat / 1000 ) ,
2929
- input_idx : Some ( input. previous_output . vout ) ,
2930
+ commitment_tx_output_idx : Some ( input. previous_output . vout ) ,
2930
2931
} ,
2931
2932
} ;
2932
2933
log_info ! ( logger, "Failing HTLC with payment_hash {} timeout by a spend tx, waiting for confirmation (at height {})" , log_bytes!( payment_hash. 0 ) , entry. confirmation_threshold( ) ) ;
0 commit comments