@@ -1786,7 +1786,7 @@ impl ChannelMonitor {
1786
1786
// While all commitment/HTLC-Success/HTLC-Timeout transactions have one input, HTLCs
1787
1787
// can also be resolved in a few other ways which can have more than one output. Thus,
1788
1788
// we call is_resolving_htlc_output here outside of the tx.input.len() == 1 check.
1789
- let mut updated = self . is_resolving_htlc_output ( tx) ;
1789
+ let mut updated = self . is_resolving_htlc_output ( tx, height ) ;
1790
1790
if updated. len ( ) > 0 {
1791
1791
htlc_updated. append ( & mut updated) ;
1792
1792
}
@@ -1904,7 +1904,7 @@ impl ChannelMonitor {
1904
1904
1905
1905
/// Check if any transaction broadcasted is resolving HTLC output by a success or timeout on a local
1906
1906
/// or remote commitment tx, if so send back the source, preimage if found and payment_hash of resolved HTLC
1907
- fn is_resolving_htlc_output ( & mut self , tx : & Transaction ) -> Vec < ( HTLCSource , Option < PaymentPreimage > , PaymentHash ) > {
1907
+ fn is_resolving_htlc_output ( & mut self , tx : & Transaction , height : u32 ) -> Vec < ( HTLCSource , Option < PaymentPreimage > , PaymentHash ) > {
1908
1908
let mut htlc_updated = Vec :: new ( ) ;
1909
1909
1910
1910
' outer_loop: for input in & tx. input {
@@ -1984,7 +1984,15 @@ impl ChannelMonitor {
1984
1984
payment_preimage. 0 . copy_from_slice ( & input. witness [ 1 ] ) ;
1985
1985
htlc_updated. push ( ( source, Some ( payment_preimage) , payment_hash) ) ;
1986
1986
} else {
1987
- htlc_updated. push ( ( source, None , payment_hash) ) ;
1987
+ log_info ! ( self , "Failing HTLC with payment_hash {} timeout by a spend tx, waiting confirmation until {} height" , log_bytes!( payment_hash. 0 ) , height + HTLC_FAIL_ANTI_REORG_DELAY - 1 ) ;
1988
+ match self . htlc_updated_waiting_threshold_conf . entry ( height + HTLC_FAIL_ANTI_REORG_DELAY - 1 ) {
1989
+ hash_map:: Entry :: Occupied ( mut entry) => {
1990
+ entry. get_mut ( ) . push ( ( source, None , payment_hash) ) ;
1991
+ }
1992
+ hash_map:: Entry :: Vacant ( entry) => {
1993
+ entry. insert ( vec ! [ ( source, None , payment_hash) ] ) ;
1994
+ }
1995
+ }
1988
1996
}
1989
1997
}
1990
1998
}
0 commit comments