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

lightningnetwork / lnd / 18197857992

02 Oct 2025 03:32PM UTC coverage: 66.622% (-0.02%) from 66.646%
18197857992

Pull #10267

github

web-flow
Merge 0d9bfccfe into 1c2ff4a7e
Pull Request #10267: [g175] multi: small G175 preparations

24 of 141 new or added lines in 12 files covered. (17.02%)

64 existing lines in 20 files now uncovered.

137216 of 205963 relevant lines covered (66.62%)

21302.01 hits per line

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

52.63
/lnwire/announcement_signatures_2.go
1
package lnwire
2

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

7
        "github.com/lightningnetwork/lnd/tlv"
8
)
9

10
// AnnounceSignatures2 is a direct message between two endpoints of a
11
// channel and serves as an opt-in mechanism to allow the announcement of
12
// a taproot channel to the rest of the network. It contains the necessary
13
// signatures by the sender to construct the channel_announcement_2 message.
14
type AnnounceSignatures2 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
        // blockchain, because it contains information about block.
19
        ChannelID tlv.RecordT[tlv.TlvType0, ChannelID]
20

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

28
        // PartialSignature is the combination of the partial Schnorr signature
29
        // created for the node's bitcoin key with the partial signature created
30
        // for the node's node ID key.
31
        PartialSignature tlv.RecordT[tlv.TlvType4, PartialSig]
32

33
        // Any extra fields in the signed range that we do not yet know about,
34
        // but we need to keep them for signature validation and to produce a
35
        // valid message.
36
        ExtraSignedFields
37
}
38

39
// NewAnnSigs2 is a constructor for AnnounceSignatures2.
40
func NewAnnSigs2(chanID ChannelID, scid ShortChannelID,
41
        partialSig PartialSig) *AnnounceSignatures2 {
×
42

×
43
        return &AnnounceSignatures2{
×
44
                ChannelID: tlv.NewRecordT[tlv.TlvType0, ChannelID](chanID),
×
45
                ShortChannelID: tlv.NewRecordT[tlv.TlvType2, ShortChannelID](
×
46
                        scid,
×
47
                ),
×
48
                PartialSignature: tlv.NewRecordT[tlv.TlvType4, PartialSig](
×
49
                        partialSig,
×
50
                ),
×
51
                ExtraSignedFields: make(ExtraSignedFields),
×
52
        }
×
53
}
×
54

55
// A compile time check to ensure AnnounceSignatures2 implements the
56
// lnwire.Message interface.
57
var _ Message = (*AnnounceSignatures2)(nil)
58

59
// A compile time check to ensure AnnounceSignatures2 implements the
60
// lnwire.SizeableMessage interface.
61
var _ SizeableMessage = (*AnnounceSignatures2)(nil)
62

63
// A compile time check to ensure ChannelAnnouncement2 implements the
64
// lnwire.PureTLVMessage interface.
65
var _ PureTLVMessage = (*AnnounceSignatures2)(nil)
66

67
// Decode deserializes a serialized AnnounceSignatures2 stored in the passed
68
// io.Reader observing the specified protocol version.
69
//
70
// This is part of the lnwire.Message interface.
71
func (a *AnnounceSignatures2) Decode(r io.Reader, _ uint32) error {
119✔
72
        stream, err := tlv.NewStream(ProduceRecordsSorted(
119✔
73
                &a.ChannelID, &a.ShortChannelID, &a.PartialSignature,
119✔
74
        )...)
119✔
75
        if err != nil {
119✔
76
                return err
×
77
        }
×
78

79
        typeMap, err := stream.DecodeWithParsedTypesP2P(r)
119✔
80
        if err != nil {
135✔
81
                return err
16✔
82
        }
16✔
83

84
        a.ExtraSignedFields = ExtraSignedFieldsFromTypeMap(typeMap)
103✔
85

103✔
86
        return nil
103✔
87
}
88

89
// Encode serializes the target AnnounceSignatures2 into the passed io.Writer
90
// observing the protocol version specified.
91
//
92
// This is part of the lnwire.Message interface.
93
func (a *AnnounceSignatures2) Encode(w *bytes.Buffer, _ uint32) error {
102✔
94
        return EncodePureTLVMessage(a, w)
102✔
95
}
102✔
96

97
// MsgType returns the integer uniquely identifying this message type on the
98
// wire.
99
//
100
// This is part of the lnwire.Message interface.
101
func (a *AnnounceSignatures2) MsgType() MessageType {
101✔
102
        return MsgAnnounceSignatures2
101✔
103
}
101✔
104

105
// GossipVersion returns the gossip version that this message is part of.
106
//
107
// NOTE: this is part of the GossipMessage interface.
NEW
108
func (a *AnnounceSignatures2) GossipVersion() GossipVersion {
×
NEW
109
        return GossipVersion2
×
NEW
110
}
×
111

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

119
// AllRecords returns all the TLV records for the message. This will include all
120
// the records we know about along with any that we don't know about but that
121
// fall in the signed TLV range.
122
//
123
// NOTE: this is part of the PureTLVMessage interface.
124
func (a *AnnounceSignatures2) AllRecords() []tlv.Record {
102✔
125
        recordProducers := []tlv.RecordProducer{
102✔
126
                &a.ChannelID, &a.ShortChannelID,
102✔
127
                &a.PartialSignature,
102✔
128
        }
102✔
129

102✔
130
        recordProducers = append(recordProducers, RecordsAsProducers(
102✔
131
                tlv.MapToRecords(a.ExtraSignedFields),
102✔
132
        )...)
102✔
133

102✔
134
        return ProduceRecordsSorted(recordProducers...)
102✔
135
}
102✔
136

137
// SCID returns the ShortChannelID of the channel.
138
//
139
// NOTE: this is part of the AnnounceSignatures interface.
140
func (a *AnnounceSignatures2) SCID() ShortChannelID {
×
141
        return a.ShortChannelID.Val
×
142
}
×
143

144
// ChanID returns the ChannelID identifying the channel.
145
//
146
// NOTE: this is part of the AnnounceSignatures interface.
147
func (a *AnnounceSignatures2) ChanID() ChannelID {
×
148
        return a.ChannelID.Val
×
149
}
×
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