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

lightningnetwork / lnd / 16990665124

15 Aug 2025 01:10PM UTC coverage: 66.74% (-0.03%) from 66.765%
16990665124

Pull #9455

github

web-flow
Merge 035fac41d into fb1adfc21
Pull Request #9455: [1/2] discovery+lnwire: add support for DNS host name in NodeAnnouncement msg

116 of 188 new or added lines in 8 files covered. (61.7%)

110 existing lines in 23 files now uncovered.

136011 of 203791 relevant lines covered (66.74%)

21482.89 hits per line

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

72.92
/lnwire/funding_created.go
1
package lnwire
2

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

7
        "github.com/btcsuite/btcd/wire"
8
        "github.com/lightningnetwork/lnd/tlv"
9
)
10

11
// FundingCreated is sent from Alice (the initiator) to Bob (the responder),
12
// once Alice receives Bob's contributions as well as his channel constraints.
13
// Once bob receives this message, he'll gain access to an immediately
14
// broadcastable commitment transaction and will reply with a signature for
15
// Alice's version of the commitment transaction.
16
type FundingCreated struct {
17
        // PendingChannelID serves to uniquely identify the future channel
18
        // created by the initiated single funder workflow.
19
        PendingChannelID [32]byte
20

21
        // FundingPoint is the outpoint of the funding transaction created by
22
        // Alice. With this, Bob is able to generate both his version and
23
        // Alice's version of the commitment transaction.
24
        FundingPoint wire.OutPoint
25

26
        // CommitSig is Alice's signature from Bob's version of the commitment
27
        // transaction.
28
        CommitSig Sig
29

30
        // PartialSig is used to transmit a musig2 extended partial signature
31
        // that also carries along the public nonce of the signer.
32
        //
33
        // NOTE: This field is only populated if a musig2 taproot channel is
34
        // being signed for. In this case, the above Sig type MUST be blank.
35
        PartialSig OptPartialSigWithNonceTLV
36

37
        // ExtraData is the set of data that was appended to this message to
38
        // fill out the full maximum transport message size. These fields can
39
        // be used to specify optional data such as custom TLV fields.
40
        ExtraData ExtraOpaqueData
41
}
42

43
// A compile time check to ensure FundingCreated implements the lnwire.Message
44
// interface.
45
var _ Message = (*FundingCreated)(nil)
46

47
// A compile time check to ensure FundingCreated implements the
48
// lnwire.SizeableMessage interface.
49
var _ SizeableMessage = (*FundingCreated)(nil)
50

51
// Encode serializes the target FundingCreated into the passed io.Writer
52
// implementation. Serialization will observe the rules defined by the passed
53
// protocol version.
54
//
55
// This is part of the lnwire.Message interface.
56
func (f *FundingCreated) Encode(w *bytes.Buffer, pver uint32) error {
114✔
57
        recordProducers := make([]tlv.RecordProducer, 0, 1)
114✔
58
        f.PartialSig.WhenSome(func(sig PartialSigWithNonceTLV) {
165✔
59
                recordProducers = append(recordProducers, &sig)
51✔
60
        })
51✔
61
        err := EncodeMessageExtraData(&f.ExtraData, recordProducers...)
114✔
62
        if err != nil {
114✔
63
                return err
×
64
        }
×
65

66
        if err := WriteBytes(w, f.PendingChannelID[:]); err != nil {
114✔
67
                return err
×
68
        }
×
69

70
        if err := WriteOutPoint(w, f.FundingPoint); err != nil {
114✔
71
                return err
×
72
        }
×
73

74
        if err := WriteSig(w, f.CommitSig); err != nil {
114✔
75
                return err
×
76
        }
×
77

78
        return WriteBytes(w, f.ExtraData)
114✔
79
}
80

81
// Decode deserializes the serialized FundingCreated stored in the passed
82
// io.Reader into the target FundingCreated using the deserialization rules
83
// defined by the passed protocol version.
84
//
85
// This is part of the lnwire.Message interface.
86
func (f *FundingCreated) Decode(r io.Reader, pver uint32) error {
176✔
87
        err := ReadElements(
176✔
88
                r, f.PendingChannelID[:], &f.FundingPoint, &f.CommitSig,
176✔
89
        )
176✔
90
        if err != nil {
181✔
91
                return err
5✔
92
        }
5✔
93

94
        var tlvRecords ExtraOpaqueData
171✔
95
        if err := ReadElements(r, &tlvRecords); err != nil {
171✔
96
                return err
×
97
        }
×
98

99
        partialSig := f.PartialSig.Zero()
171✔
100
        typeMap, err := tlvRecords.ExtractRecords(&partialSig)
171✔
101
        if err != nil {
217✔
102
                return err
46✔
103
        }
46✔
104

105
        // Set the corresponding TLV types if they were included in the stream.
106
        if val, ok := typeMap[f.PartialSig.TlvType()]; ok && val == nil {
178✔
107
                f.PartialSig = tlv.SomeRecordT(partialSig)
53✔
108
        }
53✔
109

110
        if len(tlvRecords) != 0 {
186✔
111
                f.ExtraData = tlvRecords
61✔
112
        }
61✔
113

114
        return nil
125✔
115
}
116

117
// MsgType returns the uint32 code which uniquely identifies this message as a
118
// FundingCreated on the wire.
119
//
120
// This is part of the lnwire.Message interface.
121
func (f *FundingCreated) MsgType() MessageType {
114✔
122
        return MsgFundingCreated
114✔
123
}
114✔
124

125
// SerializedSize returns the serialized size of the message in bytes.
126
//
127
// This is part of the lnwire.SizeableMessage interface.
UNCOV
128
func (f *FundingCreated) SerializedSize() (uint32, error) {
×
UNCOV
129
        return MessageSerializedSize(f)
×
UNCOV
130
}
×
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