@@ -243,15 +243,6 @@ pub const ANTI_REORG_DELAY: u32 = 6;
243
243
/// in a race condition between the user connecting a block (which would fail it) and the user
244
244
/// providing us the preimage (which would claim it).
245
245
pub ( crate ) const HTLC_FAIL_BACK_BUFFER : u32 = CLTV_CLAIM_BUFFER + LATENCY_GRACE_PERIOD_BLOCKS ;
246
- /// Number of blocks before an inbound HTLC expires at which we fail it backwards.
247
- ///
248
- /// If we have forwarded an HTLC to a peer and they have not claimed it on or off-chain by the
249
- /// time the previous hop's HTLC timeout expires, we're probably going to lose the inbound HTLC.
250
- /// Instead of also losing the channel, we fail the HTLC backwards.
251
- ///
252
- /// To give us some buffer in case we're slow to process blocks, we fail a few blocks before the
253
- /// timeout officially expires to ensure we fail back before our counterparty force closes.
254
- pub ( crate ) const TIMEOUT_FAIL_BACK_BUFFER : u32 = 3 ;
255
246
256
247
// TODO(devrandom) replace this with HolderCommitmentTransaction
257
248
#[ derive( Clone , PartialEq , Eq ) ]
@@ -3531,7 +3522,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
3531
3522
}
3532
3523
}
3533
3524
3534
- // Fail back HTLCs on backwards channels if they expire within `TIMEOUT_FAIL_BACK_BUFFER `
3525
+ // Fail back HTLCs on backwards channels if they expire within `LATENCY_GRACE_PERIOD_BLOCKS `
3535
3526
// blocks. If we haven't seen the preimage for an HTLC by the time the previous hop's
3536
3527
// timeout expires, we've lost that HTLC, so we might as well fail it back instead of having our
3537
3528
// counterparty force-close the channel.
@@ -3548,7 +3539,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
3548
3539
HTLCSource :: PreviousHopData ( HTLCPreviousHopData { htlc_id, cltv_expiry: Some ( cltv_expiry) , .. } ) if !self . failed_back_htlc_ids. contains( htlc_id) => ( * cltv_expiry, * htlc_id) ,
3549
3540
_ => continue ,
3550
3541
} ;
3551
- if cltv_expiry <= height + TIMEOUT_FAIL_BACK_BUFFER {
3542
+ if cltv_expiry <= height + LATENCY_GRACE_PERIOD_BLOCKS {
3552
3543
let duplicate_event = self . pending_monitor_events. iter( ) . any(
3553
3544
|update| if let & MonitorEvent :: HTLCEvent ( ref upd) = update {
3554
3545
upd. source == * source
0 commit comments