github.com/decred/dcrlnd@v0.7.6/lnwire/announcement_signatures.go (about) 1 package lnwire 2 3 import ( 4 "bytes" 5 "io" 6 ) 7 8 // AnnounceSignatures is a direct message between two endpoints of a 9 // channel and serves as an opt-in mechanism to allow the announcement of 10 // the channel to the rest of the network. It contains the necessary 11 // signatures by the sender to construct the channel announcement message. 12 type AnnounceSignatures struct { 13 // ChannelID is the unique description of the funding transaction. 14 // Channel id is better for users and debugging and short channel id is 15 // used for quick test on existence of the particular utxo inside the 16 // block chain, because it contains information about block. 17 ChannelID ChannelID 18 19 // ShortChannelID is the unique description of the funding 20 // transaction. It is constructed with the most significant 3 bytes 21 // as the block height, the next 3 bytes indicating the transaction 22 // index within the block, and the least significant two bytes 23 // indicating the output index which pays to the channel. 24 ShortChannelID ShortChannelID 25 26 // NodeSignature is the signature which contains the signed announce 27 // channel message, by this signature we proof that we possess of the 28 // node pub key and creating the reference node_key -> decred_key. 29 NodeSignature Sig 30 31 // DecredSignature is the signature which contains the signed node 32 // public key, by this signature we proof that we possess of the 33 // bitcoin key and and creating the reverse reference decred_key -> 34 // node_key. 35 DecredSignature Sig 36 37 // ExtraOpaqueData is the set of data that was appended to this 38 // message, some of which we may not actually know how to iterate or 39 // parse. By holding onto this data, we ensure that we're able to 40 // properly validate the set of signatures that cover these new fields, 41 // and ensure we're able to make upgrades to the network in a forwards 42 // compatible manner. 43 ExtraOpaqueData ExtraOpaqueData 44 } 45 46 // A compile time check to ensure AnnounceSignatures implements the 47 // lnwire.Message interface. 48 var _ Message = (*AnnounceSignatures)(nil) 49 50 // Decode deserializes a serialized AnnounceSignatures stored in the passed 51 // io.Reader observing the specified protocol version. 52 // 53 // This is part of the lnwire.Message interface. 54 func (a *AnnounceSignatures) Decode(r io.Reader, pver uint32) error { 55 return ReadElements(r, 56 &a.ChannelID, 57 &a.ShortChannelID, 58 &a.NodeSignature, 59 &a.DecredSignature, 60 &a.ExtraOpaqueData, 61 ) 62 } 63 64 // Encode serializes the target AnnounceSignatures into the passed io.Writer 65 // observing the protocol version specified. 66 // 67 // This is part of the lnwire.Message interface. 68 func (a *AnnounceSignatures) Encode(w *bytes.Buffer, pver uint32) error { 69 if err := WriteChannelID(w, a.ChannelID); err != nil { 70 return err 71 } 72 73 if err := WriteShortChannelID(w, a.ShortChannelID); err != nil { 74 return err 75 } 76 77 if err := WriteSig(w, a.NodeSignature); err != nil { 78 return err 79 } 80 81 if err := WriteSig(w, a.DecredSignature); err != nil { 82 return err 83 } 84 85 return WriteBytes(w, a.ExtraOpaqueData) 86 } 87 88 // MsgType returns the integer uniquely identifying this message type on the 89 // wire. 90 // 91 // This is part of the lnwire.Message interface. 92 func (a *AnnounceSignatures) MsgType() MessageType { 93 return MsgAnnounceSignatures 94 }