From 4f2c75f62047579f249ed5914042a0cc6337f342 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Thu, 11 Jul 2024 19:01:04 +0200 Subject: [PATCH] htlcswitch: also set packet amount on modified forward This fixes an issue where the switch's forwarding logic would think the bandwidth to forward an HTLC was insufficient for a custom channel HTLC, because we only overwrote the HTLC's amount and not the packet's (which is just a short cut struct member anyway). --- htlcswitch/interceptable_switch.go | 1 + itest/lnd_forward_interceptor_test.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/htlcswitch/interceptable_switch.go b/htlcswitch/interceptable_switch.go index 1060867a7..67832a985 100644 --- a/htlcswitch/interceptable_switch.go +++ b/htlcswitch/interceptable_switch.go @@ -658,6 +658,7 @@ func (f *interceptedForward) ResumeModified( switch htlc := f.packet.htlc.(type) { case *lnwire.UpdateAddHTLC: outgoingAmountMsat.WhenSome(func(amount lnwire.MilliSatoshi) { + f.packet.amount = amount htlc.Amount = amount }) diff --git a/itest/lnd_forward_interceptor_test.go b/itest/lnd_forward_interceptor_test.go index 00050cec6..3b1e61e22 100644 --- a/itest/lnd_forward_interceptor_test.go +++ b/itest/lnd_forward_interceptor_test.go @@ -407,7 +407,7 @@ func testForwardInterceptorModifiedHtlc(ht *lntest.HarnessTest) { customRecords[crKey] = crValue action := routerrpc.ResolveHoldForwardAction_RESUME_MODIFIED - newOutgoingAmountMsat := packet.OutgoingAmountMsat + 4000 + newOutgoingAmountMsat := packet.OutgoingAmountMsat err := bobInterceptor.Send(&routerrpc.ForwardHtlcInterceptResponse{ IncomingCircuitKey: packet.IncomingCircuitKey,