mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-20 13:04:28 +02:00
lnwire: add a ChannelAnnouncement interface
Add a new ChannelAnnouncement interface and ensure that ChannelAnnouncement1 implements it.
This commit is contained in:
@@ -190,6 +190,8 @@ func (a *ChannelAnnouncement1) DataToSign() ([]byte, error) {
|
|||||||
// Validate validates the channel announcement message and checks that node
|
// Validate validates the channel announcement message and checks that node
|
||||||
// signatures covers the announcement message, and that the bitcoin signatures
|
// signatures covers the announcement message, and that the bitcoin signatures
|
||||||
// covers the node keys.
|
// covers the node keys.
|
||||||
|
//
|
||||||
|
// NOTE: This is part of the ChannelAnnouncement interface.
|
||||||
func (a *ChannelAnnouncement1) Validate(_ func(id *ShortChannelID) (
|
func (a *ChannelAnnouncement1) Validate(_ func(id *ShortChannelID) (
|
||||||
[]byte, error)) error {
|
[]byte, error)) error {
|
||||||
|
|
||||||
@@ -260,3 +262,38 @@ func (a *ChannelAnnouncement1) Validate(_ func(id *ShortChannelID) (
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Node1KeyBytes returns the bytes representing the public key of node 1 in the
|
||||||
|
// channel.
|
||||||
|
//
|
||||||
|
// NOTE: This is part of the ChannelAnnouncement interface.
|
||||||
|
func (a *ChannelAnnouncement1) Node1KeyBytes() [33]byte {
|
||||||
|
return a.NodeID1
|
||||||
|
}
|
||||||
|
|
||||||
|
// Node2KeyBytes returns the bytes representing the public key of node 2 in the
|
||||||
|
// channel.
|
||||||
|
//
|
||||||
|
// NOTE: This is part of the ChannelAnnouncement interface.
|
||||||
|
func (a *ChannelAnnouncement1) Node2KeyBytes() [33]byte {
|
||||||
|
return a.NodeID2
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetChainHash returns the hash of the chain which this channel's funding
|
||||||
|
// transaction is confirmed in.
|
||||||
|
//
|
||||||
|
// NOTE: This is part of the ChannelAnnouncement interface.
|
||||||
|
func (a *ChannelAnnouncement1) GetChainHash() chainhash.Hash {
|
||||||
|
return a.ChainHash
|
||||||
|
}
|
||||||
|
|
||||||
|
// SCID returns the short channel ID of the channel.
|
||||||
|
//
|
||||||
|
// NOTE: This is part of the ChannelAnnouncement interface.
|
||||||
|
func (a *ChannelAnnouncement1) SCID() ShortChannelID {
|
||||||
|
return a.ShortChannelID
|
||||||
|
}
|
||||||
|
|
||||||
|
// A compile-time check to ensure that ChannelAnnouncement1 implements the
|
||||||
|
// ChannelAnnouncement interface.
|
||||||
|
var _ ChannelAnnouncement = (*ChannelAnnouncement1)(nil)
|
||||||
|
@@ -1,5 +1,7 @@
|
|||||||
package lnwire
|
package lnwire
|
||||||
|
|
||||||
|
import "github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||||
|
|
||||||
// AnnounceSignatures is an interface that represents a message used to
|
// AnnounceSignatures is an interface that represents a message used to
|
||||||
// exchange signatures of a ChannelAnnouncment message during the funding flow.
|
// exchange signatures of a ChannelAnnouncment message during the funding flow.
|
||||||
type AnnounceSignatures interface {
|
type AnnounceSignatures interface {
|
||||||
@@ -11,3 +13,27 @@ type AnnounceSignatures interface {
|
|||||||
|
|
||||||
Message
|
Message
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ChannelAnnouncement is an interface that must be satisfied by any message
|
||||||
|
// used to announce and prove the existence of a channel.
|
||||||
|
type ChannelAnnouncement interface {
|
||||||
|
// SCID returns the short channel ID of the channel.
|
||||||
|
SCID() ShortChannelID
|
||||||
|
|
||||||
|
// GetChainHash returns the hash of the chain which this channel's
|
||||||
|
// funding transaction is confirmed in.
|
||||||
|
GetChainHash() chainhash.Hash
|
||||||
|
|
||||||
|
// Node1KeyBytes returns the bytes representing the public key of node
|
||||||
|
// 1 in the channel.
|
||||||
|
Node1KeyBytes() [33]byte
|
||||||
|
|
||||||
|
// Node2KeyBytes returns the bytes representing the public key of node
|
||||||
|
// 2 in the channel.
|
||||||
|
Node2KeyBytes() [33]byte
|
||||||
|
|
||||||
|
// Validate checks the various signatures of the announcement.
|
||||||
|
Validate(fetchPKScript func(id *ShortChannelID) ([]byte, error)) error
|
||||||
|
|
||||||
|
Message
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user