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

lightningnetwork / lnd / 17917482292

22 Sep 2025 01:50PM UTC coverage: 56.562% (-10.1%) from 66.668%
17917482292

Pull #10182

github

web-flow
Merge 9efe3bd8c into 055fb436e
Pull Request #10182: Aux feature bits

32 of 68 new or added lines in 5 files covered. (47.06%)

29734 existing lines in 467 files now uncovered.

98449 of 174056 relevant lines covered (56.56%)

1.18 hits per line

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

70.45
/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 UpdateAddHTLC
29
        // message.
30
        CustomRecords CustomRecords
31

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

38
// NewInitMessage creates new instance of init message object.
39
func NewInitMessage(gf *RawFeatureVector, f *RawFeatureVector) *Init {
2✔
40
        return &Init{
2✔
41
                GlobalFeatures: gf,
2✔
42
                Features:       f,
2✔
43
                ExtraData:      make([]byte, 0),
2✔
44
        }
2✔
45
}
2✔
46

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

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

55
// Decode deserializes a serialized Init message stored in the passed
56
// io.Reader observing the specified protocol version.
57
//
58
// This is part of the lnwire.Message interface.
59
func (msg *Init) Decode(r io.Reader, pver uint32) error {
2✔
60
        err := ReadElements(r,
2✔
61
                &msg.GlobalFeatures,
2✔
62
                &msg.Features,
2✔
63
                &msg.ExtraData,
2✔
64
        )
2✔
65
        if err != nil {
2✔
NEW
66
                return err
×
NEW
67
        }
×
68

69
        customRecords, _, extraData, err := ParseAndExtractCustomRecords(
2✔
70
                msg.ExtraData,
2✔
71
        )
2✔
72
        if err != nil {
2✔
NEW
73
                return err
×
NEW
74
        }
×
75

76
        msg.CustomRecords = customRecords
2✔
77
        msg.ExtraData = extraData
2✔
78

2✔
79
        return nil
2✔
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 {
2✔
87
        if err := WriteRawFeatureVector(w, msg.GlobalFeatures); err != nil {
2✔
88
                return err
×
89
        }
×
90

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

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

100
        return WriteBytes(w, extraData)
2✔
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 {
2✔
108
        return MsgInit
2✔
109
}
2✔
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