• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

lightningnetwork / lnd / 21485572389

29 Jan 2026 04:09PM UTC coverage: 65.247% (+0.2%) from 65.074%
21485572389

Pull #10089

github

web-flow
Merge 22d34d15e into 19b2ad797
Pull Request #10089: Onion message forwarding

1152 of 1448 new or added lines in 23 files covered. (79.56%)

4109 existing lines in 29 files now uncovered.

139515 of 213825 relevant lines covered (65.25%)

20529.09 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

66.67
/record/hop.go
1
package record
2

3
import (
4
        "github.com/btcsuite/btcd/btcec/v2"
5
        "github.com/lightningnetwork/lnd/tlv"
6
)
7

8
const (
9
        // Onion Routing Packet types.
10

11
        // AmtOnionType is the type used in the onion to reference the amount to
12
        // send to the next hop.
13
        AmtOnionType tlv.Type = 2
14

15
        // LockTimeTLV is the type used in the onion to reference the CLTV
16
        // value that should be used for the next hop's HTLC.
17
        LockTimeOnionType tlv.Type = 4
18

19
        // NextHopOnionType is the type used in the onion to reference the ID
20
        // of the next hop.
21
        NextHopOnionType tlv.Type = 6
22

23
        // EncryptedDataOnionType is the type used to include encrypted data
24
        // provided by the receiver in the onion for use in blinded paths.
25
        EncryptedDataOnionType tlv.Type = 10
26

27
        // BlindingPointOnionType is the type used to include receiver provided
28
        // ephemeral keys in the onion that are used in blinded paths.
29
        BlindingPointOnionType tlv.Type = 12
30

31
        // MetadataOnionType is the type used in the onion for the payment
32
        // metadata.
33
        MetadataOnionType tlv.Type = 16
34

35
        // TotalAmtMsatBlindedType is the type used in the onion for the total
36
        // amount field that is included in the final hop for blinded payments.
37
        TotalAmtMsatBlindedType tlv.Type = 18
38

39
        // Onion Message Packet types.
40

41
        // ReplyPathType is the type used in the onion message to indicate the
42
        // blinded path to be used for replies.
43
        ReplyPathType tlv.Type = 2
44

45
        // EncryptedDataTLVType is the type used in the onion message to
46
        // include encrypted data in the onion for use in blinded paths.
47
        EncryptedDataTLVType tlv.Type = 4
48

49
        // InvoiceRequestNamespaceType is the type used in the onion message to
50
        // include invoice requests.
51
        InvoiceRequestNamespaceType tlv.Type = 64
52

53
        // InvoiceNamespaceType is the type used in the onion message to include
54
        // invoices.
55
        InvoiceNamespaceType tlv.Type = 66
56

57
        // InvoiceErrorNamespaceType is the type used in the onion message to
58
        // include invoice errors.
59
        InvoiceErrorNamespaceType tlv.Type = 68
60
)
61

62
// NewAmtToFwdRecord creates a tlv.Record that encodes the amount_to_forward
63
// (type 2) for an onion payload.
64
func NewAmtToFwdRecord(amt *uint64) tlv.Record {
1,003✔
65
        return tlv.MakeDynamicRecord(
1,003✔
66
                AmtOnionType, amt, func() uint64 {
1,316✔
67
                        return tlv.SizeTUint64(*amt)
313✔
68
                },
313✔
69
                tlv.ETUint64, tlv.DTUint64,
70
        )
71
}
72

73
// NewLockTimeRecord creates a tlv.Record that encodes the outgoing_cltv_value
74
// (type 4) for an onion payload.
75
func NewLockTimeRecord(lockTime *uint32) tlv.Record {
1,003✔
76
        return tlv.MakeDynamicRecord(
1,003✔
77
                LockTimeOnionType, lockTime, func() uint64 {
1,316✔
78
                        return tlv.SizeTUint32(*lockTime)
313✔
79
                },
313✔
80
                tlv.ETUint32, tlv.DTUint32,
81
        )
82
}
83

