github.com/decred/dcrlnd@v0.7.6/lnwire/funding_signed.go (about) 1 package lnwire 2 3 import ( 4 "bytes" 5 "io" 6 ) 7 8 // FundingSigned is sent from Bob (the responder) to Alice (the initiator) 9 // after receiving the funding outpoint and her signature for Bob's version of 10 // the commitment transaction. 11 type FundingSigned struct { 12 // ChannelPoint is the particular active channel that this 13 // FundingSigned is bound to. 14 ChanID ChannelID 15 16 // CommitSig is Bob's signature for Alice's version of the commitment 17 // transaction. 18 CommitSig Sig 19 20 // ExtraData is the set of data that was appended to this message to 21 // fill out the full maximum transport message size. These fields can 22 // be used to specify optional data such as custom TLV fields. 23 ExtraData ExtraOpaqueData 24 } 25 26 // A compile time check to ensure FundingSigned implements the lnwire.Message 27 // interface. 28 var _ Message = (*FundingSigned)(nil) 29 30 // Encode serializes the target FundingSigned into the passed io.Writer 31 // implementation. Serialization will observe the rules defined by the passed 32 // protocol version. 33 // 34 // This is part of the lnwire.Message interface. 35 func (f *FundingSigned) Encode(w *bytes.Buffer, pver uint32) error { 36 if err := WriteChannelID(w, f.ChanID); err != nil { 37 return err 38 } 39 40 if err := WriteSig(w, f.CommitSig); err != nil { 41 return err 42 } 43 44 return WriteBytes(w, f.ExtraData) 45 } 46 47 // Decode deserializes the serialized FundingSigned stored in the passed 48 // io.Reader into the target FundingSigned using the deserialization rules 49 // defined by the passed protocol version. 50 // 51 // This is part of the lnwire.Message interface. 52 func (f *FundingSigned) Decode(r io.Reader, pver uint32) error { 53 return ReadElements(r, &f.ChanID, &f.CommitSig, &f.ExtraData) 54 } 55 56 // MsgType returns the uint32 code which uniquely identifies this message as a 57 // FundingSigned on the wire. 58 // 59 // This is part of the lnwire.Message interface. 60 func (f *FundingSigned) MsgType() MessageType { 61 return MsgFundingSigned 62 }