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.
This commit is contained in:
Carla Kirk-Cohen
2024-04-02 11:11:35 -04:00
parent 2029a06918
commit 6d41037628

View File

@@ -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