github.com/decred/dcrlnd@v0.7.6/channeldb/migration/lnwire21/funding_created.go (about)

     1  package lnwire
     2  
     3  import (
     4  	"io"
     5  
     6  	"github.com/decred/dcrd/wire"
     7  )
     8  
     9  // FundingCreated is sent from Alice (the initiator) to Bob (the responder),
    10  // once Alice receives Bob's contributions as well as his channel constraints.
    11  // Once bob receives this message, he'll gain access to an immediately
    12  // broadcastable commitment transaction and will reply with a signature for
    13  // Alice's version of the commitment transaction.
    14  type FundingCreated struct {
    15  	// PendingChannelID serves to uniquely identify the future channel
    16  	// created by the initiated single funder workflow.
    17  	PendingChannelID [32]byte
    18  
    19  	// FundingPoint is the outpoint of the funding transaction created by
    20  	// Alice. With this, Bob is able to generate both his version and
    21  	// Alice's version of the commitment transaction.
    22  	FundingPoint wire.OutPoint
    23  
    24  	// CommitSig is Alice's signature from Bob's version of the commitment
    25  	// transaction.
    26  	CommitSig Sig
    27  }
    28  
    29  // A compile time check to ensure FundingCreated implements the lnwire.Message
    30  // interface.
    31  var _ Message = (*FundingCreated)(nil)
    32  
    33  // Encode serializes the target FundingCreated into the passed io.Writer
    34  // implementation. Serialization will observe the rules defined by the passed
    35  // protocol version.
    36  //
    37  // This is part of the lnwire.Message interface.
    38  func (f *FundingCreated) Encode(w io.Writer, pver uint32) error {
    39  	return WriteElements(w, f.PendingChannelID[:], f.FundingPoint, f.CommitSig)
    40  }
    41  
    42  // Decode deserializes the serialized FundingCreated stored in the passed
    43  // io.Reader into the target FundingCreated using the deserialization rules
    44  // defined by the passed protocol version.
    45  //
    46  // This is part of the lnwire.Message interface.
    47  func (f *FundingCreated) Decode(r io.Reader, pver uint32) error {
    48  	return ReadElements(r, f.PendingChannelID[:], &f.FundingPoint, &f.CommitSig)
    49  }
    50  
    51  // MsgType returns the uint32 code which uniquely identifies this message as a
    52  // FundingCreated on the wire.
    53  //
    54  // This is part of the lnwire.Message interface.
    55  func (f *FundingCreated) MsgType() MessageType {
    56  	return MsgFundingCreated
    57  }
    58  
    59  // MaxPayloadLength returns the maximum allowed payload length for a
    60  // FundingCreated message.
    61  //
    62  // This is part of the lnwire.Message interface.
    63  func (f *FundingCreated) MaxPayloadLength(uint32) uint32 {
    64  	// 32 + 32 + 2 + 64
    65  	return 130
    66  }