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

lightningnetwork / lnd / 19155841408

07 Nov 2025 02:03AM UTC coverage: 66.675% (-0.04%) from 66.712%
19155841408

Pull #10352

github

web-flow
Merge e4313eba8 into 096ab65b1
Pull Request #10352: [WIP] chainrpc: return Unavailable while notifier starts

137328 of 205965 relevant lines covered (66.68%)

21333.36 hits per line

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

80.77
/lnwire/warning.go
1
package lnwire
2

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

9
// WarningData is a set of bytes associated with a particular sent warning. A
10
// receiving node SHOULD only print out data verbatim if the string is composed
11
// solely of printable ASCII characters. For reference, the printable character
12
// set includes byte values 32 through 127 inclusive.
13
type WarningData []byte
14

15
// Warning is used to express non-critical errors in the protocol, providing
16
// a "soft" way for nodes to communicate failures.
17
type Warning struct {
18
        // ChanID references the active channel in which the warning occurred
19
        // within. If the ChanID is all zeros, then this warning applies to the
20
        // entire established connection.
21
        ChanID ChannelID
22

23
        // Data is the attached warning data that describes the exact failure
24
        // which caused the warning message to be sent.
25
        Data WarningData
26
}
27

28
// A compile time check to ensure Warning implements the lnwire.Message
29
// interface.
30
var _ Message = (*Warning)(nil)
31

32
// A compile time check to ensure Warning implements the lnwire.SizeableMessage
33
// interface.
34
var _ SizeableMessage = (*Warning)(nil)
35

36
// NewWarning creates a new Warning message.
37
func NewWarning() *Warning {
×
38
        return &Warning{}
×
39
}
×
40

41
// Warning returns the string representation to Warning.
42
func (c *Warning) Warning() string {
45✔
43
        errMsg := "non-ascii data"
45✔
44
        if isASCII(c.Data) {
90✔
45
                errMsg = string(c.Data)
45✔
46
        }
45✔
47

48
        return fmt.Sprintf("chan_id=%v, err=%v", c.ChanID, errMsg)
45✔
49
}
50

51
// Decode deserializes a serialized Warning message stored in the passed
52
// io.Reader observing the specified protocol version.
53
//
54
// This is part of the lnwire.Message interface.
55
func (c *Warning) Decode(r io.Reader, _ uint32) error {
113✔
56
        return ReadElements(r,
113✔
57
                &c.ChanID,
113✔
58
                &c.Data,
113✔
59
        )
113✔
60
}
113✔
61

62
// Encode serializes the target Warning into the passed io.Writer observing the
63
// protocol version specified.
64
//
65
// This is part of the lnwire.Message interface.
66
func (c *Warning) Encode(w *bytes.Buffer, _ uint32) error {
126✔
67
        if err := WriteBytes(w, c.ChanID[:]); err != nil {
126✔
68
                return err
×
69
        }
×
70

71
        return WriteWarningData(w, c.Data)
126✔
72
}
73

74
// MsgType returns the integer uniquely identifying an Warning message on the
75
// wire.
76
//
77
// This is part of the lnwire.Message interface.
78
func (c *Warning) MsgType() MessageType {
118✔
79
        return MsgWarning
118✔
80
}
118✔
81

82
// SerializedSize returns the serialized size of the message in bytes.
83
//
84
// This is part of the lnwire.SizeableMessage interface.
85
func (c *Warning) SerializedSize() (uint32, error) {
11✔
86
        return MessageSerializedSize(c)
11✔
87
}
11✔
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