@@ -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
@@ -2673,7 +2680,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2673
2680
// Produce actionable events from on-chain events having reached their threshold.
2674
2681
for entry in onchain_events_reaching_threshold_conf. drain ( ..) {
2675
2682
match entry. event {
2676
- OnchainEvent :: HTLCUpdate { ref source, payment_hash, htlc_value_satoshis, commitment_tx_output_idx, .. } => {
2683
+ OnchainEvent :: HTLCUpdate { ref source, payment_hash, htlc_value_satoshis, commitment_tx_output_idx, onchain_value_satoshis } => {
2677
2684
// Check for duplicate HTLC resolutions.
2678
2685
#[ cfg( debug_assertions) ]
2679
2686
{
@@ -2699,7 +2706,10 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2699
2706
htlc_value_satoshis,
2700
2707
} ) ) ;
2701
2708
if let Some ( idx) = commitment_tx_output_idx {
2702
- self . htlcs_resolved_on_chain . push ( IrrevocablyResolvedHTLC { commitment_tx_output_idx : idx, payment_preimage : None } ) ;
2709
+ self . htlcs_resolved_on_chain . push ( IrrevocablyResolvedHTLC {
2710
+ commitment_tx_output_idx : idx, resolving_txid : Some ( entry. txid ) ,
2711
+ payment_preimage : None , onchain_value_satoshis,
2712
+ } ) ;
2703
2713
}
2704
2714
} ,
2705
2715
OnchainEvent :: MaturingOutput { descriptor } => {
@@ -2708,8 +2718,10 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2708
2718
outputs : vec ! [ descriptor]
2709
2719
} ) ;
2710
2720
} ,
2711
- OnchainEvent :: HTLCSpendConfirmation { commitment_tx_output_idx, preimage, .. } => {
2712
- self . htlcs_resolved_on_chain . push ( IrrevocablyResolvedHTLC { commitment_tx_output_idx, payment_preimage : preimage } ) ;
2721
+ OnchainEvent :: HTLCSpendConfirmation { commitment_tx_output_idx, preimage, onchain_value_satoshis, .. } => {
2722
+ self . htlcs_resolved_on_chain . push ( IrrevocablyResolvedHTLC {
2723
+ commitment_tx_output_idx, resolving_txid : Some ( entry. txid ) ,
2724
+ payment_preimage : preimage, onchain_value_satoshis } ) ;
2713
2725
} ,
2714
2726
OnchainEvent :: FundingSpendConfirmation { commitment_tx_to_counterparty_output, .. } => {
2715
2727
self . funding_spend_confirmed = Some ( entry. txid ) ;
0 commit comments