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

lightningnetwork / lnd / 13236757158

10 Feb 2025 08:39AM UTC coverage: 57.649% (-1.2%) from 58.815%
13236757158

Pull #9493

github

ziggie1984
lncli: for some cmds we don't replace the data of the response.

For some cmds it is not very practical to replace the json output
because we might pipe it into other commands. For example when
creating the route we want to pipe it into sendtoRoute.
Pull Request #9493: For some lncli cmds we should not replace the content with other data

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

19535 existing lines in 252 files now uncovered.

103517 of 179563 relevant lines covered (57.65%)

24878.49 hits per line

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

84.75
/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
        // CustomRecords maps TLV types to byte slices, storing arbitrary data
49
        // intended for inclusion in the ExtraData field.
50
        CustomRecords CustomRecords
51

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

58
// NewCommitSig creates a new empty CommitSig message.
59
func NewCommitSig() *CommitSig {
100✔
60
        return &CommitSig{}
100✔
61
}
100✔
62

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

67
// Decode deserializes a serialized CommitSig message stored in the
68
// passed io.Reader observing the specified protocol version.
69
//
70
// This is part of the lnwire.Message interface.
71
func (c *CommitSig) Decode(r io.Reader, pver uint32) error {
2,231✔
72
        // msgExtraData is a temporary variable used to read the message extra
2,231✔
73
        // data field from the reader.
2,231✔
74
        var msgExtraData ExtraOpaqueData
2,231✔
75

2,231✔
76
        err := ReadElements(r,
2,231✔
77
                &c.ChanID,
2,231✔
78
                &c.CommitSig,
2,231✔
79
                &c.HtlcSigs,
2,231✔
80
                &msgExtraData,
2,231✔
81
        )
2,231✔
82
        if err != nil {
2,245✔
83
                return err
14✔
84
        }
14✔
85

86
        // Extract TLV records from the extra data field.
87
        partialSig := c.PartialSig.Zero()
2,217✔
88

2,217✔
89
        customRecords, parsed, extraData, err := ParseAndExtractCustomRecords(
2,217✔
90
                msgExtraData, &partialSig,
2,217✔
91
        )
2,217✔
92
        if err != nil {
2,265✔
93
                return err
48✔
94
        }
48✔
95

96
        // Set the corresponding TLV types if they were included in the stream.
97
        if _, ok := parsed[partialSig.TlvType()]; ok {
2,222✔
98
                c.PartialSig = tlv.SomeRecordT(partialSig)
53✔
99
        }
53✔
100

101
        c.CustomRecords = customRecords
2,169✔
102
        c.ExtraData = extraData
2,169✔
103

2,169✔
104
        return nil
2,169✔
105
}
106

107
// Encode serializes the target CommitSig into the passed io.Writer
108
// observing the protocol version specified.
109
//
110
// This is part of the lnwire.Message interface.
111
func (c *CommitSig) Encode(w *bytes.Buffer, pver uint32) error {
4,179✔
112
        recordProducers := make([]tlv.RecordProducer, 0, 1)
4,179✔
113
        c.PartialSig.WhenSome(func(sig PartialSigWithNonceTLV) {
4,232✔
114
                recordProducers = append(recordProducers, &sig)
53✔
115
        })
53✔
116

117
        extraData, err := MergeAndEncode(
4,179✔
118
                recordProducers, c.ExtraData, c.CustomRecords,
4,179✔
119
        )
4,179✔
120
        if err != nil {
4,180✔
121
                return err
1✔
122
        }
1✔
123

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

128
        if err := WriteSig(w, c.CommitSig); err != nil {
4,178✔
129
                return err
×
130
        }
×
131

132
        if err := WriteSigs(w, c.HtlcSigs); err != nil {
4,178✔
133
                return err
×
134
        }
×
135

136
        return WriteBytes(w, extraData)
4,178✔
137
}
138

139
// MsgType returns the integer uniquely identifying this message type on the
140
// wire.
141
//
142
// This is part of the lnwire.Message interface.
143
func (c *CommitSig) MsgType() MessageType {
3,398✔
144
        return MsgCommitSig
3,398✔
145
}
3,398✔
146

147
// TargetChanID returns the channel id of the link for which this message is
148
// intended.
149
//
150
// NOTE: Part of peer.LinkUpdater interface.
UNCOV
151
func (c *CommitSig) TargetChanID() ChannelID {
×
UNCOV
152
        return c.ChanID
×
UNCOV
153
}
×
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