From 6d410376288c73f2ed82a5213b47cfa6bf4ae846 Mon Sep 17 00:00:00 2001 From: Carla Kirk-Cohen Date: Tue, 2 Apr 2024 11:11:35 -0400 Subject: [PATCH] htlcswitch: set forwarding information from encrypted data If we received a payload with a encrypted data point set, our forwarding information should be set from the information in our encrypted blob. This behavior is the same for introduction and relying nodes in a blinded route. --- htlcswitch/hop/iterator.go | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/htlcswitch/hop/iterator.go b/htlcswitch/hop/iterator.go index e14954723..df6f5aac7 100644 --- a/htlcswitch/hop/iterator.go +++ b/htlcswitch/hop/iterator.go @@ -106,10 +106,27 @@ func (r *sphinxHopIterator) HopPayload() (*Payload, error) { // Otherwise, if this is the TLV payload, then we'll make a new stream // to decode only what we need to make routing decisions. case sphinx.PayloadTLV: - payload, _, err := NewPayloadFromReader( + isFinal := r.processedPacket.Action == sphinx.ExitNode + payload, parsed, err := NewPayloadFromReader( bytes.NewReader(r.processedPacket.Payload.Payload), - r.processedPacket.Action == sphinx.ExitNode, + isFinal, ) + if err != nil { + return nil, err + } + + // If we had an encrypted data payload present, pull out our + // forwarding info from the blob. + if payload.encryptedData != nil { + fwdInfo, err := r.blindingKit.DecryptAndValidateFwdInfo( + payload, isFinal, parsed, + ) + if err != nil { + return nil, err + } + + payload.FwdInfo = *fwdInfo + } return payload, err