2018-06-07 20:05:32 -07:00
|
|
|
package lnpeer
|
|
|
|
|
|
|
|
import (
|
2018-07-05 13:26:55 -07:00
|
|
|
"net"
|
|
|
|
|
2022-02-23 14:48:00 +01:00
|
|
|
"github.com/btcsuite/btcd/btcec/v2"
|
2018-06-04 18:41:41 -07:00
|
|
|
"github.com/btcsuite/btcd/wire"
|
2018-09-26 11:12:57 +02:00
|
|
|
"github.com/lightningnetwork/lnd/channeldb"
|
2023-01-19 20:26:05 -08:00
|
|
|
"github.com/lightningnetwork/lnd/lnwallet"
|
2018-06-07 20:05:32 -07:00
|
|
|
"github.com/lightningnetwork/lnd/lnwire"
|
|
|
|
)
|
|
|
|
|
2023-01-19 20:26:05 -08:00
|
|
|
// NewChannel is a newly funded channel. This struct couples a channel along
|
|
|
|
// with the set of channel options that may change how the channel is created.
|
|
|
|
// This can be used to pass along the nonce state needed for taproot channels.
|
|
|
|
type NewChannel struct {
|
|
|
|
*channeldb.OpenChannel
|
|
|
|
|
|
|
|
// ChanOpts can be used to change how the channel is created.
|
|
|
|
ChanOpts []lnwallet.ChannelOpt
|
|
|
|
}
|
|
|
|
|
2020-06-24 23:47:07 -04:00
|
|
|
// Peer is an interface which represents a remote lightning node.
|
2018-06-07 20:05:32 -07:00
|
|
|
type Peer interface {
|
2019-03-05 17:08:22 -08:00
|
|
|
// SendMessage sends a variadic number of high-priority message to
|
|
|
|
// remote peer. The first argument denotes if the method should block
|
|
|
|
// until the messages have been sent to the remote peer or an error is
|
|
|
|
// returned, otherwise it returns immediately after queuing.
|
|
|
|
SendMessage(sync bool, msgs ...lnwire.Message) error
|
|
|
|
|
|
|
|
// SendMessageLazy sends a variadic number of low-priority message to
|
|
|
|
// remote peer. The first argument denotes if the method should block
|
|
|
|
// until the messages have been sent to the remote peer or an error is
|
|
|
|
// returned, otherwise it returns immediately after queueing.
|
|
|
|
SendMessageLazy(sync bool, msgs ...lnwire.Message) error
|
2018-06-07 20:05:32 -07:00
|
|
|
|
2018-07-05 13:26:55 -07:00
|
|
|
// AddNewChannel adds a new channel to the peer. The channel should fail
|
|
|
|
// to be added if the cancel channel is closed.
|
2023-01-19 20:26:05 -08:00
|
|
|
AddNewChannel(newChan *NewChannel, cancel <-chan struct{}) error
|
2018-07-05 13:26:55 -07:00
|
|
|
|
2023-03-16 21:25:17 +08:00
|
|
|
// AddPendingChannel adds a pending open channel ID to the peer. The
|
|
|
|
// channel should fail to be added if the cancel chan is closed.
|
|
|
|
AddPendingChannel(cid lnwire.ChannelID, cancel <-chan struct{}) error
|
|
|
|
|
2023-06-08 19:42:07 +08:00
|
|
|
// RemovePendingChannel removes a pending open channel ID to the peer.
|
|
|
|
RemovePendingChannel(cid lnwire.ChannelID) error
|
|
|
|
|
2018-06-07 20:05:32 -07:00
|
|
|
// WipeChannel removes the channel uniquely identified by its channel
|
|
|
|
// point from all indexes associated with the peer.
|
2020-04-02 17:39:29 -07:00
|
|
|
WipeChannel(*wire.OutPoint)
|
2018-06-07 20:05:32 -07:00
|
|
|
|
|
|
|
// PubKey returns the serialized public key of the remote peer.
|
|
|
|
PubKey() [33]byte
|
|
|
|
|
|
|
|
// IdentityKey returns the public key of the remote peer.
|
|
|
|
IdentityKey() *btcec.PublicKey
|
2018-07-05 13:26:55 -07:00
|
|
|
|
|
|
|
// Address returns the network address of the remote peer.
|
|
|
|
Address() net.Addr
|
2018-08-25 17:10:25 -07:00
|
|
|
|
|
|
|
// QuitSignal is a method that should return a channel which will be
|
|
|
|
// sent upon or closed once the backing peer exits. This allows callers
|
|
|
|
// using the interface to cancel any processing in the event the backing
|
|
|
|
// implementation exits.
|
|
|
|
QuitSignal() <-chan struct{}
|
2019-09-11 05:41:08 -07:00
|
|
|
|
2019-11-08 05:31:47 -08:00
|
|
|
// LocalFeatures returns the set of features that has been advertised by
|
|
|
|
// the us to the remote peer. This allows sub-systems that use this
|
2019-09-11 05:41:08 -07:00
|
|
|
// interface to gate their behavior off the set of negotiated feature
|
|
|
|
// bits.
|
2019-11-08 05:31:47 -08:00
|
|
|
LocalFeatures() *lnwire.FeatureVector
|
2019-09-11 05:41:08 -07:00
|
|
|
|
2019-11-08 05:31:47 -08:00
|
|
|
// RemoteFeatures returns the set of features that has been advertised
|
|
|
|
// by the remote peer. This allows sub-systems that use this interface
|
|
|
|
// to gate their behavior off the set of negotiated feature bits.
|
|
|
|
RemoteFeatures() *lnwire.FeatureVector
|
2024-08-14 14:03:39 -04:00
|
|
|
|
|
|
|
// Disconnect halts communication with the peer.
|
|
|
|
Disconnect(error)
|
2018-06-07 20:05:32 -07:00
|
|
|
}
|