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

lightningnetwork / lnd / 15736109134

18 Jun 2025 02:46PM UTC coverage: 58.197% (-10.1%) from 68.248%
15736109134

Pull #9752

github

web-flow
Merge d2634a68c into 31c74f20f
Pull Request #9752: routerrpc: reject payment to invoice that don't have payment secret or blinded paths

6 of 13 new or added lines in 2 files covered. (46.15%)

28331 existing lines in 455 files now uncovered.

97860 of 168153 relevant lines covered (58.2%)

1.81 hits per line

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

0.0
/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.
UNCOV
42
func (c *Warning) Warning() string {
×
UNCOV
43
        errMsg := "non-ascii data"
×
UNCOV
44
        if isASCII(c.Data) {
×
UNCOV
45
                errMsg = string(c.Data)
×
UNCOV
46
        }
×
47

UNCOV
48
        return fmt.Sprintf("chan_id=%v, err=%v", c.ChanID, errMsg)
×
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.
UNCOV
55
func (c *Warning) Decode(r io.Reader, _ uint32) error {
×
UNCOV
56
        return ReadElements(r,
×
UNCOV
57
                &c.ChanID,
×
UNCOV
58
                &c.Data,
×
UNCOV
59
        )
×
UNCOV
60
}
×
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.
UNCOV
66
func (c *Warning) Encode(w *bytes.Buffer, _ uint32) error {
×
UNCOV
67
        if err := WriteBytes(w, c.ChanID[:]); err != nil {
×
68
                return err
×
69
        }
×
70

UNCOV
71
        return WriteWarningData(w, c.Data)
×
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.
UNCOV
78
func (c *Warning) MsgType() MessageType {
×
UNCOV
79
        return MsgWarning
×
UNCOV
80
}
×
81

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