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

lightningnetwork / lnd / 14193549836

01 Apr 2025 10:40AM UTC coverage: 69.046% (+0.007%) from 69.039%
14193549836

Pull #9665

github

web-flow
Merge e8825f209 into b01f4e514
Pull Request #9665: kvdb: bump etcd libs to v3.5.12

133439 of 193262 relevant lines covered (69.05%)

22119.45 hits per line

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

100.0
/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
        // AmtOnionType is the type used in the onion to reference the amount to
10
        // send to the next hop.
11
        AmtOnionType tlv.Type = 2
12

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

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

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

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

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

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

38
// NewAmtToFwdRecord creates a tlv.Record that encodes the amount_to_forward
39
// (type 2) for an onion payload.
40
func NewAmtToFwdRecord(amt *uint64) tlv.Record {
297✔
41
        return tlv.MakeDynamicRecord(
297✔
42
                AmtOnionType, amt, func() uint64 {
538✔
43
                        return tlv.SizeTUint64(*amt)
241✔
44
                },
241✔
45
                tlv.ETUint64, tlv.DTUint64,
46
        )
47
}
48

49
// NewLockTimeRecord creates a tlv.Record that encodes the outgoing_cltv_value
50
// (type 4) for an onion payload.
51
func NewLockTimeRecord(lockTime *uint32) tlv.Record {
297✔
52
        return tlv.MakeDynamicRecord(
297✔
53
                LockTimeOnionType, lockTime, func() uint64 {
538✔
54
                        return tlv.SizeTUint32(*lockTime)
241✔
55
                },
241✔
56
                tlv.ETUint32, tlv.DTUint32,
57
        )
58
}
59

60
// NewNextHopIDRecord creates a tlv.Record that encodes the short_channel_id
61
// (type 6) for an onion payload.
62
func NewNextHopIDRecord(cid *uint64) tlv.Record {
92✔
63
        return tlv.MakePrimitiveRecord(NextHopOnionType, cid)
92✔
64
}
92✔
65

66
// NewEncryptedDataRecord creates a tlv.Record that encodes the encrypted_data
67
// (type 10) record for an onion payload.
68
func NewEncryptedDataRecord(data *[]byte) tlv.Record {
68✔
69
        return tlv.MakePrimitiveRecord(EncryptedDataOnionType, data)
68✔
70
}
68✔
71

72
// NewBlindingPointRecord creates a tlv.Record that encodes the blinding_point
73
// (type 12) record for an onion payload.
74
func NewBlindingPointRecord(point **btcec.PublicKey) tlv.Record {
61✔
75
        return tlv.MakePrimitiveRecord(BlindingPointOnionType, point)
61✔
76
}
61✔
77

78
// NewMetadataRecord creates a tlv.Record that encodes the metadata (type 10)
79
// for an onion payload.
80
func NewMetadataRecord(metadata *[]byte) tlv.Record {
285✔
81
        return tlv.MakeDynamicRecord(
285✔
82
                MetadataOnionType, metadata,
285✔
83
                func() uint64 {
448✔
84
                        return uint64(len(*metadata))
163✔
85
                },
163✔
86
                tlv.EVarBytes, tlv.DVarBytes,
87
        )
88
}
89

90
// NewTotalAmtMsatBlinded creates a tlv.Record that encodes the
91
// total_amount_msat for the final an onion payload within a blinded route.
92
func NewTotalAmtMsatBlinded(amt *uint64) tlv.Record {
57✔
93
        return tlv.MakeDynamicRecord(
57✔
94
                TotalAmtMsatBlindedType, amt, func() uint64 {
61✔
95
                        return tlv.SizeTUint64(*amt)
4✔
96
                },
4✔
97
                tlv.ETUint64, tlv.DTUint64,
98
        )
99
}
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

© 2025 Coveralls, Inc