• 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
/channeldb/migration/lnwire21/announcement_signatures.go
1
package lnwire
2

3
import (
4
        "io"
5
)
6

7
// AnnounceSignatures is a direct message between two endpoints of a
8
// channel and serves as an opt-in mechanism to allow the announcement of
9
// the channel to the rest of the network. It contains the necessary
10
// signatures by the sender to construct the channel announcement message.
11
type AnnounceSignatures struct {
12
        // ChannelID is the unique description of the funding transaction.
13
        // Channel id is better for users and debugging and short channel id is
14
        // used for quick test on existence of the particular utxo inside the
15
        // block chain, because it contains information about block.
16
        ChannelID ChannelID
17

18
        // ShortChannelID is the unique description of the funding
19
        // transaction. It is constructed with the most significant 3 bytes
20
        // as the block height, the next 3 bytes indicating the transaction
21
        // index within the block, and the least significant two bytes
22
        // indicating the output index which pays to the channel.
23
        ShortChannelID ShortChannelID
24

25
        // NodeSignature is the signature which contains the signed announce
26
        // channel message, by this signature we proof that we possess of the
27
        // node pub key and creating the reference node_key -> bitcoin_key.
28
        NodeSignature Sig
29

30
        // BitcoinSignature is the signature which contains the signed node
31
        // public key, by this signature we proof that we possess of the
32
        // bitcoin key and and creating the reverse reference bitcoin_key ->
33
        // node_key.
34
        BitcoinSignature Sig
35

36
        // ExtraOpaqueData is the set of data that was appended to this
37
        // message, some of which we may not actually know how to iterate or
38
        // parse. By holding onto this data, we ensure that we're able to
39
        // properly validate the set of signatures that cover these new fields,
40
        // and ensure we're able to make upgrades to the network in a forwards
41
        // compatible manner.
42
        ExtraOpaqueData []byte
43
}
44

45
// A compile time check to ensure AnnounceSignatures implements the
46
// lnwire.Message interface.
47
var _ Message = (*AnnounceSignatures)(nil)
48

49
// Decode deserializes a serialized AnnounceSignatures stored in the passed
50
// io.Reader observing the specified protocol version.
51
//
52
// This is part of the lnwire.Message interface.
UNCOV
53
func (a *AnnounceSignatures) Decode(r io.Reader, pver uint32) error {
×
UNCOV
54
        err := ReadElements(r,
×
UNCOV
55
                &a.ChannelID,
×
UNCOV
56
                &a.ShortChannelID,
×
UNCOV
57
                &a.NodeSignature,
×
UNCOV
58
                &a.BitcoinSignature,
×
UNCOV
59
        )
×
UNCOV
60
        if err != nil {
×
61
                return err
×
62
        }
×
63

64
        // Now that we've read out all the fields that we explicitly know of,
65
        // we'll collect the remainder into the ExtraOpaqueData field. If there
66
        // aren't any bytes, then we'll snip off the slice to avoid carrying
67
        // around excess capacity.
UNCOV
68
        a.ExtraOpaqueData, err = io.ReadAll(r)
×
UNCOV
69
        if err != nil {
×
70
                return err
×
71
        }
×
UNCOV
72
        if len(a.ExtraOpaqueData) == 0 {
×
UNCOV
73
                a.ExtraOpaqueData = nil
×
UNCOV
74
        }
×
75

UNCOV
76
        return nil
×
77
}
78

79
// Encode serializes the target AnnounceSignatures into the passed io.Writer
80
// observing the protocol version specified.
81
//
82
// This is part of the lnwire.Message interface.
UNCOV
83
func (a *AnnounceSignatures) Encode(w io.Writer, pver uint32) error {
×
UNCOV
84
        return WriteElements(w,
×
UNCOV
85
                a.ChannelID,
×
UNCOV
86
                a.ShortChannelID,
×
UNCOV
87
                a.NodeSignature,
×
UNCOV
88
                a.BitcoinSignature,
×
UNCOV
89
                a.ExtraOpaqueData,
×
UNCOV
90
        )
×
UNCOV
91
}
×
92

93
// MsgType returns the integer uniquely identifying this message type on the
94
// wire.
95
//
96
// This is part of the lnwire.Message interface.
UNCOV
97
func (a *AnnounceSignatures) MsgType() MessageType {
×
UNCOV
98
        return MsgAnnounceSignatures
×
UNCOV
99
}
×
100

101
// MaxPayloadLength returns the maximum allowed payload size for this message
102
// observing the specified protocol version.
103
//
104
// This is part of the lnwire.Message interface.
UNCOV
105
func (a *AnnounceSignatures) MaxPayloadLength(pver uint32) uint32 {
×
UNCOV
106
        return 65533
×
UNCOV
107
}
×
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