Merge pull request #3876 from breez/allow-timeouted-initiated-htlc
contractcourt: keep channels with timed-out initiated htlcs.
This commit is contained in:
9 files changed
+204
-40
No files matched your search
@@ -459,6 +459,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.
|
||||
|
||||
@@ -336,6 +336,10 @@ func TestSwitchForward(t *testing.T) {
|
||||
t.Fatal("wrong amount of circuits")
|
||||
}
|
||||
|
||||
if !s.IsForwardedHTLC(bobChannelLink.ShortChanID(), 0) {
|
||||
t.Fatal("htlc should be identified as forwarded")
|
||||
}
|
||||
|
||||
// Create settle request pretending that bob link handled the add htlc
|
||||
// request and sent the htlc settle request back. This request should
|
||||
// be forwarder back to Alice link.
|
||||
@@ -2120,6 +2124,9 @@ func TestSwitchSendPayment(t *testing.T) {
|
||||
t.Fatalf("unable obfuscate failure: %v", err)
|
||||
}
|
||||
|
||||
if s.IsForwardedHTLC(aliceChannelLink.ShortChanID(), update.ID) {
|
||||
t.Fatal("htlc should be identified as not forwarded")
|
||||
}
|
||||
packet := &htlcPacket{
|
||||
outgoingChanID: aliceChannelLink.ShortChanID(),
|
||||
outgoingHTLCID: 0,
|
||||
|
||||
Reference in new issue
Block a user