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

lightningnetwork / lnd / 13566028875

27 Feb 2025 12:09PM UTC coverage: 49.396% (-9.4%) from 58.748%
13566028875

Pull #9555

github

ellemouton
graph/db: populate the graph cache in Start instead of during construction

In this commit, we move the graph cache population logic out of the
ChannelGraph constructor and into its Start method instead.
Pull Request #9555: graph: extract cache from CRUD [6]

34 of 54 new or added lines in 4 files covered. (62.96%)

27464 existing lines in 436 files now uncovered.

101095 of 204664 relevant lines covered (49.4%)

1.54 hits per line

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

68.89
/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
// Encode serializes the target FundingCreated into the passed io.Writer
48
// implementation. Serialization will observe the rules defined by the passed
49
// protocol version.
50
//
51
// This is part of the lnwire.Message interface.
52
func (f *FundingCreated) Encode(w *bytes.Buffer, pver uint32) error {
3✔
53
        recordProducers := make([]tlv.RecordProducer, 0, 1)
3✔
54
        f.PartialSig.WhenSome(func(sig PartialSigWithNonceTLV) {
6✔
55
                recordProducers = append(recordProducers, &sig)
3✔
56
        })
3✔
57
        err := EncodeMessageExtraData(&f.ExtraData, recordProducers...)
3✔
58
        if err != nil {
3✔
59
                return err
×
60
        }
×
61

62
        if err := WriteBytes(w, f.PendingChannelID[:]); err != nil {
3✔
63
                return err
×
64
        }
×
65

66
        if err := WriteOutPoint(w, f.FundingPoint); err != nil {
3✔
67
                return err
×
68
        }
×
69

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

74
        return WriteBytes(w, f.ExtraData)
3✔
75
}
76

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

90
        var tlvRecords ExtraOpaqueData
3✔
91
        if err := ReadElements(r, &tlvRecords); err != nil {
3✔
92
                return err
×
93
        }
×
94

95
        partialSig := f.PartialSig.Zero()
3✔
96
        typeMap, err := tlvRecords.ExtractRecords(&partialSig)
3✔
97
        if err != nil {
3✔
UNCOV
98
                return err
×
UNCOV
99
        }
×
100

101
        // Set the corresponding TLV types if they were included in the stream.
102
        if val, ok := typeMap[f.PartialSig.TlvType()]; ok && val == nil {
6✔
103
                f.PartialSig = tlv.SomeRecordT(partialSig)
3✔
104
        }
3✔
105

106
        if len(tlvRecords) != 0 {
6✔
107
                f.ExtraData = tlvRecords
3✔
108
        }
3✔
109

110
        return nil
3✔
111
}
112

113
// MsgType returns the uint32 code which uniquely identifies this message as a
114
// FundingCreated on the wire.
115
//
116
// This is part of the lnwire.Message interface.
117
func (f *FundingCreated) MsgType() MessageType {
3✔
118
        return MsgFundingCreated
3✔
119
}
3✔
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