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

lightningnetwork / lnd / 13980275562

20 Mar 2025 10:06PM UTC coverage: 58.6% (-10.2%) from 68.789%
13980275562

Pull #9623

github

web-flow
Merge b9b960345 into 09b674508
Pull Request #9623: Size msg test msg

0 of 1518 new or added lines in 42 files covered. (0.0%)

26603 existing lines in 443 files now uncovered.

96807 of 165200 relevant lines covered (58.6%)

1.82 hits per line

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

40.91
/lnwire/announcement_signatures.go
1
package lnwire
2

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

7
        "pgregory.net/rapid"
8
)
9

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

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

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

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

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

48
// A compile time check to ensure AnnounceSignatures1 implements the
49
// lnwire.Message interface.
50
var _ Message = (*AnnounceSignatures1)(nil)
51

52
// A compile time check to ensure AnnounceSignatures1 implements the
53
// lnwire.SizeableMessage interface.
54
var _ SizeableMessage = (*AnnounceSignatures1)(nil)
55

56
// A compile time check to ensure AnnounceSignatures1 implements the
57
// lnwire.AnnounceSignatures interface.
58
var _ AnnounceSignatures = (*AnnounceSignatures1)(nil)
59

60
// A compile time check to ensure AnnounceSignatures1 implements the
61
// lnwire.TestMessage interface.
62
var _ TestMessage = (*AnnounceSignatures1)(nil)
63

64
// Decode deserializes a serialized AnnounceSignatures1 stored in the passed
65
// io.Reader observing the specified protocol version.
66
//
67
// This is part of the lnwire.Message interface.
68
func (a *AnnounceSignatures1) Decode(r io.Reader, _ uint32) error {
3✔
69
        return ReadElements(r,
3✔
70
                &a.ChannelID,
3✔
71
                &a.ShortChannelID,
3✔
72
                &a.NodeSignature,
3✔
73
                &a.BitcoinSignature,
3✔
74
                &a.ExtraOpaqueData,
3✔
75
        )
3✔
76
}
3✔
77

78
// Encode serializes the target AnnounceSignatures1 into the passed io.Writer
79
// observing the protocol version specified.
80
//
81
// This is part of the lnwire.Message interface.
82
func (a *AnnounceSignatures1) Encode(w *bytes.Buffer, _ uint32) error {
3✔
83
        if err := WriteChannelID(w, a.ChannelID); err != nil {
3✔
84
                return err
×
85
        }
×
86

87
        if err := WriteShortChannelID(w, a.ShortChannelID); err != nil {
3✔
88
                return err
×
89
        }
×
90

91
        if err := WriteSig(w, a.NodeSignature); err != nil {
3✔
92
                return err
×
93
        }
×
94

95
        if err := WriteSig(w, a.BitcoinSignature); err != nil {
3✔
96
                return err
×
97
        }
×
98

99
        return WriteBytes(w, a.ExtraOpaqueData)
3✔
100
}
101

102
// MsgType returns the integer uniquely identifying this message type on the
103
// wire.
104
//
105
// This is part of the lnwire.Message interface.
106
func (a *AnnounceSignatures1) MsgType() MessageType {
3✔
107
        return MsgAnnounceSignatures
3✔
108
}
3✔
109

110
// SerializedSize returns the serialized size of the message in bytes.
111
//
112
// This is part of the lnwire.SizeableMessage interface.
NEW
113
func (a *AnnounceSignatures1) SerializedSize() (uint32, error) {
×
NEW
114
        return MessageSerializedSize(a)
×
NEW
115
}
×
116

117
// SCID returns the ShortChannelID of the channel.
118
//
119
// This is part of the lnwire.AnnounceSignatures interface.
120
func (a *AnnounceSignatures1) SCID() ShortChannelID {
×
121
        return a.ShortChannelID
×
122
}
×
123

124
// ChanID returns the ChannelID identifying the channel.
125
//
126
// This is part of the lnwire.AnnounceSignatures interface.
127
func (a *AnnounceSignatures1) ChanID() ChannelID {
×
128
        return a.ChannelID
×
129
}
×
130

131
// RandTestMessage populates the message with random data suitable for testing.
132
// It uses the rapid testing framework to generate random values.
133
//
134
// This is part of the TestMessage interface.
NEW
135
func (a *AnnounceSignatures1) RandTestMessage(t *rapid.T) Message {
×
NEW
136
        return &AnnounceSignatures1{
×
NEW
137
                ChannelID:        RandChannelID(t),
×
NEW
138
                ShortChannelID:   RandShortChannelID(t),
×
NEW
139
                NodeSignature:    RandSignature(t),
×
NEW
140
                BitcoinSignature: RandSignature(t),
×
NEW
141
                ExtraOpaqueData:  RandExtraOpaqueData(t, nil),
×
NEW
142
        }
×
NEW
143
}
×
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