@@ -1775,7 +1775,7 @@ impl ChannelMonitor {
1775
1775
// While all commitment/HTLC-Success/HTLC-Timeout transactions have one input, HTLCs
1776
1776
// can also be resolved in a few other ways which can have more than one output. Thus,
1777
1777
// we call is_resolving_htlc_output here outside of the tx.input.len() == 1 check.
1778
- let mut updated = self . is_resolving_htlc_output ( tx) ;
1778
+ let mut updated = self . is_resolving_htlc_output ( tx, height ) ;
1779
1779
if updated. len ( ) > 0 {
1780
1780
htlc_updated. append ( & mut updated) ;
1781
1781
}
@@ -1893,7 +1893,7 @@ impl ChannelMonitor {
1893
1893
1894
1894
/// Check if any transaction broadcasted is resolving HTLC output by a success or timeout on a local
1895
1895
/// or remote commitment tx, if so send back the source, preimage if found and payment_hash of resolved HTLC
1896
- fn is_resolving_htlc_output ( & mut self , tx : & Transaction ) -> Vec < ( HTLCSource , Option < PaymentPreimage > , PaymentHash ) > {
1896
+ fn is_resolving_htlc_output ( & mut self , tx : & Transaction , height : u32 ) -> Vec < ( HTLCSource , Option < PaymentPreimage > , PaymentHash ) > {
1897
1897
let mut htlc_updated = Vec :: new ( ) ;
1898
1898
1899
1899
' outer_loop: for input in & tx. input {
@@ -1973,7 +1973,15 @@ impl ChannelMonitor {
1973
1973
payment_preimage. 0 . copy_from_slice ( & input. witness [ 1 ] ) ;
1974
1974
htlc_updated. push ( ( source, Some ( payment_preimage) , payment_hash) ) ;
1975
1975
} else {
1976
- htlc_updated. push ( ( source, None , payment_hash) ) ;
1976
+ log_trace ! ( 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 ) ;
1977
+ match self . htlc_updated_waiting_threshold_conf . entry ( height + HTLC_FAIL_ANTI_REORG_DELAY - 1 ) {
1978
+ hash_map:: Entry :: Occupied ( mut entry) => {
1979
+ entry. get_mut ( ) . push ( ( source, None , payment_hash) ) ;
1980
+ }
1981
+ hash_map:: Entry :: Vacant ( entry) => {
1982
+ entry. insert ( vec ! [ ( source, None , payment_hash) ] ) ;
1983
+ }
1984
+ }
1977
1985
}
1978
1986
}
1979
1987
}
0 commit comments