mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-12-08 11:53:16 +01:00
contractcourt+switch: keep channels with timed-out initiated htlcs.
This commit enables the user to specify he is not interested in automatically close channels with pending payments that their corresponding htlcs have timed-out. By requiring a configurable grace period uptime of our node before closing such channels, we give a chance to the other node to properly cancel the htlc and avoid unnecessary on-chain transaction. In mobile it is very important for the user experience as otherwise channels will be force closed more frequently.
This commit is contained in:
@@ -460,6 +460,18 @@ func (s *Switch) UpdateForwardingPolicies(
|
||||
s.indexMtx.RUnlock()
|
||||
}
|
||||
|
||||
// IsForwardedHTLC checks for a given channel and htlc index if it is related
|
||||
// to an opened circuit that represents a forwarded payment.
|
||||
func (s *Switch) IsForwardedHTLC(chanID lnwire.ShortChannelID,
|
||||
htlcIndex uint64) bool {
|
||||
|
||||
circuit := s.circuits.LookupOpenCircuit(channeldb.CircuitKey{
|
||||
ChanID: chanID,
|
||||
HtlcID: htlcIndex,
|
||||
})
|
||||
return circuit != nil && circuit.Incoming.ChanID != hop.Source
|
||||
}
|
||||
|
||||
// forward is used in order to find next channel link and apply htlc update.
|
||||
// Also this function is used by channel links itself in order to forward the
|
||||
// update after it has been included in the channel.
|
||||
|
||||
Reference in New Issue
Block a user