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
2021-09-29 17:24:55 +03:00
committed by Olaoluwa Osuntokun
parent b45c4ea7e3
commit 1f1b33bf85

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{