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

lightningnetwork / lnd / 15782265189

20 Jun 2025 03:23PM UTC coverage: 68.14% (-0.003%) from 68.143%
15782265189

Pull #9958

github

web-flow
Merge ae1a1d1ba into 7857d2c6a
Pull Request #9958: improve CloseChannel docs

134478 of 197355 relevant lines covered (68.14%)

22170.18 hits per line

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

75.0
/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
        // ExtraData is the set of data that was appended to this message to
28
        // fill out the full maximum transport message size. These fields can
29
        // be used to specify optional data such as custom TLV fields.
30
        ExtraData ExtraOpaqueData
31
}
32

33
// NewInitMessage creates new instance of init message object.
34
func NewInitMessage(gf *RawFeatureVector, f *RawFeatureVector) *Init {
113✔
35
        return &Init{
113✔
36
                GlobalFeatures: gf,
113✔
37
                Features:       f,
113✔
38
                ExtraData:      make([]byte, 0),
113✔
39
        }
113✔
40
}
113✔
41

42
// A compile time check to ensure Init implements the lnwire.Message
43
// interface.
44
var _ Message = (*Init)(nil)
45

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

50
// Decode deserializes a serialized Init message stored in the passed
51
// io.Reader observing the specified protocol version.
52
//
53
// This is part of the lnwire.Message interface.
54
func (msg *Init) Decode(r io.Reader, pver uint32) error {
183✔
55
        return ReadElements(r,
183✔
56
                &msg.GlobalFeatures,
183✔
57
                &msg.Features,
183✔
58
                &msg.ExtraData,
183✔
59
        )
183✔
60
}
183✔
61

62
// Encode serializes the target Init into the passed io.Writer observing
63
// the protocol version specified.
64
//
65
// This is part of the lnwire.Message interface.
66
func (msg *Init) Encode(w *bytes.Buffer, pver uint32) error {
147✔
67
        if err := WriteRawFeatureVector(w, msg.GlobalFeatures); err != nil {
147✔
68
                return err
×
69
        }
×
70

71
        if err := WriteRawFeatureVector(w, msg.Features); err != nil {
147✔
72
                return err
×
73
        }
×
74

75
        return WriteBytes(w, msg.ExtraData)
147✔
76
}
77

78
// MsgType returns the integer uniquely identifying this message type on the
79
// wire.
80
//
81
// This is part of the lnwire.Message interface.
82
func (msg *Init) MsgType() MessageType {
147✔
83
        return MsgInit
147✔
84
}
147✔
85

86
// SerializedSize returns the serialized size of the message in bytes.
87
//
88
// This is part of the lnwire.SizeableMessage interface.
89
func (msg *Init) SerializedSize() (uint32, error) {
×
90
        return MessageSerializedSize(msg)
×
91
}
×
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