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

lightningnetwork / lnd / 10295705138

08 Aug 2024 04:01AM UTC coverage: 50.268% (-8.2%) from 58.51%
10295705138

push

github

web-flow
Merge pull request #8986 from Roasbeef/min-relay-fee-rpc

lnrpc: add new min_relay_fee response to EstimateFee

0 of 9 new or added lines in 2 files covered. (0.0%)

23037 existing lines in 393 files now uncovered.

95956 of 190889 relevant lines covered (50.27%)

2.09 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 {
4✔
70
        err := ReadElements(r,
4✔
71
                &c.ChanID,
4✔
72
                &c.CommitSig,
4✔
73
                &c.HtlcSigs,
4✔
74
        )
4✔
75
        if err != nil {
4✔
UNCOV
76
                return err
×
UNCOV
77
        }
×
78

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

84
        partialSig := c.PartialSig.Zero()
4✔
85
        typeMap, err := tlvRecords.ExtractRecords(&partialSig)
4✔
86
        if err != nil {
4✔
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 {
8✔
92
                c.PartialSig = tlv.SomeRecordT(partialSig)
4✔
93
        }
4✔
94

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

99
        return nil
4✔
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 {
4✔
107
        recordProducers := make([]tlv.RecordProducer, 0, 1)
4✔
108
        c.PartialSig.WhenSome(func(sig PartialSigWithNonceTLV) {
8✔
109
                recordProducers = append(recordProducers, &sig)
4✔
110
        })
4✔
111
        err := EncodeMessageExtraData(&c.ExtraData, recordProducers...)
4✔
112
        if err != nil {
4✔
113
                return err
×
114
        }
×
115

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

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

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

128
        return WriteBytes(w, c.ExtraData)
4✔
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 {
4✔
136
        return MsgCommitSig
4✔
137
}
4✔
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 {
4✔
144
        return c.ChanID
4✔
145
}
4✔
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