2017-01-31 05:45:28 +03:00
|
|
|
package lnwire
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io"
|
|
|
|
|
2018-06-05 04:34:16 +03:00
|
|
|
"github.com/btcsuite/btcd/btcec"
|
2017-01-31 05:45:28 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
// FundingLocked is the message that both parties to a new channel creation
|
2017-04-17 01:22:20 +03:00
|
|
|
// send once they have observed the funding transaction being confirmed on the
|
|
|
|
// blockchain. FundingLocked contains the signatures necessary for the channel
|
|
|
|
// participants to advertise the existence of the channel to the rest of the
|
|
|
|
// network.
|
2017-01-31 05:45:28 +03:00
|
|
|
type FundingLocked struct {
|
2017-04-17 01:22:20 +03:00
|
|
|
// ChanID is the outpoint of the channel's funding transaction. This
|
|
|
|
// can be used to query for the channel in the database.
|
|
|
|
ChanID ChannelID
|
2017-01-31 05:45:28 +03:00
|
|
|
|
2017-04-17 01:22:20 +03:00
|
|
|
// NextPerCommitmentPoint is the secret that can be used to revoke the
|
|
|
|
// next commitment transaction for the channel.
|
2017-01-31 05:45:28 +03:00
|
|
|
NextPerCommitmentPoint *btcec.PublicKey
|
2020-01-28 04:25:36 +03:00
|
|
|
|
|
|
|
// ExtraData is the set of data that was appended to this message to
|
|
|
|
// fill out the full maximum transport message size. These fields can
|
|
|
|
// be used to specify optional data such as custom TLV fields.
|
|
|
|
ExtraData ExtraOpaqueData
|
2017-01-31 05:45:28 +03:00
|
|
|
}
|
|
|
|
|
2017-04-17 01:22:20 +03:00
|
|
|
// NewFundingLocked creates a new FundingLocked message, populating it with the
|
|
|
|
// necessary IDs and revocation secret.
|
|
|
|
func NewFundingLocked(cid ChannelID, npcp *btcec.PublicKey) *FundingLocked {
|
2017-01-31 05:45:28 +03:00
|
|
|
return &FundingLocked{
|
2017-04-17 01:22:20 +03:00
|
|
|
ChanID: cid,
|
2017-01-31 05:45:28 +03:00
|
|
|
NextPerCommitmentPoint: npcp,
|
2020-01-28 04:25:36 +03:00
|
|
|
ExtraData: make([]byte, 0),
|
2017-01-31 05:45:28 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-17 01:22:20 +03:00
|
|
|
// A compile time check to ensure FundingLocked implements the lnwire.Message
|
|
|
|
// interface.
|
2017-01-31 05:45:28 +03:00
|
|
|
var _ Message = (*FundingLocked)(nil)
|
|
|
|
|
2017-04-17 01:22:20 +03:00
|
|
|
// Decode deserializes the serialized FundingLocked message stored in the
|
|
|
|
// passed io.Reader into the target FundingLocked using the deserialization
|
2017-01-31 05:45:28 +03:00
|
|
|
// rules defined by the passed protocol version.
|
|
|
|
//
|
|
|
|
// This is part of the lnwire.Message interface.
|
|
|
|
func (c *FundingLocked) Decode(r io.Reader, pver uint32) error {
|
2018-12-10 05:27:41 +03:00
|
|
|
return ReadElements(r,
|
2017-04-17 01:22:20 +03:00
|
|
|
&c.ChanID,
|
2020-01-28 04:25:36 +03:00
|
|
|
&c.NextPerCommitmentPoint,
|
|
|
|
&c.ExtraData,
|
|
|
|
)
|
2017-01-31 05:45:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Encode serializes the target FundingLocked message into the passed io.Writer
|
|
|
|
// implementation. Serialization will observe the rules defined by the passed
|
|
|
|
// protocol version.
|
|
|
|
//
|
|
|
|
// This is part of the lnwire.Message interface.
|
|
|
|
func (c *FundingLocked) Encode(w io.Writer, pver uint32) error {
|
2018-12-10 05:27:41 +03:00
|
|
|
return WriteElements(w,
|
2017-04-17 01:22:20 +03:00
|
|
|
c.ChanID,
|
2020-01-28 04:25:36 +03:00
|
|
|
c.NextPerCommitmentPoint,
|
|
|
|
c.ExtraData,
|
|
|
|
)
|
2017-01-31 05:45:28 +03:00
|
|
|
}
|
|
|
|
|
2017-04-20 01:57:43 +03:00
|
|
|
// MsgType returns the uint32 code which uniquely identifies this message as a
|
2017-01-31 05:45:28 +03:00
|
|
|
// FundingLocked message on the wire.
|
|
|
|
//
|
|
|
|
// This is part of the lnwire.Message interface.
|
2017-04-20 01:57:43 +03:00
|
|
|
func (c *FundingLocked) MsgType() MessageType {
|
|
|
|
return MsgFundingLocked
|
2017-01-31 05:45:28 +03:00
|
|
|
}
|