@@ -594,13 +594,20 @@ pub enum Balance {
594
594
#[ derive( PartialEq ) ]
595
595
struct IrrevocablyResolvedHTLC {
596
596
commitment_tx_output_idx : u32 ,
597
+ /// The txid of the transaction which resolved the HTLC, this may be a commitment,
598
+ /// HTLC-Success, or HTLC-Timeout transaction.
599
+ resolving_txid : Option < Txid > ,
600
+ /// The amount of the output for this HTLC in `resolving_txid`.
601
+ onchain_value_satoshis : Option < u64 > ,
597
602
/// Only set if the HTLC claim was ours using a payment preimage
598
603
payment_preimage : Option < PaymentPreimage > ,
599
604
}
600
605
601
606
impl_writeable_tlv_based ! ( IrrevocablyResolvedHTLC , {
602
607
( 0 , commitment_tx_output_idx, required) ,
608
+ ( 1 , resolving_txid, option) ,
603
609
( 2 , payment_preimage, option) ,
610
+ ( 3 , onchain_value_satoshis, option) ,
604
611
} ) ;
605
612
606
613
/// A ChannelMonitor handles chain events (blocks connected and disconnected) and generates
@@ -2631,7 +2638,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2631
2638
// Produce actionable events from on-chain events having reached their threshold.
2632
2639
for entry in onchain_events_reaching_threshold_conf. drain ( ..) {
2633
2640
match entry. event {
2634
- OnchainEvent :: HTLCUpdate { ref source, payment_hash, htlc_value_satoshis, commitment_tx_output_idx, .. } => {
2641
+ OnchainEvent :: HTLCUpdate { ref source, payment_hash, htlc_value_satoshis, commitment_tx_output_idx, onchain_value_satoshis } => {
2635
2642
// Check for duplicate HTLC resolutions.
2636
2643
#[ cfg( debug_assertions) ]
2637
2644
{
@@ -2657,7 +2664,10 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2657
2664
htlc_value_satoshis,
2658
2665
} ) ) ;
2659
2666
if let Some ( idx) = commitment_tx_output_idx {
2660
- self . htlcs_resolved_on_chain . push ( IrrevocablyResolvedHTLC { commitment_tx_output_idx : idx, payment_preimage : None } ) ;
2667
+ self . htlcs_resolved_on_chain . push ( IrrevocablyResolvedHTLC {
2668
+ commitment_tx_output_idx : idx, resolving_txid : Some ( entry. txid ) ,
2669
+ payment_preimage : None , onchain_value_satoshis,
2670
+ } ) ;
2661
2671
}
2662
2672
} ,
2663
2673
OnchainEvent :: MaturingOutput { descriptor } => {
@@ -2666,8 +2676,10 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2666
2676
outputs : vec ! [ descriptor]
2667
2677
} ) ;
2668
2678
} ,
2669
- OnchainEvent :: HTLCSpendConfirmation { commitment_tx_output_idx, preimage, .. } => {
2670
- self . htlcs_resolved_on_chain . push ( IrrevocablyResolvedHTLC { commitment_tx_output_idx, payment_preimage : preimage } ) ;
2679
+ OnchainEvent :: HTLCSpendConfirmation { commitment_tx_output_idx, preimage, onchain_value_satoshis, .. } => {
2680
+ self . htlcs_resolved_on_chain . push ( IrrevocablyResolvedHTLC {
2681
+ commitment_tx_output_idx, resolving_txid : Some ( entry. txid ) ,
2682
+ payment_preimage : preimage, onchain_value_satoshis } ) ;
2671
2683
} ,
2672
2684
OnchainEvent :: FundingSpendConfirmation { commitment_tx_to_counterparty_output, .. } => {
2673
2685
self . funding_spend_confirmed = Some ( entry. txid ) ;
0 commit comments