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

lightningnetwork / lnd / 17027244024

17 Aug 2025 11:32PM UTC coverage: 57.287% (-9.5%) from 66.765%
17027244024

Pull #10167

github

web-flow
Merge fcb4f4303 into fb1adfc21
Pull Request #10167: multi: bump Go to 1.24.6

3 of 18 new or added lines in 6 files covered. (16.67%)

28537 existing lines in 457 files now uncovered.

99094 of 172978 relevant lines covered (57.29%)

1.78 hits per line

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

0.0
/lnwire/dyn_commit.go
1
package lnwire
2

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

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

11
// DynCommit is a composite message that is used to irrefutably execute a
12
// dynamic commitment update.
13
type DynCommit struct {
14
        // DynPropose is an embedded version of the original DynPropose message
15
        // that initiated this negotiation.
16
        DynPropose
17

18
        // DynAck is an embedded version of the original DynAck message that
19
        // countersigned this negotiation.
20
        DynAck
21

22
        // ExtraData is the set of data that was appended to this message to
23
        // fill out the full maximum transport message size. These fields can
24
        // be used to specify optional data such as custom TLV fields.
25
        ExtraData ExtraOpaqueData
26
}
27

28
// A compile time check to ensure DynCommit implements the lnwire.Message
29
// interface.
30
var _ Message = (*DynCommit)(nil)
31

32
// A compile time check to ensure DynCommit implements the
33
// lnwire.SizeableMessage interface.
34
var _ SizeableMessage = (*DynCommit)(nil)
35

36
// Encode serializes the target DynAck into the passed io.Writer. Serialization
37
// will observe the rules defined by the passed protocol version.
38
//
39
// This is a part of the lnwire.Message interface.
UNCOV
40
func (dc *DynCommit) Encode(w *bytes.Buffer, _ uint32) error {
×
UNCOV
41
        if err := WriteChannelID(w, dc.DynPropose.ChanID); err != nil {
×
42
                return err
×
43
        }
×
44

UNCOV
45
        if err := WriteSig(w, dc.Sig); err != nil {
×
46
                return err
×
47
        }
×
48

49
        // Create extra data records.
UNCOV
50
        producers, err := dc.ExtraData.RecordProducers()
×
UNCOV
51
        if err != nil {
×
52
                return err
×
53
        }
×
54

55
        // Append the known records.
UNCOV
56
        producers = append(producers, dynProposeRecords(&dc.DynPropose)...)
×
UNCOV
57
        dc.LocalNonce.WhenSome(
×
UNCOV
58
                func(rec tlv.RecordT[tlv.TlvType14, Musig2Nonce]) {
×
UNCOV
59
                        producers = append(producers, &rec)
×
UNCOV
60
                },
×
61
        )
62

63
        // Encode all known records.
UNCOV
64
        var tlvData ExtraOpaqueData
×
UNCOV
65
        err = tlvData.PackRecords(producers...)
×
UNCOV
66
        if err != nil {
×
67
                return err
×
68
        }
×
69

UNCOV
70
        return WriteBytes(w, tlvData)
×
71
}
72

