2018-06-08 05:05:32 +02:00
|
|
|
package lnpeer
|
|
|
|
|
|
|
|
import (
|
2018-07-05 22:26:55 +02:00
|
|
|
"net"
|
|
|
|
|
2022-02-23 14:48:00 +01:00
|
|
|
"github.com/btcsuite/btcd/btcec/v2"
|
2018-06-05 03:41:41 +02:00
|
|
|
"github.com/btcsuite/btcd/wire"
|
2018-09-26 11:12:57 +02:00
|
|
|
"github.com/lightningnetwork/lnd/channeldb"
|
2023-01-20 05:26:05 +01:00
|
|
|
"github.com/lightningnetwork/lnd/lnwallet"
|
2018-06-08 05:05:32 +02:00
|
|
|
"github.com/lightningnetwork/lnd/lnwire"
|
|
|
|
)
|
|
|
|
|
2023-01-20 05:26:05 +01: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-25 05:47:07 +02:00
|
|
|
// Peer is an interface which represents a remote lightning node.
|
2018-06-08 05:05:32 +02:00
|
|
|
type Peer interface {
|
2019-03-06 02:08:22 +01: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-08 05:05:32 +02:00
|
|
|
|
2018-07-05 22:26:55 +02:00
|
|
|
// AddNewChannel adds a new channel to the peer. The channel should fail
|
|
|
|
// to be added if the cancel channel is closed.
|
2023-01-20 05:26:05 +01:00
|
|
|
AddNewChannel(newChan *NewChannel, cancel <-chan struct{}) error
|
2018-07-05 22:26:55 +02:00
|
|
|
|
2023-03-16 14:25:17 +01: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 13:42:07 +02:00
|
|
|
// RemovePendingChannel removes a pending open channel ID to the peer.
|
|
|
|
RemovePendingChannel(cid lnwire.ChannelID) error
|
|
|
|
|
2018-06-08 05:05:32 +02:00
|
|
|
// WipeChannel removes the channel uniquely identified by its channel
|
|
|
|
// point from all indexes associated with the peer.
|
2020-04-03 02:39:29 +02:00
|
|
|
WipeChannel(*wire.OutPoint)
|
2018-06-08 05:05:32 +02: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 22:26:55 +02:00
|
|
|
|
|
|
|
// Address returns the network address of the remote peer.
|
|
|
|
Address() net.Addr
|
2018-08-26 02:10:25 +02: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 14:41:08 +02:00
|
|
|
|
2019-11-08 14:31:47 +01: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 14:41:08 +02:00
|
|
|
// interface to gate their behavior off the set of negotiated feature
|
|
|
|
// bits.
|
2019-11-08 14:31:47 +01:00
|
|
|
LocalFeatures() *lnwire.FeatureVector
|
2019-09-11 14:41:08 +02:00
|
|
|
|
2019-11-08 14:31:47 +01: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
|
2018-06-08 05:05:32 +02:00
|
|
|
}
|