routerrpc: de-duplicate htlc held by interceptor

This commit ensures htlcs currently held by the interceptor
Are not sent again. This prevents potential races in the user code that
may lead to loosing funds.
This commit is contained in:
Roei Erez authored and Olaoluwa Osuntokun committed 2021-10-28 16:16:50 -07:00
1 parent b45c4ea7e3
commit 1f1b33bf85
1 file changed
+5
+5
View File
@@ -150,6 +150,11 @@ func (r *forwardInterceptor) holdAndForwardToClient(
htlc := forward.Packet()
inKey := htlc.IncomingCircuit
// ignore already held htlcs.
if _, ok := r.holdForwards[inKey]; ok {
return nil
}
// First hold the forward, then send to client.
r.holdForwards[inKey] = forward
interceptionRequest := &ForwardHtlcInterceptRequest{