84
// NewNextHopIDRecord creates a tlv.Record that encodes the short_channel_id
85
// (type 6) for an onion payload.
86
func NewNextHopIDRecord(cid *uint64) tlv.Record {
741✔
87
        return tlv.MakePrimitiveRecord(NextHopOnionType, cid)
741✔
88
}
741✔
89

90
// NewEncryptedDataRecord creates a tlv.Record that encodes the encrypted_data
91
// (type 10) record for an onion payload.
92
func NewEncryptedDataRecord(data *[]byte) tlv.Record {
735✔
93
        return tlv.MakePrimitiveRecord(EncryptedDataOnionType, data)
735✔
94
}
735✔
95

96
// NewEncryptedRecipientDataRecord creates a tlv.Record that encodes the
97
// encrypted_data (type 4) record for an onion message payload.
NEW
98
func NewEncryptedRecipientDataRecord(data *[]byte) tlv.Record {
×
NEW
99
        return tlv.MakePrimitiveRecord(EncryptedDataTLVType, data)
×
NEW
100
}
×
101

102
// NewReplyPathRecord creates a tlv.Record that encodes the reply_path (type 2)
103
// record for an onion message payload.
NEW
104
func NewReplyPathRecord(data *[]byte) tlv.Record {
×
NEW
105
        return tlv.MakePrimitiveRecord(ReplyPathType, data)
×
NEW
106
}
×
107

108
// NewInvoiceRequestRecord creates a tlv.Record that encodes the
109
// invoice_request (type 64) record for an onion message payload.
NEW
110
func NewInvoiceRequestRecord(data *[]byte) tlv.Record {
×
NEW
111
        return tlv.MakePrimitiveRecord(InvoiceRequestNamespaceType, data)
×
NEW
112
}
×
113

114
// NewInvoiceRecord creates a tlv.Record that encodes the
115
// invoice (type 66) record for an onion message payload.
NEW
116
func NewInvoiceRecord(data *[]byte) tlv.Record {
×
NEW
117
        return tlv.MakePrimitiveRecord(InvoiceNamespaceType, data)
×
NEW
118
}
×
119

120
// NewInvoiceErrorRecord creates a tlv.Record that encodes the
121
// invoice_error (type 68) record for an onion message payload.
NEW
122
func NewInvoiceErrorRecord(data *[]byte) tlv.Record {
×
NEW
123
        return tlv.MakePrimitiveRecord(InvoiceErrorNamespaceType, data)
×
NEW
124
}
×
125

126
// NewBlindingPointRecord creates a tlv.Record that encodes the blinding_point
127
// (type 12) record for an onion payload.
128
func NewBlindingPointRecord(point **btcec.PublicKey) tlv.Record {
697✔
129
        return tlv.MakePrimitiveRecord(BlindingPointOnionType, point)
697✔
130
}
697✔
131

132
// NewMetadataRecord creates a tlv.Record that encodes the metadata (type 10)
133
// for an onion payload.
134
func NewMetadataRecord(metadata *[]byte) tlv.Record {
928✔
135
        return tlv.MakeDynamicRecord(
928✔
136
                MetadataOnionType, metadata,
928✔
137
                func() uint64 {
1,102✔
138
                        return uint64(len(*metadata))
174✔
139
                },
174✔
140
                tlv.EVarBytes, tlv.DVarBytes,
141
        )
142
}
143

144
// NewTotalAmtMsatBlinded creates a tlv.Record that encodes the
145
// total_amount_msat for the final an onion payload within a blinded route.
146
func NewTotalAmtMsatBlinded(amt *uint64) tlv.Record {
713✔
147
        return tlv.MakeDynamicRecord(
713✔
148
                TotalAmtMsatBlindedType, amt, func() uint64 {
740✔
149
                        return tlv.SizeTUint64(*amt)
27✔
150
                },
27✔
151
                tlv.ETUint64, tlv.DTUint64,
152
        )
153
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc