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

lightningnetwork / lnd / 15561477203

10 Jun 2025 01:54PM UTC coverage: 58.351% (-10.1%) from 68.487%
15561477203

Pull #9356

github

web-flow
Merge 6440b25db into c6d6d4c0b
Pull Request #9356: lnrpc: add incoming/outgoing channel ids filter to forwarding history request

33 of 36 new or added lines in 2 files covered. (91.67%)

28366 existing lines in 455 files now uncovered.

97715 of 167461 relevant lines covered (58.35%)

1.81 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 {
3✔
35
        return &Init{
3✔
36
                GlobalFeatures: gf,
3✔
37
                Features:       f,
3✔
38
                ExtraData:      make([]byte, 0),
3✔
39
        }
3✔
40
}
3✔
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 {
3✔
55
        return ReadElements(r,
3✔
56
                &msg.GlobalFeatures,
3✔
57
                &msg.Features,
3✔
58
                &msg.ExtraData,
3✔
59
        )
3✔
60
}
3✔
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 {
3✔
67
        if err := WriteRawFeatureVector(w, msg.GlobalFeatures); err != nil {
3✔
68
                return err
×
69
        }
×
70

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

75
        return WriteBytes(w, msg.ExtraData)
3✔
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 {
3✔
83
        return MsgInit
3✔
84
}
3✔
85

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