From 1f1b33bf85a22931611d90f7cf9386c2fbf2843d Mon Sep 17 00:00:00 2001 From: Roei Erez Date: Wed, 29 Sep 2021 17:24:55 +0300 Subject: [PATCH] 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. --- lnrpc/routerrpc/forward_interceptor.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lnrpc/routerrpc/forward_interceptor.go b/lnrpc/routerrpc/forward_interceptor.go index b3adc48c1..c644cd6b6 100644 --- a/lnrpc/routerrpc/forward_interceptor.go +++ b/lnrpc/routerrpc/forward_interceptor.go @@ -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{