@@ -596,13 +596,20 @@ pub enum Balance {
596
596
#[ derive( PartialEq ) ]
597
597
struct IrrevocablyResolvedHTLC {
598
598
commitment_tx_output_idx : u32 ,
599
+ /// The txid of the transaction which resolved the HTLC, this may be a commitment,
600
+ /// HTLC-Success, or HTLC-Timeout transaction.
601
+ resolving_txid : Option < Txid > ,
602
+ /// The amount of the output for this HTLC in `resolving_txid`.
603
+ onchain_value_satoshis : Option < u64 > ,
599
604
/// Only set if the HTLC claim was ours using a payment preimage
600
605
payment_preimage : Option < PaymentPreimage > ,
601
606
}
602
607
603
608
impl_writeable_tlv_based ! ( IrrevocablyResolvedHTLC , {
604
609
( 0 , commitment_tx_output_idx, required) ,
610
+ ( 1 , resolving_txid, option) ,
605
611
( 2 , payment_preimage, option) ,
612
+ ( 3 , onchain_value_satoshis, option) ,
606
613
} ) ;
607
614
608
615
/// A ChannelMonitor handles chain events (blocks connected and disconnected) and generates
@@ -2675,7 +2682,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2675
2682
// Produce actionable events from on-chain events having reached their threshold.
2676
2683
for entry in onchain_events_reaching_threshold_conf. drain ( ..) {
2677
2684
match entry. event {
2678
- OnchainEvent :: HTLCUpdate { ref source, payment_hash, htlc_value_satoshis, commitment_tx_output_idx, .. } => {
2685
+ OnchainEvent :: HTLCUpdate { ref source, payment_hash, htlc_value_satoshis, commitment_tx_output_idx, onchain_value_satoshis } => {
2679
2686
// Check for duplicate HTLC resolutions.
2680
2687
#[ cfg( debug_assertions) ]
2681
2688
{
@@ -2701,7 +2708,10 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2701
2708
htlc_value_satoshis,
2702
2709
} ) ) ;
2703
2710
if let Some ( idx) = commitment_tx_output_idx {
2704
- self . htlcs_resolved_on_chain . push ( IrrevocablyResolvedHTLC { commitment_tx_output_idx : idx, payment_preimage : None } ) ;
2711
+ self . htlcs_resolved_on_chain . push ( IrrevocablyResolvedHTLC {
2712
+ commitment_tx_output_idx : idx, resolving_txid : Some ( entry. txid ) ,
2713
+ payment_preimage : None , onchain_value_satoshis,
2714
+ } ) ;
2705
2715
}
2706
2716
} ,
2707
2717
OnchainEvent :: MaturingOutput { descriptor } => {
@@ -2710,8 +2720,10 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2710
2720
outputs : vec ! [ descriptor]
2711
2721
} ) ;
2712
2722
} ,
2713
- OnchainEvent :: HTLCSpendConfirmation { commitment_tx_output_idx, preimage, .. } => {
2714
- self . htlcs_resolved_on_chain . push ( IrrevocablyResolvedHTLC { commitment_tx_output_idx, payment_preimage : preimage } ) ;
2723
+ OnchainEvent :: HTLCSpendConfirmation { commitment_tx_output_idx, preimage, onchain_value_satoshis, .. } => {
2724
+ self . htlcs_resolved_on_chain . push ( IrrevocablyResolvedHTLC {
2725
+ commitment_tx_output_idx, resolving_txid : Some ( entry. txid ) ,
2726
+ payment_preimage : preimage, onchain_value_satoshis } ) ;
2715
2727
} ,
2716
2728
OnchainEvent :: FundingSpendConfirmation { commitment_tx_to_counterparty_output, .. } => {
2717
2729
self . funding_spend_confirmed = Some ( entry. txid ) ;
0 commit comments