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

lightningnetwork / lnd / 19027031130

03 Nov 2025 07:27AM UTC coverage: 56.922% (-9.7%) from 66.639%
19027031130

Pull #9334

github

web-flow
Merge b9be11a16 into f938e40af
Pull Request #9334: Use all valid routes during blinded path construction

9 of 11 new or added lines in 3 files covered. (81.82%)

29175 existing lines in 461 files now uncovered.

99696 of 175144 relevant lines covered (56.92%)

1.77 hits per line

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

71.11
/lnwire/init_message.go
1
package lnwire
2

3
import (
4
        "bytes"
5
        "io"
6
)
7

8
// Init is the first message reveals the features supported or required by this
9
// node. Nodes wait for receipt of the other's features to simplify error
10
// diagnosis where features are incompatible. Each node MUST wait to receive
11
// init before sending any other messages.
12
type Init struct {
13
        // GlobalFeatures is a legacy feature vector used for backwards
14
        // compatibility with older nodes. Any features defined here should be
15
        // merged with those presented in Features.
16
        GlobalFeatures *RawFeatureVector
17

18
        // Features is a feature vector containing the features supported by
19
        // the remote node.
20
        //
21
        // NOTE: Older nodes may place some features in GlobalFeatures, but all
22
        // new features are to be added in Features. When handling an Init
23
        // message, any GlobalFeatures should be merged into the unified
24
        // Features field.
25
        Features *RawFeatureVector
26

27
        // CustomRecords maps TLV types to byte slices, storing arbitrary data
28
        // intended for inclusion in the ExtraData field of the init message.
29
        CustomRecords CustomRecords
30

31
        // ExtraData is the set of data that was appended to this message to
32
        // fill out the full maximum transport message size. These fields can
33
        // be used to specify optional data such as custom TLV fields.
34
        ExtraData ExtraOpaqueData
35
}
36

37
// NewInitMessage creates new instance of init message object.
38
func NewInitMessage(gf *RawFeatureVector, f *RawFeatureVector) *Init {
3✔
39
        return &Init{
3✔
40
                GlobalFeatures: gf,
3✔
41
                Features:       f,
3✔
42
        }
3✔
43
}
3✔
44

45
// A compile time check to ensure Init implements the lnwire.Message
46
// interface.
47
var _ Message = (*Init)(nil)
48

49
// A compile time check to ensure Init implements the lnwire.SizeableMessage
50
// interface.
51
var _ SizeableMessage = (*Init)(nil)
52

53
// Decode deserializes a serialized Init message stored in the passed
54
// io.Reader observing the specified protocol version.
55
//
56
// This is part of the lnwire.Message interface.
57
func (msg *Init) Decode(r io.Reader, pver uint32) error {
3✔
58
        var msgExtraData ExtraOpaqueData
3✔
59

3✔
60
        err := ReadElements(r,
3✔
61
                &msg.GlobalFeatures,
3✔
62
                &msg.Features,
3✔
63
                &msgExtraData,
3✔
64
        )
3✔
65
        if err != nil {
3✔
UNCOV
66
                return err
×
UNCOV
67
        }
×
68

69
        customRecords, _, extraDData, err := ParseAndExtractCustomRecords(
3✔
70
                msgExtraData,
3✔
71
        )
3✔
72
        if err != nil {
3✔
UNCOV
73
                return err
×
UNCOV
74
        }
×
75

76
        msg.CustomRecords = customRecords
3✔
77
        msg.ExtraData = extraDData
3✔
78

3✔
79
        return nil
3✔
80
}
81

82
// Encode serializes the target Init into the passed io.Writer observing
83
// the protocol version specified.
84
//
85
// This is part of the lnwire.Message interface.
86
func (msg *Init) Encode(w *bytes.Buffer, pver uint32) error {
3✔
87
        if err := WriteRawFeatureVector(w, msg.GlobalFeatures); err != nil {
3✔
88
                return err
×
89
        }
×
90

91
        if err := WriteRawFeatureVector(w, msg.Features); err != nil {
3✔
92
                return err
×
93
        }
×
94

95
        extraData, err := MergeAndEncode(nil, msg.ExtraData, msg.CustomRecords)
3✔
96
        if err != nil {
3✔
97
                return err
×
98
        }
×
99

100
        return WriteBytes(w, extraData)
3✔
101
}
102

103
// MsgType returns the integer uniquely identifying this message type on the
104
// wire.
105
//
106
// This is part of the lnwire.Message interface.
107
func (msg *Init) MsgType() MessageType {
3✔
108
        return MsgInit
3✔
109
}
3✔
110

111
// SerializedSize returns the serialized size of the message in bytes.
112
//
113
// This is part of the lnwire.SizeableMessage interface.
114
func (msg *Init) SerializedSize() (uint32, error) {
×
115
        return MessageSerializedSize(msg)
×
116
}
×
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