73
// Decode deserializes the serialized DynCommit stored in the passed io.Reader
74
// into the target DynAck using the deserialization rules defined by the passed
75
// protocol version.
76
//
77
// This is a part of the lnwire.Message interface.
UNCOV
78
func (dc *DynCommit) Decode(r io.Reader, _ uint32) error {
×
UNCOV
79
        // Parse out main message.
×
UNCOV
80
        if err := ReadElements(r, &dc.DynPropose.ChanID, &dc.Sig); err != nil {
×
81
                return err
×
82
        }
×
UNCOV
83
        dc.DynAck.ChanID = dc.DynPropose.ChanID
×
UNCOV
84

×
UNCOV
85
        // Parse out TLV records.
×
UNCOV
86
        var tlvRecords ExtraOpaqueData
×
UNCOV
87
        if err := ReadElement(r, &tlvRecords); err != nil {
×
88
                return err
×
89
        }
×
90

91
        // Prepare receiving buffers to be filled by TLV extraction.
UNCOV
92
        var dustLimit tlv.RecordT[tlv.TlvType0, tlv.BigSizeT[btcutil.Amount]]
×
UNCOV
93
        var maxValue tlv.RecordT[tlv.TlvType2, MilliSatoshi]
×
UNCOV
94
        var htlcMin tlv.RecordT[tlv.TlvType4, MilliSatoshi]
×
UNCOV
95
        var reserve tlv.RecordT[tlv.TlvType6, tlv.BigSizeT[btcutil.Amount]]
×
UNCOV
96
        csvDelay := dc.CsvDelay.Zero()
×
UNCOV
97
        maxHtlcs := dc.MaxAcceptedHTLCs.Zero()
×
UNCOV
98
        chanType := dc.ChannelType.Zero()
×
UNCOV
99
        nonce := dc.LocalNonce.Zero()
×
UNCOV
100

×
UNCOV
101
        // Parse all known records and extra data.
×
UNCOV
102
        knownRecords, extraData, err := ParseAndExtractExtraData(
×
UNCOV
103
                tlvRecords, &dustLimit, &maxValue, &htlcMin, &reserve,
×
UNCOV
104
                &csvDelay, &maxHtlcs, &chanType, &nonce,
×
UNCOV
105
        )
×
UNCOV
106
        if err != nil {
×
107
                return err
×
108
        }
×
109

110
        // Check the results of the TLV Stream decoding and appropriately set
111
        // message fields.
UNCOV
112
        if _, ok := knownRecords[dc.DustLimit.TlvType()]; ok {
×
UNCOV
113
                dc.DustLimit = tlv.SomeRecordT(dustLimit)
×
UNCOV
114
        }
×
UNCOV
115
        if _, ok := knownRecords[dc.MaxValueInFlight.TlvType()]; ok {
×
UNCOV
116
                dc.MaxValueInFlight = tlv.SomeRecordT(maxValue)
×
UNCOV
117
        }
×
UNCOV
118
        if _, ok := knownRecords[dc.HtlcMinimum.TlvType()]; ok {
×
UNCOV
119
                dc.HtlcMinimum = tlv.SomeRecordT(htlcMin)
×
UNCOV
120
        }
×
UNCOV
121
        if _, ok := knownRecords[dc.ChannelReserve.TlvType()]; ok {
×
UNCOV
122
                dc.ChannelReserve = tlv.SomeRecordT(reserve)
×
UNCOV
123
        }
×
UNCOV
124
        if _, ok := knownRecords[dc.CsvDelay.TlvType()]; ok {
×
UNCOV
125
                dc.CsvDelay = tlv.SomeRecordT(csvDelay)
×
UNCOV
126
        }
×
UNCOV
127
        if _, ok := knownRecords[dc.MaxAcceptedHTLCs.TlvType()]; ok {
×
UNCOV
128
                dc.MaxAcceptedHTLCs = tlv.SomeRecordT(maxHtlcs)
×
UNCOV
129
        }
×
UNCOV
130
        if _, ok := knownRecords[dc.ChannelType.TlvType()]; ok {
×
UNCOV
131
                dc.ChannelType = tlv.SomeRecordT(chanType)
×
UNCOV
132
        }
×
UNCOV
133
        if _, ok := knownRecords[dc.LocalNonce.TlvType()]; ok {
×
UNCOV
134
                dc.LocalNonce = tlv.SomeRecordT(nonce)
×
UNCOV
135
        }
×
136

UNCOV
137
        dc.ExtraData = extraData
×
UNCOV
138

×
UNCOV
139
        return nil
×
140
}
141

142
// MsgType returns the MessageType code which uniquely identifies this message
143
// as a DynCommit on the wire.
144
//
145
// This is part of the lnwire.Message interface.
UNCOV
146
func (dc *DynCommit) MsgType() MessageType {
×
UNCOV
147
        return MsgDynCommit
×
UNCOV
148
}
×
149

150
// SerializedSize returns the serialized size of the message in bytes.
151
//
152
// This is part of the lnwire.SizeableMessage interface.
153
func (dc *DynCommit) SerializedSize() (uint32, error) {
×
154
        return MessageSerializedSize(dc)
×
155
}
×
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