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

lightningnetwork / lnd / 15707922856

17 Jun 2025 12:59PM UTC coverage: 68.521% (+0.01%) from 68.507%
15707922856

Pull #9957

github

web-flow
Merge 6b7c85cd4 into a5c4a7c54
Pull Request #9957: Re-send AnnouncementSignature not more than once per connection.

69 of 81 new or added lines in 4 files covered. (85.19%)

48 existing lines in 13 files now uncovered.

134580 of 196406 relevant lines covered (68.52%)

22264.31 hits per line

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

65.75
/lnwire/announcement_signatures.go
1
package lnwire
2

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

7
        "github.com/btcsuite/btcd/btcec/v2/ecdsa"
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
func newAnnSig(chanID ChannelID, shortChanID ShortChannelID,
49
        nodeSig, bitcoinSig Sig,
50
        extraOpaqueData ExtraOpaqueData) *AnnounceSignatures1 {
47✔
51

47✔
52
        return &AnnounceSignatures1{
47✔
53
                ChannelID:        chanID,
47✔
54
                ShortChannelID:   shortChanID,
47✔
55
                NodeSignature:    nodeSig,
47✔
56
                BitcoinSignature: bitcoinSig,
47✔
57
                ExtraOpaqueData:  extraOpaqueData,
47✔
58
        }
47✔
59
}
47✔
60

61
func NewAnnSigFromSignature(chanID ChannelID,
62
        shortChanID ShortChannelID, nodeSig, bitcoinSig *ecdsa.Signature,
63
        extraOpaqueData ExtraOpaqueData) (*AnnounceSignatures1, error) {
45✔
64

45✔
65
        nodeSignature, err := NewSigFromSignature(nodeSig)
45✔
66
        if err != nil {
45✔
NEW
67
                return nil, err
×
NEW
68
        }
×
69
        bitcoinSignature, err := NewSigFromSignature(bitcoinSig)
45✔
70
        if err != nil {
45✔
NEW
71
                return nil, err
×
NEW
72
        }
×
73

74
        return newAnnSig(
45✔
75
                chanID, shortChanID, nodeSignature, bitcoinSignature,
45✔
76
                extraOpaqueData,
45✔
77
        ), nil
45✔
78
}
79

80
func NewAnnSigFromWireECDSARaw(chanID ChannelID,
81
        shortChanID ShortChannelID, nodeSig, bitcoinSig []byte,
82
        extraOpaqueData ExtraOpaqueData) (*AnnounceSignatures1, error) {
5✔
83

5✔
84
        nodeSignature, err := NewSigFromECDSARawSignature(nodeSig)
5✔
85
        if err != nil {
5✔
NEW
86
                return nil, err
×
NEW
87
        }
×
88
        bitcoinSignature, err := NewSigFromECDSARawSignature(bitcoinSig)
5✔
89
        if err != nil {
5✔
NEW
90
                return nil, err
×
NEW
91
        }
×
92

93
        return newAnnSig(
5✔
94
                chanID, shortChanID, nodeSignature, bitcoinSignature,
5✔
95
                extraOpaqueData,
5✔
96
        ), nil
5✔
97
}
98

99
// A compile time check to ensure AnnounceSignatures1 implements the
100
// lnwire.Message interface.
101
var _ Message = (*AnnounceSignatures1)(nil)
102

103
// A compile time check to ensure AnnounceSignatures1 implements the
104
// lnwire.SizeableMessage interface.
105
var _ SizeableMessage = (*AnnounceSignatures1)(nil)
106

107
// A compile time check to ensure AnnounceSignatures1 implements the
108
// lnwire.AnnounceSignatures interface.
109
var _ AnnounceSignatures = (*AnnounceSignatures1)(nil)
110

111
// Decode deserializes a serialized AnnounceSignatures1 stored in the passed
112
// io.Reader observing the specified protocol version.
113
//
114
// This is part of the lnwire.Message interface.
115
func (a *AnnounceSignatures1) Decode(r io.Reader, _ uint32) error {
146✔
116
        return ReadElements(r,
146✔
117
                &a.ChannelID,
146✔
118
                &a.ShortChannelID,
146✔
119
                &a.NodeSignature,
146✔
120
                &a.BitcoinSignature,
146✔
121
                &a.ExtraOpaqueData,
146✔
122
        )
146✔
123
}
146✔
124

125
// Encode serializes the target AnnounceSignatures1 into the passed io.Writer
126
// observing the protocol version specified.
127
//
128
// This is part of the lnwire.Message interface.
129
func (a *AnnounceSignatures1) Encode(w *bytes.Buffer, _ uint32) error {
125✔
130
        if err := WriteChannelID(w, a.ChannelID); err != nil {
125✔
131
                return err
×
132
        }
×
133

134
        if err := WriteShortChannelID(w, a.ShortChannelID); err != nil {
125✔
135
                return err
×
136
        }
×
137

138
        if err := WriteSig(w, a.NodeSignature); err != nil {
125✔
139
                return err
×
140
        }
×
141

142
        if err := WriteSig(w, a.BitcoinSignature); err != nil {
125✔
143
                return err
×
144
        }
×
145

146
        return WriteBytes(w, a.ExtraOpaqueData)
125✔
147
}
148

149
// MsgType returns the integer uniquely identifying this message type on the
150
// wire.
151
//
152
// This is part of the lnwire.Message interface.
153
func (a *AnnounceSignatures1) MsgType() MessageType {
186✔
154
        return MsgAnnounceSignatures
186✔
155
}
186✔
156

157
// SerializedSize returns the serialized size of the message in bytes.
158
//
159
// This is part of the lnwire.SizeableMessage interface.
160
func (a *AnnounceSignatures1) SerializedSize() (uint32, error) {
×
161
        return MessageSerializedSize(a)
×
162
}
×
163

164
// SCID returns the ShortChannelID of the channel.
165
//
166
// This is part of the lnwire.AnnounceSignatures interface.
167
func (a *AnnounceSignatures1) SCID() ShortChannelID {
×
168
        return a.ShortChannelID
×
169
}
×
170

171
// ChanID returns the ChannelID identifying the channel.
172
//
173
// This is part of the lnwire.AnnounceSignatures interface.
174
func (a *AnnounceSignatures1) ChanID() ChannelID {
×
175
        return a.ChannelID
×
176
}
×
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