lnwire: add AnnounceSignatures interface

Add a AnnounceSignatures interface and ensure that AnnounceSignatures1
implements it.
This commit is contained in:
Elle Mouton 2023-10-26 12:17:12 +02:00
parent df65b7cad9
commit f230e2c574
No known key found for this signature in database
GPG key ID: D7D916376026F177
2 changed files with 33 additions and 2 deletions

View file

@ -47,11 +47,15 @@ type AnnounceSignatures1 struct {
// lnwire.Message interface. // lnwire.Message interface.
var _ Message = (*AnnounceSignatures1)(nil) var _ Message = (*AnnounceSignatures1)(nil)
// A compile time check to ensure AnnounceSignatures1 implements the
// lnwire.AnnounceSignatures interface.
var _ AnnounceSignatures = (*AnnounceSignatures1)(nil)
// Decode deserializes a serialized AnnounceSignatures1 stored in the passed // Decode deserializes a serialized AnnounceSignatures1 stored in the passed
// io.Reader observing the specified protocol version. // io.Reader observing the specified protocol version.
// //
// This is part of the lnwire.Message interface. // This is part of the lnwire.Message interface.
func (a *AnnounceSignatures1) Decode(r io.Reader, pver uint32) error { func (a *AnnounceSignatures1) Decode(r io.Reader, _ uint32) error {
return ReadElements(r, return ReadElements(r,
&a.ChannelID, &a.ChannelID,
&a.ShortChannelID, &a.ShortChannelID,
@ -65,7 +69,7 @@ func (a *AnnounceSignatures1) Decode(r io.Reader, pver uint32) error {
// observing the protocol version specified. // observing the protocol version specified.
// //
// This is part of the lnwire.Message interface. // This is part of the lnwire.Message interface.
func (a *AnnounceSignatures1) Encode(w *bytes.Buffer, pver uint32) error { func (a *AnnounceSignatures1) Encode(w *bytes.Buffer, _ uint32) error {
if err := WriteChannelID(w, a.ChannelID); err != nil { if err := WriteChannelID(w, a.ChannelID); err != nil {
return err return err
} }
@ -92,3 +96,17 @@ func (a *AnnounceSignatures1) Encode(w *bytes.Buffer, pver uint32) error {
func (a *AnnounceSignatures1) MsgType() MessageType { func (a *AnnounceSignatures1) MsgType() MessageType {
return MsgAnnounceSignatures return MsgAnnounceSignatures
} }
// SCID returns the ShortChannelID of the channel.
//
// This is part of the lnwire.AnnounceSignatures interface.
func (a *AnnounceSignatures1) SCID() ShortChannelID {
return a.ShortChannelID
}
// ChanID returns the ChannelID identifying the channel.
//
// This is part of the lnwire.AnnounceSignatures interface.
func (a *AnnounceSignatures1) ChanID() ChannelID {
return a.ChannelID
}

13
lnwire/interfaces.go Normal file
View file

@ -0,0 +1,13 @@
package lnwire
// AnnounceSignatures is an interface that represents a message used to
// exchange signatures of a ChannelAnnouncment message during the funding flow.
type AnnounceSignatures interface {
// SCID returns the ShortChannelID of the channel.
SCID() ShortChannelID
// ChanID returns the ChannelID identifying the channel.
ChanID() ChannelID
Message
}