9a6bb19770
Messages: - UpdateFulfillHTLC - UpdateFee - UpdateFailMalformedHTLC - UpdateFailHTLC - UpdateAddHTLC - Shutdown - RevokeAndAck - ReplyShortChanIDsEnd - ReplyChannelRange - QueryShortChanIDs - QueryChannelRange - NodeAnnouncement - Init - GossipTimestampRange - FundingSigned - FundingLocked - FundingCreated - CommitSig - ClosingSigned - ChannelUpdate - ChannelReestablish - ChannelAnnouncement - AnnounceSignatures lnwire: update quickcheck tests, use constant for Error multi: update unit tests to pass deep equal assertions with messages In this commit, we update a series of unit tests in the code base to now pass due to the new wire message encode/decode logic. In many instances, we'll now manually set the extra bytes to an empty byte slice to avoid comparisons that fail due to one message having an empty byte slice and the other having a nil pointer.
92 lines
3.2 KiB
Go
92 lines
3.2 KiB
Go
package lnwire
|
|
|
|
import (
|
|
"io"
|
|
)
|
|
|
|
// AnnounceSignatures is a direct message between two endpoints of a
|
|
// channel and serves as an opt-in mechanism to allow the announcement of
|
|
// the channel to the rest of the network. It contains the necessary
|
|
// signatures by the sender to construct the channel announcement message.
|
|
type AnnounceSignatures struct {
|
|
// ChannelID is the unique description of the funding transaction.
|
|
// Channel id is better for users and debugging and short channel id is
|
|
// used for quick test on existence of the particular utxo inside the
|
|
// block chain, because it contains information about block.
|
|
ChannelID ChannelID
|
|
|
|
// ShortChannelID is the unique description of the funding
|
|
// transaction. It is constructed with the most significant 3 bytes
|
|
// as the block height, the next 3 bytes indicating the transaction
|
|
// index within the block, and the least significant two bytes
|
|
// indicating the output index which pays to the channel.
|
|
ShortChannelID ShortChannelID
|
|
|
|
// NodeSignature is the signature which contains the signed announce
|
|
// channel message, by this signature we proof that we possess of the
|
|
// node pub key and creating the reference node_key -> bitcoin_key.
|
|
NodeSignature Sig
|
|
|
|
// BitcoinSignature is the signature which contains the signed node
|
|
// public key, by this signature we proof that we possess of the
|
|
// bitcoin key and and creating the reverse reference bitcoin_key ->
|
|
// node_key.
|
|
BitcoinSignature Sig
|
|
|
|
// ExtraOpaqueData is the set of data that was appended to this
|
|
// message, some of which we may not actually know how to iterate or
|
|
// parse. By holding onto this data, we ensure that we're able to
|
|
// properly validate the set of signatures that cover these new fields,
|
|
// and ensure we're able to make upgrades to the network in a forwards
|
|
// compatible manner.
|
|
ExtraOpaqueData ExtraOpaqueData
|
|
}
|
|
|
|
// A compile time check to ensure AnnounceSignatures implements the
|
|
// lnwire.Message interface.
|
|
var _ Message = (*AnnounceSignatures)(nil)
|
|
|
|
// Decode deserializes a serialized AnnounceSignatures stored in the passed
|
|
// io.Reader observing the specified protocol version.
|
|
//
|
|
// This is part of the lnwire.Message interface.
|
|
func (a *AnnounceSignatures) Decode(r io.Reader, pver uint32) error {
|
|
return ReadElements(r,
|
|
&a.ChannelID,
|
|
&a.ShortChannelID,
|
|
&a.NodeSignature,
|
|
&a.BitcoinSignature,
|
|
&a.ExtraOpaqueData,
|
|
)
|
|
}
|
|
|
|
// Encode serializes the target AnnounceSignatures into the passed io.Writer
|
|
// observing the protocol version specified.
|
|
//
|
|
// This is part of the lnwire.Message interface.
|
|
func (a *AnnounceSignatures) Encode(w io.Writer, pver uint32) error {
|
|
return WriteElements(w,
|
|
a.ChannelID,
|
|
a.ShortChannelID,
|
|
a.NodeSignature,
|
|
a.BitcoinSignature,
|
|
a.ExtraOpaqueData,
|
|
)
|
|
}
|
|
|
|
// MsgType returns the integer uniquely identifying this message type on the
|
|
// wire.
|
|
//
|
|
// This is part of the lnwire.Message interface.
|
|
func (a *AnnounceSignatures) MsgType() MessageType {
|
|
return MsgAnnounceSignatures
|
|
}
|
|
|
|
// MaxPayloadLength returns the maximum allowed payload size for this message
|
|
// observing the specified protocol version.
|
|
//
|
|
// This is part of the lnwire.Message interface.
|
|
func (a *AnnounceSignatures) MaxPayloadLength(pver uint32) uint32 {
|
|
return MaxMsgBody
|
|
}
|