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

lightningnetwork / lnd / 12115442155

02 Dec 2024 08:28AM UTC coverage: 48.662% (-10.3%) from 58.948%
12115442155

Pull #9175

github

ellemouton
netann: update ChanAnn2 validation to work for P2WSH channels

This commit expands the ChannelAnnouncement2 validation for the case
where it is announcing a P2WSH channel.
Pull Request #9175: lnwire+netann: update structure of g175 messages to be pure TLV

6 of 314 new or added lines in 9 files covered. (1.91%)

27532 existing lines in 434 files now uncovered.

97890 of 201164 relevant lines covered (48.66%)

0.52 hits per line

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

70.0
/lnwire/funding_signed.go
1
package lnwire
2

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

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

10
// FundingSigned is sent from Bob (the responder) to Alice (the initiator)
11
// after receiving the funding outpoint and her signature for Bob's version of
12
// the commitment transaction.
13
type FundingSigned struct {
14
        // ChannelPoint is the particular active channel that this
15
        // FundingSigned is bound to.
16
        ChanID ChannelID
17

18
        // CommitSig is Bob's signature for Alice's version of the commitment
19
        // transaction.
20
        CommitSig Sig
21

22
        // PartialSig is used to transmit a musig2 extended partial signature
23
        // that also carries along the public nonce of the signer.
24
        //
25
        // NOTE: This field is only populated if a musig2 taproot channel is
26
        // being signed for. In this case, the above Sig type MUST be blank.
27
        PartialSig OptPartialSigWithNonceTLV
28

29
        // ExtraData is the set of data that was appended to this message to
30
        // fill out the full maximum transport message size. These fields can
31
        // be used to specify optional data such as custom TLV fields.
32
        ExtraData ExtraOpaqueData
33
}
34

35
// A compile time check to ensure FundingSigned implements the lnwire.Message
36
// interface.
37
var _ Message = (*FundingSigned)(nil)
38

39
// Encode serializes the target FundingSigned into the passed io.Writer
40
// implementation. Serialization will observe the rules defined by the passed
41
// protocol version.
42
//
43
// This is part of the lnwire.Message interface.
44
func (f *FundingSigned) Encode(w *bytes.Buffer, pver uint32) error {
1✔
45
        recordProducers := make([]tlv.RecordProducer, 0, 1)
1✔
46
        f.PartialSig.WhenSome(func(sig PartialSigWithNonceTLV) {
2✔
47
                recordProducers = append(recordProducers, &sig)
1✔
48
        })
1✔
49
        err := EncodeMessageExtraData(&f.ExtraData, recordProducers...)
1✔
50
        if err != nil {
1✔
51
                return err
×
52
        }
×
53

54
        if err := WriteChannelID(w, f.ChanID); err != nil {
1✔
55
                return err
×
56
        }
×
57

58
        if err := WriteSig(w, f.CommitSig); err != nil {
1✔
59
                return err
×
60
        }
×
61

62
        return WriteBytes(w, f.ExtraData)
1✔
63
}
64

65
// Decode deserializes the serialized FundingSigned stored in the passed
66
// io.Reader into the target FundingSigned using the deserialization rules
67
// defined by the passed protocol version.
68
//
69
// This is part of the lnwire.Message interface.
70
func (f *FundingSigned) Decode(r io.Reader, pver uint32) error {
1✔
71
        err := ReadElements(r, &f.ChanID, &f.CommitSig)
1✔
72
        if err != nil {
1✔
UNCOV
73
                return err
×
UNCOV
74
        }
×
75

76
        var tlvRecords ExtraOpaqueData
1✔
77
        if err := ReadElements(r, &tlvRecords); err != nil {
1✔
78
                return err
×
79
        }
×
80

81
        partialSig := f.PartialSig.Zero()
1✔
82
        typeMap, err := tlvRecords.ExtractRecords(&partialSig)
1✔
83
        if err != nil {
1✔
UNCOV
84
                return err
×
UNCOV
85
        }
×
86

87
        // Set the corresponding TLV types if they were included in the stream.
88
        if val, ok := typeMap[f.PartialSig.TlvType()]; ok && val == nil {
2✔
89
                f.PartialSig = tlv.SomeRecordT(partialSig)
1✔
90
        }
1✔
91

92
        if len(tlvRecords) != 0 {
2✔
93
                f.ExtraData = tlvRecords
1✔
94
        }
1✔
95

96
        return nil
1✔
97
}
98

99
// MsgType returns the uint32 code which uniquely identifies this message as a
100
// FundingSigned on the wire.
101
//
102
// This is part of the lnwire.Message interface.
103
func (f *FundingSigned) MsgType() MessageType {
1✔
104
        return MsgFundingSigned
1✔
105
}
1✔
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