2017-07-29 01:24:34 +02:00
|
|
|
package lnwire
|
|
|
|
|
|
|
|
import (
|
2021-06-17 08:17:30 +02:00
|
|
|
"bytes"
|
2017-07-29 01:24:34 +02:00
|
|
|
"io"
|
|
|
|
|
2018-06-05 03:34:16 +02:00
|
|
|
"github.com/btcsuite/btcd/wire"
|
2017-07-29 01:24:34 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
// FundingCreated is sent from Alice (the initiator) to Bob (the responder),
|
|
|
|
// once Alice receives Bob's contributions as well as his channel constraints.
|
|
|
|
// Once bob receives this message, he'll gain access to an immediately
|
|
|
|
// broadcastable commitment transaction and will reply with a signature for
|
|
|
|
// Alice's version of the commitment transaction.
|
|
|
|
type FundingCreated struct {
|
|
|
|
// PendingChannelID serves to uniquely identify the future channel
|
|
|
|
// created by the initiated single funder workflow.
|
|
|
|
PendingChannelID [32]byte
|
|
|
|
|
|
|
|
// FundingPoint is the outpoint of the funding transaction created by
|
|
|
|
// Alice. With this, Bob is able to generate both his version and
|
|
|
|
// Alice's version of the commitment transaction.
|
|
|
|
FundingPoint wire.OutPoint
|
|
|
|
|
|
|
|
// CommitSig is Alice's signature from Bob's version of the commitment
|
|
|
|
// transaction.
|
2018-01-31 04:41:52 +01:00
|
|
|
CommitSig Sig
|
2020-01-28 02:25:36 +01: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-07-29 01:24:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// A compile time check to ensure FundingCreated implements the lnwire.Message
|
|
|
|
// interface.
|
|
|
|
var _ Message = (*FundingCreated)(nil)
|
|
|
|
|
|
|
|
// Encode serializes the target FundingCreated 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.
|
2021-06-17 08:17:30 +02:00
|
|
|
func (f *FundingCreated) Encode(w *bytes.Buffer, pver uint32) error {
|
2021-06-18 09:03:43 +02:00
|
|
|
if err := WriteBytes(w, f.PendingChannelID[:]); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := WriteOutPoint(w, f.FundingPoint); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := WriteSig(w, f.CommitSig); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return WriteBytes(w, f.ExtraData)
|
2017-07-29 01:24:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Decode deserializes the serialized FundingCreated stored in the passed
|
|
|
|
// io.Reader into the target FundingCreated using the deserialization rules
|
|
|
|
// defined by the passed protocol version.
|
|
|
|
//
|
|
|
|
// This is part of the lnwire.Message interface.
|
|
|
|
func (f *FundingCreated) Decode(r io.Reader, pver uint32) error {
|
2020-01-28 02:25:36 +01:00
|
|
|
return ReadElements(
|
|
|
|
r, f.PendingChannelID[:], &f.FundingPoint, &f.CommitSig,
|
|
|
|
&f.ExtraData,
|
|
|
|
)
|
2017-07-29 01:24:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// MsgType returns the uint32 code which uniquely identifies this message as a
|
|
|
|
// FundingCreated on the wire.
|
|
|
|
//
|
|
|
|
// This is part of the lnwire.Message interface.
|
|
|
|
func (f *FundingCreated) MsgType() MessageType {
|
|
|
|
return MsgFundingCreated
|
|
|
|
}
|