record: add func for non-final om route data
What changed, and why it matters
This commit adds a new helper function in LND's code for constructing routing data used in a privacy-preserving messaging feature called 'blinded routes' for onion messages. It is a pure code addition with no obvious security bug, no fix of a vulnerability, and no disclosed security relevance.
No security action required. Review as normal code-quality/API addition if desired.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch introduces NewNonFinalBlindedRouteDataOnionMessage in record/blinded_data.go. It builds a BlindedRouteData struct for non-final hops in an onion-message blinded route, accepting either a next-node public key or a short channel ID, plus optional blinding override and feature vector. The logic mirrors the existing NewNonFinalBlindedRouteData but omits the channel-update and payment-constraints fields that are relevant to payments, which is consistent with BOLT 7/offer-style onion-message routing data. No input validation, serialization, or resource-handling changes are present that would indicate a vulnerability or a security fix.
Changed components
record/blinded_data.goInspect captured patch +42 / −0
diff --git a/record/blinded_data.go b/record/blinded_data.go
index 3d9b17c..8bcc0dd 100644
--- a/record/blinded_data.go
+++ b/record/blinded_data.go
@@ -6,6 +6,7 @@ import (
"io"
"github.com/btcsuite/btcd/btcec/v2"
+ "github.com/lightningnetwork/lnd/fn/v2"
"github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/tlv"
)
@@ -90,6 +91,47 @@ func NewNonFinalBlindedRouteData(chanID lnwire.ShortChannelID,
return info
}
+// NewNonFinalBlindedRouteData creates the data that's provided for hops within
+// a blinded route.
+func NewNonFinalBlindedRouteDataOnionMessage(
+ nextNode fn.Either[*btcec.PublicKey, lnwire.ShortChannelID],
+ blindingOverride *btcec.PublicKey,
+ features *lnwire.FeatureVector) *BlindedRouteData {
+
+ info := fn.ElimEither(
+ nextNode,
+ func(nextNodeID *btcec.PublicKey) *BlindedRouteData {
+ return &BlindedRouteData{
+ NextNodeID: tlv.SomeRecordT(
+ tlv.NewPrimitiveRecord[tlv.TlvType4](
+ nextNodeID,
+ ),
+ ),
+ }
+ },
+ func(chanID lnwire.ShortChannelID) *BlindedRouteData {
+ return &BlindedRouteData{
+ ShortChannelID: tlv.SomeRecordT(
+ tlv.NewRecordT[tlv.TlvType2](chanID),
+ ),
+ }
+ },
+ )
+
+ if blindingOverride != nil {
+ info.NextBlindingOverride = tlv.SomeRecordT(
+ tlv.NewPrimitiveRecord[tlv.TlvType8](blindingOverride))
+ }
+
+ if features != nil {
+ info.Features = tlv.SomeRecordT(
+ tlv.NewRecordT[tlv.TlvType14](*features),
+ )
+ }
+
+ return info
+}
+
// NewFinalHopBlindedRouteData creates the data that's provided for the final
// hop in a blinded route.
func NewFinalHopBlindedRouteData(constraints *PaymentConstraints,
Why this scored 12/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.