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

lightningnetwork / lnd / 13035292482

29 Jan 2025 03:59PM UTC coverage: 49.3% (-9.5%) from 58.777%
13035292482

Pull #9456

github

mohamedawnallah
docs: update release-notes-0.19.0.md

In this commit, we warn users about the removal
of RPCs `SendToRoute`, `SendToRouteSync`, `SendPayment`,
and `SendPaymentSync` in the next release 0.20.
Pull Request #9456: lnrpc+docs: deprecate warning `SendToRoute`, `SendToRouteSync`, `SendPayment`, and `SendPaymentSync` in Release 0.19

100634 of 204126 relevant lines covered (49.3%)

1.54 hits per line

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

75.0
/lnwire/channel_ready.go
1
package lnwire
2

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

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

11
// ChannelReady is the message that both parties to a new channel creation
12
// send once they have observed the funding transaction being confirmed on the
13
// blockchain. ChannelReady contains the signatures necessary for the channel
14
// participants to advertise the existence of the channel to the rest of the
15
// network.
16
type ChannelReady struct {
17
        // ChanID is the outpoint of the channel's funding transaction. This
18
        // can be used to query for the channel in the database.
19
        ChanID ChannelID
20

21
        // NextPerCommitmentPoint is the secret that can be used to revoke the
22
        // next commitment transaction for the channel.
23
        NextPerCommitmentPoint *btcec.PublicKey
24

25
        // AliasScid is an alias ShortChannelID used to refer to the underlying
26
        // channel. It can be used instead of the confirmed on-chain
27
        // ShortChannelID for forwarding.
28
        AliasScid *ShortChannelID
29

30
        // NextLocalNonce is an optional field that stores a local musig2 nonce.
31
        // This will only be populated if the simple taproot channels type was
32
        // negotiated. This is the local nonce that will be used by the sender
33
        // to accept a new commitment state transition.
34
        NextLocalNonce OptMusig2NonceTLV
35

36
        // AnnouncementNodeNonce is an optional field that stores a public
37
        // nonce that will be used along with the node's ID key during signing
38
        // of the ChannelAnnouncement2 message.
39
        AnnouncementNodeNonce tlv.OptionalRecordT[tlv.TlvType0, Musig2Nonce]
40

41
        // AnnouncementBitcoinNonce is an optional field that stores a public
42
        // nonce that will be used along with the node's bitcoin key during
43
        // signing of the ChannelAnnouncement2 message.
44
        AnnouncementBitcoinNonce tlv.OptionalRecordT[tlv.TlvType2, Musig2Nonce]
45

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

52
// NewChannelReady creates a new ChannelReady message, populating it with the
53
// necessary IDs and revocation secret.
54
func NewChannelReady(cid ChannelID, npcp *btcec.PublicKey) *ChannelReady {
3✔
55
        return &ChannelReady{
3✔
56
                ChanID:                 cid,
3✔
57
                NextPerCommitmentPoint: npcp,
3✔
58
                ExtraData:              nil,
3✔
59
        }
3✔
60
}
3✔
61

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

66
// Decode deserializes the serialized ChannelReady message stored in the
67
// passed io.Reader into the target ChannelReady using the deserialization
68
// rules defined by the passed protocol version.
69
//
70
// This is part of the lnwire.Message interface.
71
func (c *ChannelReady) Decode(r io.Reader, _ uint32) error {
3✔
72
        // Read all the mandatory fields in the message.
3✔
73
        err := ReadElements(r,
3✔
74
                &c.ChanID,
3✔
75
                &c.NextPerCommitmentPoint,
3✔
76
        )
3✔
77
        if err != nil {
3✔
78
                return err
×
79
        }
×
80

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

86
        // Next we'll parse out the set of known records. For now, this is just
87
        // the AliasScidRecordType.
88
        var (
3✔
89
                aliasScid  ShortChannelID
3✔
90
                localNonce = c.NextLocalNonce.Zero()
3✔
91
                nodeNonce  = tlv.ZeroRecordT[tlv.TlvType0, Musig2Nonce]()
3✔
92
                btcNonce   = tlv.ZeroRecordT[tlv.TlvType2, Musig2Nonce]()
3✔
93
        )
3✔
94
        typeMap, err := tlvRecords.ExtractRecords(
3✔
95
                &btcNonce, &aliasScid, &nodeNonce, &localNonce,
3✔
96
        )
3✔
97
        if err != nil {
3✔
98
                return err
×
99
        }
×
100

101
        // We'll only set AliasScid if the corresponding TLV type was included
102
        // in the stream.
103
        if val, ok := typeMap[AliasScidRecordType]; ok && val == nil {
6✔
104
                c.AliasScid = &aliasScid
3✔
105
        }
3✔
106
        if val, ok := typeMap[c.NextLocalNonce.TlvType()]; ok && val == nil {
6✔
107
                c.NextLocalNonce = tlv.SomeRecordT(localNonce)
3✔
108
        }
3✔
109
        val, ok := typeMap[c.AnnouncementBitcoinNonce.TlvType()]
3✔
110
        if ok && val == nil {
3✔
111
                c.AnnouncementBitcoinNonce = tlv.SomeRecordT(btcNonce)
×
112
        }
×
113
        val, ok = typeMap[c.AnnouncementNodeNonce.TlvType()]
3✔
114
        if ok && val == nil {
3✔
115
                c.AnnouncementNodeNonce = tlv.SomeRecordT(nodeNonce)
×
116
        }
×
117

118
        if len(tlvRecords) != 0 {
6✔
119
                c.ExtraData = tlvRecords
3✔
120
        }
3✔
121

122
        return nil
3✔
123
}
124

125
// Encode serializes the target ChannelReady message into the passed io.Writer
126
// implementation. Serialization will observe the rules defined by the passed
127
// protocol version.
128
//
129
// This is part of the lnwire.Message interface.
130
func (c *ChannelReady) Encode(w *bytes.Buffer, _ uint32) error {
3✔
131
        if err := WriteChannelID(w, c.ChanID); err != nil {
3✔
132
                return err
×
133
        }
×
134

135
        if err := WritePublicKey(w, c.NextPerCommitmentPoint); err != nil {
3✔
136
                return err
×
137
        }
×
138

139
        // We'll only encode the AliasScid in a TLV segment if it exists.
140
        recordProducers := make([]tlv.RecordProducer, 0, 4)
3✔
141
        if c.AliasScid != nil {
6✔
142
                recordProducers = append(recordProducers, c.AliasScid)
3✔
143
        }
3✔
144
        c.NextLocalNonce.WhenSome(func(localNonce Musig2NonceTLV) {
6✔
145
                recordProducers = append(recordProducers, &localNonce)
3✔
146
        })
3✔
147
        c.AnnouncementBitcoinNonce.WhenSome(
3✔
148
                func(nonce tlv.RecordT[tlv.TlvType2, Musig2Nonce]) {
3✔
149
                        recordProducers = append(recordProducers, &nonce)
×
150
                },
×
151
        )
152
        c.AnnouncementNodeNonce.WhenSome(
3✔
153
                func(nonce tlv.RecordT[tlv.TlvType0, Musig2Nonce]) {
3✔
154
                        recordProducers = append(recordProducers, &nonce)
×
155
                },
×
156
        )
157

158
        err := EncodeMessageExtraData(&c.ExtraData, recordProducers...)
3✔
159
        if err != nil {
3✔
160
                return err
×
161
        }
×
162

163
        return WriteBytes(w, c.ExtraData)
3✔
164
}
165

166
// MsgType returns the uint32 code which uniquely identifies this message as a
167
// ChannelReady message on the wire.
168
//
169
// This is part of the lnwire.Message interface.
170
func (c *ChannelReady) MsgType() MessageType {
3✔
171
        return MsgChannelReady
3✔
172
}
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