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

lightningnetwork / lnd / 17917482292

22 Sep 2025 01:50PM UTC coverage: 56.562% (-10.1%) from 66.668%
17917482292

Pull #10182

github

web-flow
Merge 9efe3bd8c into 055fb436e
Pull Request #10182: Aux feature bits

32 of 68 new or added lines in 5 files covered. (47.06%)

29734 existing lines in 467 files now uncovered.

98449 of 174056 relevant lines covered (56.56%)

1.18 hits per line

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

0.0
/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.
UNCOV
71
func (a *AnnounceSignatures2) Decode(r io.Reader, _ uint32) error {
×
UNCOV
72
        stream, err := tlv.NewStream(ProduceRecordsSorted(
×
UNCOV
73
                &a.ChannelID, &a.ShortChannelID, &a.PartialSignature,
×
UNCOV
74
        )...)
×
UNCOV
75
        if err != nil {
×
76
                return err
×
77
        }
×
78

UNCOV
79
        typeMap, err := stream.DecodeWithParsedTypesP2P(r)
×
UNCOV
80
        if err != nil {
×
UNCOV
81
                return err
×
UNCOV
82
        }
×
83

UNCOV
84
        a.ExtraSignedFields = ExtraSignedFieldsFromTypeMap(typeMap)
×
UNCOV
85

×
UNCOV
86
        return nil
×
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.
UNCOV
93
func (a *AnnounceSignatures2) Encode(w *bytes.Buffer, _ uint32) error {
×
UNCOV
94
        return EncodePureTLVMessage(a, w)
×
UNCOV
95
}
×
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.
UNCOV
101
func (a *AnnounceSignatures2) MsgType() MessageType {
×
UNCOV
102
        return MsgAnnounceSignatures2
×
UNCOV
103
}
×
104

105
// SerializedSize returns the serialized size of the message in bytes.
106
//
107
// This is part of the lnwire.SizeableMessage interface.
108
func (a *AnnounceSignatures2) SerializedSize() (uint32, error) {
×
109
        return MessageSerializedSize(a)
×
110
}
×
111

112
// AllRecords returns all the TLV records for the message. This will include all
113
// the records we know about along with any that we don't know about but that
114
// fall in the signed TLV range.
115
//
116
// NOTE: this is part of the PureTLVMessage interface.
UNCOV
117
func (a *AnnounceSignatures2) AllRecords() []tlv.Record {
×
UNCOV
118
        recordProducers := []tlv.RecordProducer{
×
UNCOV
119
                &a.ChannelID, &a.ShortChannelID,
×
UNCOV
120
                &a.PartialSignature,
×
UNCOV
121
        }
×
UNCOV
122

×
UNCOV
123
        recordProducers = append(recordProducers, RecordsAsProducers(
×
UNCOV
124
                tlv.MapToRecords(a.ExtraSignedFields),
×
UNCOV
125
        )...)
×
UNCOV
126

×
UNCOV
127
        return ProduceRecordsSorted(recordProducers...)
×
UNCOV
128
}
×
129

130
// SCID returns the ShortChannelID of the channel.
131
//
132
// NOTE: this is part of the AnnounceSignatures interface.
133
func (a *AnnounceSignatures2) SCID() ShortChannelID {
×
134
        return a.ShortChannelID.Val
×
135
}
×
136

137
// ChanID returns the ChannelID identifying the channel.
138
//
139
// NOTE: this is part of the AnnounceSignatures interface.
140
func (a *AnnounceSignatures2) ChanID() ChannelID {
×
141
        return a.ChannelID.Val
×
142
}
×
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