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

lightningnetwork / lnd / 15736109134

18 Jun 2025 02:46PM UTC coverage: 58.197% (-10.1%) from 68.248%
15736109134

Pull #9752

github

web-flow
Merge d2634a68c into 31c74f20f
Pull Request #9752: routerrpc: reject payment to invoice that don't have payment secret or blinded paths

6 of 13 new or added lines in 2 files covered. (46.15%)

28331 existing lines in 455 files now uncovered.

97860 of 168153 relevant lines covered (58.2%)

1.81 hits per line

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

64.58
/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 {
3✔
57
        recordProducers := make([]tlv.RecordProducer, 0, 1)
3✔
58
        f.PartialSig.WhenSome(func(sig PartialSigWithNonceTLV) {
6✔
59
                recordProducers = append(recordProducers, &sig)
3✔
60
        })
3✔
61
        err := EncodeMessageExtraData(&f.ExtraData, recordProducers...)
3✔
62
        if err != nil {
3✔
63
                return err
×
64
        }
×
65

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

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

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

78
        return WriteBytes(w, f.ExtraData)
3✔
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 {
3✔
87
        err := ReadElements(
3✔
88
                r, f.PendingChannelID[:], &f.FundingPoint, &f.CommitSig,
3✔
89
        )
3✔
90
        if err != nil {
3✔
UNCOV
91
                return err
×
UNCOV
92
        }
×
93

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

99
        partialSig := f.PartialSig.Zero()
3✔
100
        typeMap, err := tlvRecords.ExtractRecords(&partialSig)
3✔
101
        if err != nil {
3✔
UNCOV
102
                return err
×
UNCOV
103
        }
×
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 {
6✔
107
                f.PartialSig = tlv.SomeRecordT(partialSig)
3✔
108
        }
3✔
109

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

114
        return nil
3✔
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 {
3✔
122
        return MsgFundingCreated
3✔
123
}
3✔
124

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