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

lightningnetwork / lnd / 9184489199

22 May 2024 02:34AM UTC coverage: 48.835% (-9.6%) from 58.452%
9184489199

push

github

web-flow
Merge pull request #8762 from ProofOfKeags/bugfix/ping-stability

Adjust ping parameters to improve tor stability

22 of 24 new or added lines in 2 files covered. (91.67%)

24816 existing lines in 399 files now uncovered.

91733 of 187843 relevant lines covered (48.83%)

1.04 hits per line

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

65.45
/lnwire/commit_sig.go
1
package lnwire
2

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

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

10
// CommitSig is sent by either side to stage any pending HTLC's in the
11
// receiver's pending set into a new commitment state. Implicitly, the new
12
// commitment transaction constructed which has been signed by CommitSig
13
// includes all HTLC's in the remote node's pending set. A CommitSig message
14
// may be sent after a series of UpdateAddHTLC/UpdateFulfillHTLC messages in
15
// order to batch add several HTLC's with a single signature covering all
16
// implicitly accepted HTLC's.
17
type CommitSig struct {
18
        // ChanID uniquely identifies to which currently active channel this
19
        // CommitSig applies to.
20
        ChanID ChannelID
21

22
        // CommitSig is Alice's signature for Bob's new commitment transaction.
23
        // Alice is able to send this signature without requesting any
24
        // additional data due to the piggybacking of Bob's next revocation
25
        // hash in his prior RevokeAndAck message, as well as the canonical
26
        // ordering used for all inputs/outputs within commitment transactions.
27
        // If initiating a new commitment state, this signature should ONLY
28
        // cover all of the sending party's pending log updates, and the log
29
        // updates of the remote party that have been ACK'd.
30
        CommitSig Sig
31

32
        // HtlcSigs is a signature for each relevant HTLC output within the
33
        // created commitment. The order of the signatures is expected to be
34
        // identical to the placement of the HTLC's within the BIP 69 sorted
35
        // commitment transaction. For each outgoing HTLC (from the PoV of the
36
        // sender of this message), a signature for an HTLC timeout transaction
37
        // should be signed, for each incoming HTLC the HTLC timeout
38
        // transaction should be signed.
39
        HtlcSigs []Sig
40

41
        // PartialSig is used to transmit a musig2 extended partial signature
42
        // that also carries along the public nonce of the signer.
43
        //
44
        // NOTE: This field is only populated if a musig2 taproot channel is
45
        // being signed for. In this case, the above Sig type MUST be blank.
46
        PartialSig OptPartialSigWithNonceTLV
47

48
        // ExtraData is the set of data that was appended to this message to
49
        // fill out the full maximum transport message size. These fields can
50
        // be used to specify optional data such as custom TLV fields.
51
        ExtraData ExtraOpaqueData
52
}
53

54
// NewCommitSig creates a new empty CommitSig message.
UNCOV
55
func NewCommitSig() *CommitSig {
×
UNCOV
56
        return &CommitSig{
×
UNCOV
57
                ExtraData: make([]byte, 0),
×
UNCOV
58
        }
×
UNCOV
59
}
×
60

61
// A compile time check to ensure CommitSig implements the lnwire.Message
62
// interface.
63
var _ Message = (*CommitSig)(nil)
64

65
// Decode deserializes a serialized CommitSig message stored in the
66
// passed io.Reader observing the specified protocol version.
67
//
68
// This is part of the lnwire.Message interface.
69
func (c *CommitSig) Decode(r io.Reader, pver uint32) error {
2✔
70
        err := ReadElements(r,
2✔
71
                &c.ChanID,
2✔
72
                &c.CommitSig,
2✔
73
                &c.HtlcSigs,
2✔
74
        )
2✔
75
        if err != nil {
2✔
UNCOV
76
                return err
×
UNCOV
77
        }
×
78

79
        var tlvRecords ExtraOpaqueData
2✔
80
        if err := ReadElements(r, &tlvRecords); err != nil {
2✔
81
                return err
×
82
        }
×
83

84
        partialSig := c.PartialSig.Zero()
2✔
85
        typeMap, err := tlvRecords.ExtractRecords(&partialSig)
2✔
86
        if err != nil {
2✔
UNCOV
87
                return err
×
UNCOV
88
        }
×
89

90
        // Set the corresponding TLV types if they were included in the stream.
91
        if val, ok := typeMap[c.PartialSig.TlvType()]; ok && val == nil {
4✔
92
                c.PartialSig = tlv.SomeRecordT(partialSig)
2✔
93
        }
2✔
94

95
        if len(tlvRecords) != 0 {
4✔
96
                c.ExtraData = tlvRecords
2✔
97
        }
2✔
98

99
        return nil
2✔
100
}
101

102
// Encode serializes the target CommitSig into the passed io.Writer
103
// observing the protocol version specified.
104
//
105
// This is part of the lnwire.Message interface.
106
func (c *CommitSig) Encode(w *bytes.Buffer, pver uint32) error {
2✔
107
        recordProducers := make([]tlv.RecordProducer, 0, 1)
2✔
108
        c.PartialSig.WhenSome(func(sig PartialSigWithNonceTLV) {
4✔
109
                recordProducers = append(recordProducers, &sig)
2✔
110
        })
2✔
111
        err := EncodeMessageExtraData(&c.ExtraData, recordProducers...)
2✔
112
        if err != nil {
2✔
113
                return err
×
114
        }
×
115

116
        if err := WriteChannelID(w, c.ChanID); err != nil {
2✔
117
                return err
×
118
        }
×
119

120
        if err := WriteSig(w, c.CommitSig); err != nil {
2✔
121
                return err
×
122
        }
×
123

124
        if err := WriteSigs(w, c.HtlcSigs); err != nil {
2✔
125
                return err
×
126
        }
×
127

128
        return WriteBytes(w, c.ExtraData)
2✔
129
}
130

131
// MsgType returns the integer uniquely identifying this message type on the
132
// wire.
133
//
134
// This is part of the lnwire.Message interface.
135
func (c *CommitSig) MsgType() MessageType {
2✔
136
        return MsgCommitSig
2✔
137
}
2✔
138

139
// TargetChanID returns the channel id of the link for which this message is
140
// intended.
141
//
142
// NOTE: Part of peer.LinkUpdater interface.
143
func (c *CommitSig) TargetChanID() ChannelID {
2✔
144
        return c.ChanID
2✔
145
}
2✔
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

© 2026 Coveralls, Inc