github.com/decred/dcrlnd@v0.7.6/lnwire/funding_created.go (about) 1 package lnwire 2 3 import ( 4 "bytes" 5 "io" 6 7 "github.com/decred/dcrd/wire" 8 ) 9 10 // FundingCreated is sent from Alice (the initiator) to Bob (the responder), 11 // once Alice receives Bob's contributions as well as his channel constraints. 12 // Once bob receives this message, he'll gain access to an immediately 13 // broadcastable commitment transaction and will reply with a signature for 14 // Alice's version of the commitment transaction. 15 type FundingCreated struct { 16 // PendingChannelID serves to uniquely identify the future channel 17 // created by the initiated single funder workflow. 18 PendingChannelID [32]byte 19 20 // FundingPoint is the outpoint of the funding transaction created by 21 // Alice. With this, Bob is able to generate both his version and 22 // Alice's version of the commitment transaction. 23 FundingPoint wire.OutPoint 24 25 // CommitSig is Alice's signature from Bob's version of the commitment 26 // transaction. 27 CommitSig Sig 28 29 // ExtraData is the set of data that was appended to this message to 30 // fill out the full maximum transport message size. These fields can 31 // be used to specify optional data such as custom TLV fields. 32 ExtraData ExtraOpaqueData 33 } 34 35 // A compile time check to ensure FundingCreated implements the lnwire.Message 36 // interface. 37 var _ Message = (*FundingCreated)(nil) 38 39 // Encode serializes the target FundingCreated into the passed io.Writer 40 // implementation. Serialization will observe the rules defined by the passed 41 // protocol version. 42 // 43 // This is part of the lnwire.Message interface. 44 func (f *FundingCreated) Encode(w *bytes.Buffer, pver uint32) error { 45 if err := WriteBytes(w, f.PendingChannelID[:]); err != nil { 46 return err 47 } 48 49 if err := WriteOutPoint(w, f.FundingPoint); err != nil { 50 return err 51 } 52 53 if err := WriteSig(w, f.CommitSig); err != nil { 54 return err 55 } 56 57 return WriteBytes(w, f.ExtraData) 58 } 59 60 // Decode deserializes the serialized FundingCreated stored in the passed 61 // io.Reader into the target FundingCreated using the deserialization rules 62 // defined by the passed protocol version. 63 // 64 // This is part of the lnwire.Message interface. 65 func (f *FundingCreated) Decode(r io.Reader, pver uint32) error { 66 return ReadElements( 67 r, f.PendingChannelID[:], &f.FundingPoint, &f.CommitSig, 68 &f.ExtraData, 69 ) 70 } 71 72 // MsgType returns the uint32 code which uniquely identifies this message as a 73 // FundingCreated on the wire. 74 // 75 // This is part of the lnwire.Message interface. 76 func (f *FundingCreated) MsgType() MessageType { 77 return MsgFundingCreated 78 }