From 7265e4c9b0ce6e9cff58eae8a424d3c7daea6416 Mon Sep 17 00:00:00 2001 From: Carla Kirk-Cohen Date: Fri, 27 Jan 2023 14:19:56 -0500 Subject: [PATCH] htlcswitch: add incoming amount and to decode hop iterator request When we have payments inside of a blinded route, we need to know the incoming amount to be able to back-calculate the amount that we need to forward using the forwarding parameters provided in the blinded route encrypted data. This commit adds the payment amount to our DecodeHopIteratorRequest so that it can be threaded down to payment forwarding information creation in later commits. --- htlcswitch/hop/iterator.go | 9 +++++---- htlcswitch/link.go | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/htlcswitch/hop/iterator.go b/htlcswitch/hop/iterator.go index 55ec6032f..71d8e1b9c 100644 --- a/htlcswitch/hop/iterator.go +++ b/htlcswitch/hop/iterator.go @@ -175,10 +175,11 @@ func (p *OnionProcessor) ReconstructHopIterator(r io.Reader, rHash []byte) ( // packet, perform sphinx replay detection, and schedule the entry for garbage // collection. type DecodeHopIteratorRequest struct { - OnionReader io.Reader - RHash []byte - IncomingCltv uint32 - BlindingPoint *btcec.PublicKey + OnionReader io.Reader + RHash []byte + IncomingCltv uint32 + IncomingAmount lnwire.MilliSatoshi + BlindingPoint *btcec.PublicKey } // DecodeHopIteratorResponse encapsulates the outcome of a batched sphinx onion diff --git a/htlcswitch/link.go b/htlcswitch/link.go index 2c6b0b5e4..c06ca5324 100644 --- a/htlcswitch/link.go +++ b/htlcswitch/link.go @@ -3160,10 +3160,11 @@ func (l *channelLink) processRemoteAdds(fwdPkg *channeldb.FwdPkg, onionReader := bytes.NewReader(pd.OnionBlob) req := hop.DecodeHopIteratorRequest{ - OnionReader: onionReader, - RHash: pd.RHash[:], - IncomingCltv: pd.Timeout, - BlindingPoint: pd.BlindingPoint, + OnionReader: onionReader, + RHash: pd.RHash[:], + IncomingCltv: pd.Timeout, + IncomingAmount: pd.Amount, + BlindingPoint: pd.BlindingPoint, } decodeReqs = append(decodeReqs, req)