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

lightningnetwork / lnd / 13211764208

08 Feb 2025 03:08AM UTC coverage: 49.288% (-9.5%) from 58.815%
13211764208

Pull #9489

github

calvinrzachman
itest: verify switchrpc server enforces send then track

We prevent the rpc server from allowing onion dispatches for
attempt IDs which have already been tracked by rpc clients.

This helps protect the client from leaking a duplicate onion
attempt. NOTE: This is not the only method for solving this
issue! The issue could be addressed via careful client side
programming which accounts for the uncertainty and async
nature of dispatching onions to a remote process via RPC.
This would require some lnd ChannelRouter changes for how
we intend to use these RPCs though.
Pull Request #9489: multi: add BuildOnion, SendOnion, and TrackOnion RPCs

474 of 990 new or added lines in 11 files covered. (47.88%)

27321 existing lines in 435 files now uncovered.

101192 of 205306 relevant lines covered (49.29%)

1.54 hits per line

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

0.0
/lnwire/ping.go
1
package lnwire
2

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

8
// PingPayload is a set of opaque bytes used to pad out a ping message.
9
type PingPayload []byte
10

11
// Ping defines a message which is sent by peers periodically to determine if
12
// the connection is still valid. Each ping message carries the number of bytes
13
// to pad the pong response with, and also a number of bytes to be ignored at
14
// the end of the ping message (which is padding).
15
type Ping struct {
16
        // NumPongBytes is the number of bytes the pong response to this
17
        // message should carry.
18
        NumPongBytes uint16
19

20
        // PaddingBytes is a set of opaque bytes used to pad out this ping
21
        // message. Using this field in conjunction to the one above, it's
22
        // possible for node to generate fake cover traffic.
23
        PaddingBytes PingPayload
24
}
25

26
// NewPing returns a new Ping message.
UNCOV
27
func NewPing(numBytes uint16) *Ping {
×
UNCOV
28
        return &Ping{
×
UNCOV
29
                NumPongBytes: numBytes,
×
UNCOV
30
        }
×
UNCOV
31
}
×
32

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

36
// Decode deserializes a serialized Ping message stored in the passed io.Reader
37
// observing the specified protocol version.
38
//
39
// This is part of the lnwire.Message interface.
UNCOV
40
func (p *Ping) Decode(r io.Reader, pver uint32) error {
×
UNCOV
41
        err := ReadElements(r, &p.NumPongBytes, &p.PaddingBytes)
×
UNCOV
42
        if err != nil {
×
UNCOV
43
                return err
×
UNCOV
44
        }
×
45

UNCOV
46
        if p.NumPongBytes > MaxPongBytes {
×
UNCOV
47
                return ErrMaxPongBytesExceeded
×
UNCOV
48
        }
×
49

UNCOV
50
        return nil
×
51
}
52

53
// Encode serializes the target Ping into the passed io.Writer observing the
54
// protocol version specified.
55
//
56
// This is part of the lnwire.Message interface.
UNCOV
57
func (p *Ping) Encode(w *bytes.Buffer, pver uint32) error {
×
UNCOV
58
        if err := WriteUint16(w, p.NumPongBytes); err != nil {
×
59
                return err
×
60
        }
×
61

UNCOV
62
        return WritePingPayload(w, p.PaddingBytes)
×
63
}
64

65
// MsgType returns the integer uniquely identifying this message type on the
66
// wire.
67
//
68
// This is part of the lnwire.Message interface.
UNCOV
69
func (p *Ping) MsgType() MessageType {
×
UNCOV
70
        return MsgPing
×
UNCOV
71
}
×
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