Documentation
¶
Index ¶
- Constants
- Variables
- func DisableLog()
- func UseLogger(logger btclog.Logger)
- func WaitForChanToClose(bestHeight uint32, notifier chainntnfs.ChainNotifier, errChan chan error, ...)
- type Brontide
- func (p *Brontide) ActiveSignal() chan struct{}
- func (p *Brontide) AddNewChannel(newChan *lnpeer.NewChannel, cancel <-chan struct{}) error
- func (p *Brontide) AddPendingChannel(cid lnwire.ChannelID, cancel <-chan struct{}) error
- func (p *Brontide) Address() net.Addr
- func (p *Brontide) BytesReceived() uint64
- func (p *Brontide) BytesSent() uint64
- func (p *Brontide) ChanHasRbfCoopCloser(chanPoint wire.OutPoint) bool
- func (p *Brontide) ChannelSnapshots() []*channeldb.ChannelSnapshot
- func (p *Brontide) Conn() net.Conn
- func (p *Brontide) ConnReq() *connmgr.ConnReq
- func (p *Brontide) Disconnect(reason error)
- func (p *Brontide) ErrorBuffer() *queue.CircularBuffer
- func (p *Brontide) HandleLocalCloseChanReqs(req *htlcswitch.ChanClose)
- func (p *Brontide) IdentityKey() *btcec.PublicKey
- func (p *Brontide) Inbound() bool
- func (p *Brontide) LastRemotePingPayload() []byte
- func (p *Brontide) LocalFeatures() *lnwire.FeatureVector
- func (p *Brontide) NetAddress() *lnwire.NetAddress
- func (p *Brontide) PingTime() int64
- func (p *Brontide) PubKey() [33]byte
- func (p *Brontide) QuitSignal() <-chan struct{}
- func (p *Brontide) RemoteFeatures() *lnwire.FeatureVector
- func (p *Brontide) RemovePendingChannel(cid lnwire.ChannelID) error
- func (p *Brontide) SendMessage(sync bool, msgs ...lnwire.Message) error
- func (p *Brontide) SendMessageLazy(sync bool, msgs ...lnwire.Message) error
- func (p *Brontide) SetAddress(address net.Addr)
- func (p *Brontide) Start() error
- func (p *Brontide) StartTime() time.Time
- func (p *Brontide) String() string
- func (p *Brontide) TriggerCoopCloseRbfBump(ctx context.Context, chanPoint wire.OutPoint, feeRate chainfee.SatPerKWeight, ...) (*CoopCloseUpdates, error)
- func (p *Brontide) WaitForDisconnect(ready chan struct{})
- func (p *Brontide) WipeChannel(chanPoint *wire.OutPoint)
- type ChannelCloseUpdate
- type Config
- type CoopCloseUpdates
- type LndAdapterCfg
- type LndDaemonAdapters
- func (l *LndDaemonAdapters) BroadcastTransaction(tx *wire.MsgTx, label string) error
- func (l *LndDaemonAdapters) RegisterConfirmationsNtfn(txid *chainhash.Hash, pkScript []byte, numConfs, heightHint uint32, ...) (*chainntnfs.ConfirmationEvent, error)
- func (l *LndDaemonAdapters) RegisterSpendNtfn(outpoint *wire.OutPoint, pkScript []byte, heightHint uint32) (*chainntnfs.SpendEvent, error)
- func (l *LndDaemonAdapters) SendMessages(pub btcec.PublicKey, msgs []lnwire.Message) error
- type MessageConn
- type MessageSender
- type MusigChanCloser
- func (m *MusigChanCloser) ClosingNonce() (*musig2.Nonces, error)
- func (m *MusigChanCloser) CombineClosingOpts(localSig, remoteSig lnwire.PartialSig) (input.Signature, input.Signature, []lnwallet.ChanCloseOpt, error)
- func (m *MusigChanCloser) InitRemoteNonce(nonce *musig2.Nonces)
- func (m *MusigChanCloser) ProposalClosingOpts() ([]lnwallet.ChanCloseOpt, error)
- type PendingUpdate
- type PingManager
- type PingManagerConfig
- type TimestampedError
- type TxBroadcaster
Constants ¶
const (
// ErrorBufferSize is the number of historic peer errors that we store.
ErrorBufferSize = 10
)
Variables ¶
var ( // ErrChannelNotFound is an error returned when a channel is queried and // either the Brontide doesn't know of it, or the channel in question // is pending. ErrChannelNotFound = fmt.Errorf("channel not found") )
Functions ¶
func UseLogger ¶
func UseLogger(logger btclog.Logger)
UseLogger uses a specified Logger to output package logging info.
func WaitForChanToClose ¶
func WaitForChanToClose(bestHeight uint32, notifier chainntnfs.ChainNotifier, errChan chan error, chanPoint *wire.OutPoint, closingTxID *chainhash.Hash, closeScript []byte, cb func())
WaitForChanToClose uses the passed notifier to wait until the channel has been detected as closed on chain and then concludes by executing the following actions: the channel point will be sent over the settleChan, and finally the callback will be executed. If any error is encountered within the function, then it will be sent over the errChan.
Types ¶
type Brontide ¶
type Brontide struct {
// contains filtered or unexported fields
}
Brontide is an active peer on the Lightning Network. This struct is responsible for managing any channel state related to this peer. To do so, it has several helper goroutines to handle events such as HTLC timeouts, new funding workflow, and detecting an uncooperative closure of any active channels.
func NewBrontide ¶
NewBrontide creates a new Brontide from a peer.Config struct.
func (*Brontide) ActiveSignal ¶
func (p *Brontide) ActiveSignal() chan struct{}
ActiveSignal returns the peer's active signal.
func (*Brontide) AddNewChannel ¶
func (p *Brontide) AddNewChannel(newChan *lnpeer.NewChannel, cancel <-chan struct{}) error
AddNewChannel adds a new channel to the peer. The channel should fail to be added if the cancel channel is closed.
NOTE: Part of the lnpeer.Peer interface.
func (*Brontide) AddPendingChannel ¶
AddPendingChannel adds a pending open channel to the peer. The channel should fail to be added if the cancel channel is closed.
NOTE: Part of the lnpeer.Peer interface.
func (*Brontide) Address ¶
Address returns the network address of the remote peer.
NOTE: Part of the lnpeer.Peer interface.
func (*Brontide) BytesReceived ¶
BytesReceived returns the number of bytes received from the peer.
func (*Brontide) ChanHasRbfCoopCloser ¶
ChanHasRbfCoopCloser returns true if the channel as identifier by the channel point has an active RBF chan closer.
func (*Brontide) ChannelSnapshots ¶
func (p *Brontide) ChannelSnapshots() []*channeldb.ChannelSnapshot
ChannelSnapshots returns a slice of channel snapshots detailing all currently active channels maintained with the remote peer.
func (*Brontide) Disconnect ¶
Disconnect terminates the connection with the remote peer. Additionally, a signal is sent to the server and htlcSwitch indicating the resources allocated to the peer can now be cleaned up.
NOTE: Be aware that this method will block if the peer is still starting up. Therefore consider starting it in a goroutine if you cannot guarantee that the peer has finished starting up before calling this method.
func (*Brontide) ErrorBuffer ¶
func (p *Brontide) ErrorBuffer() *queue.CircularBuffer
ErrorBuffer is a getter for the Brontide's errorBuffer in cfg.
func (*Brontide) HandleLocalCloseChanReqs ¶
func (p *Brontide) HandleLocalCloseChanReqs(req *htlcswitch.ChanClose)
HandleLocalCloseChanReqs accepts a *htlcswitch.ChanClose and passes it onto the channelManager goroutine, which will shut down the link and possibly close the channel.
func (*Brontide) IdentityKey ¶
func (p *Brontide) IdentityKey() *btcec.PublicKey
IdentityKey returns the public key of the remote peer.
NOTE: Part of the lnpeer.Peer interface.
func (*Brontide) LastRemotePingPayload ¶
LastRemotePingPayload returns the last payload the remote party sent as part of their ping.
func (*Brontide) LocalFeatures ¶
func (p *Brontide) LocalFeatures() *lnwire.FeatureVector
LocalFeatures returns the set of global features that has been advertised by the local node. This allows sub-systems that use this interface to gate their behavior off the set of negotiated feature bits.
NOTE: Part of the lnpeer.Peer interface.
func (*Brontide) NetAddress ¶
func (p *Brontide) NetAddress() *lnwire.NetAddress
NetAddress returns the network of the remote peer as an lnwire.NetAddress.
func (*Brontide) PubKey ¶
PubKey returns the pubkey of the peer in compressed serialized format.
NOTE: Part of the lnpeer.Peer interface.
func (*Brontide) QuitSignal ¶
func (p *Brontide) QuitSignal() <-chan struct{}
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.
NOTE: Part of the lnpeer.Peer interface.
func (*Brontide) RemoteFeatures ¶
func (p *Brontide) RemoteFeatures() *lnwire.FeatureVector
RemoteFeatures returns the set of global features that has been advertised by the remote node. This allows sub-systems that use this interface to gate their behavior off the set of negotiated feature bits.
NOTE: Part of the lnpeer.Peer interface.
func (*Brontide) RemovePendingChannel ¶
RemovePendingChannel removes a pending open channel from the peer.
NOTE: Part of the lnpeer.Peer interface.
func (*Brontide) SendMessage ¶
SendMessage sends a variadic number of high-priority messages to the 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.
NOTE: Part of the lnpeer.Peer interface.
func (*Brontide) SendMessageLazy ¶
SendMessageLazy sends a variadic number of low-priority messages to the 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.
NOTE: Part of the lnpeer.Peer interface.
func (*Brontide) SetAddress ¶
SetAddress sets the remote peer's address given an address.
func (*Brontide) Start ¶
Start starts all helper goroutines the peer needs for normal operations. In the case this peer has already been started, then this function is a noop.
func (*Brontide) StartTime ¶
StartTime returns the time at which the connection was established if the peer started successfully, and zero otherwise.
func (*Brontide) TriggerCoopCloseRbfBump ¶
func (p *Brontide) TriggerCoopCloseRbfBump(ctx context.Context, chanPoint wire.OutPoint, feeRate chainfee.SatPerKWeight, deliveryScript lnwire.DeliveryAddress) (*CoopCloseUpdates, error)
TriggerCoopCloseRbfBump given a chan ID, and the params needed to trigger a new RBF co-op close update, a bump is attempted. A channel used for updates, along with one used to o=communicate any errors is returned. If no chan closer is found, then false is returned for the second argument.
func (*Brontide) WaitForDisconnect ¶
func (p *Brontide) WaitForDisconnect(ready chan struct{})
WaitForDisconnect waits until the peer has disconnected. A peer may be disconnected if the local or remote side terminates the connection, or an irrecoverable protocol error has been encountered. This method will only begin watching the peer's waitgroup after the ready channel or the peer's quit channel are signaled. The ready channel should only be signaled if a call to Start returns no error. Otherwise, if the peer fails to start, calling Disconnect will signal the quit channel and the method will not block, since no goroutines were spawned.
func (*Brontide) WipeChannel ¶
WipeChannel removes the passed channel point from all indexes associated with the peer and the switch.
type ChannelCloseUpdate ¶
type ChannelCloseUpdate struct { ClosingTxid []byte Success bool // LocalCloseOutput is an optional, additional output on the closing // transaction that the local party should be paid to. This will only be // populated if the local balance isn't dust. LocalCloseOutput fn.Option[chancloser.CloseOutput] // RemoteCloseOutput is an optional, additional output on the closing // transaction that the remote party should be paid to. This will only // be populated if the remote balance isn't dust. RemoteCloseOutput fn.Option[chancloser.CloseOutput] // AuxOutputs is an optional set of additional outputs that might be // included in the closing transaction. These are used for custom // channel types. AuxOutputs fn.Option[chancloser.AuxCloseOutputs] }
ChannelCloseUpdate contains the outcome of the close channel operation.
type Config ¶
type Config struct { // Conn is the underlying network connection for this peer. Conn MessageConn // ConnReq stores information related to the persistent connection request // for this peer. ConnReq *connmgr.ConnReq // PubKeyBytes is the serialized, compressed public key of this peer. PubKeyBytes [33]byte // Addr is the network address of the peer. Addr *lnwire.NetAddress // Inbound indicates whether or not the peer is an inbound peer. Inbound bool // Features is the set of features that we advertise to the remote party. Features *lnwire.FeatureVector // LegacyFeatures is the set of features that we advertise to the remote // peer for backwards compatibility. Nodes that have not implemented // flat features will still be able to read our feature bits from the // legacy global field, but we will also advertise everything in the // default features field. LegacyFeatures *lnwire.FeatureVector // OutgoingCltvRejectDelta defines the number of blocks before expiry of // an htlc where we don't offer it anymore. OutgoingCltvRejectDelta uint32 // ChanActiveTimeout specifies the duration the peer will wait to request // a channel reenable, beginning from the time the peer was started. ChanActiveTimeout time.Duration // ErrorBuffer stores a set of errors related to a peer. It contains error // messages that our peer has recently sent us over the wire and records of // unknown messages that were sent to us so that we can have a full track // record of the communication errors we have had with our peer. If we // choose to disconnect from a peer, it also stores the reason we had for // disconnecting. ErrorBuffer *queue.CircularBuffer // WritePool is the task pool that manages reuse of write buffers. Write // tasks are submitted to the pool in order to conserve the total number of // write buffers allocated at any one time, and decouple write buffer // allocation from the peer life cycle. WritePool *pool.Write // ReadPool is the task pool that manages reuse of read buffers. ReadPool *pool.Read // Switch is a pointer to the htlcswitch. It is used to setup, get, and // tear-down ChannelLinks. Switch messageSwitch // InterceptSwitch is a pointer to the InterceptableSwitch, a wrapper around // the regular Switch. We only export it here to pass ForwardPackets to the // ChannelLinkConfig. InterceptSwitch *htlcswitch.InterceptableSwitch // ChannelDB is used to fetch opened channels, and closed channels. ChannelDB *channeldb.ChannelStateDB // ChannelGraph is a pointer to the channel graph which is used to // query information about the set of known active channels. ChannelGraph *graphdb.ChannelGraph // ChainArb is used to subscribe to channel events, update contract signals, // and force close channels. ChainArb *contractcourt.ChainArbitrator // AuthGossiper is needed so that the Brontide impl can register with the // gossiper and process remote channel announcements. AuthGossiper *discovery.AuthenticatedGossiper // ChanStatusMgr is used to set or un-set the disabled bit in channel // updates. ChanStatusMgr *netann.ChanStatusManager // ChainIO is used to retrieve the best block. ChainIO lnwallet.BlockChainIO // FeeEstimator is used to compute our target ideal fee-per-kw when // initializing the coop close process. FeeEstimator chainfee.Estimator // Signer is used when creating *lnwallet.LightningChannel instances. Signer input.Signer // SigPool is used when creating *lnwallet.LightningChannel instances. SigPool *lnwallet.SigPool // Wallet is used to publish transactions and generates delivery // scripts during the coop close process. Wallet *lnwallet.LightningWallet // ChainNotifier is used to receive confirmations of a coop close // transaction. ChainNotifier chainntnfs.ChainNotifier // BestBlockView is used to efficiently query for up-to-date // blockchain state information BestBlockView chainntnfs.BestBlockView // RoutingPolicy is used to set the forwarding policy for links created by // the Brontide. RoutingPolicy models.ForwardingPolicy // Sphinx is used when setting up ChannelLinks so they can decode sphinx // onion blobs. Sphinx *hop.OnionProcessor // WitnessBeacon is used when setting up ChannelLinks so they can add any // preimages that they learn. WitnessBeacon contractcourt.WitnessBeacon // Invoices is passed to the ChannelLink on creation and handles all // invoice-related logic. Invoices *invoices.InvoiceRegistry // ChannelNotifier is used by the link to notify other sub-systems about // channel-related events and by the Brontide to subscribe to // ActiveLinkEvents. ChannelNotifier *channelnotifier.ChannelNotifier // HtlcNotifier is used when creating a ChannelLink. HtlcNotifier *htlcswitch.HtlcNotifier // TowerClient is used to backup revoked states. TowerClient wtclient.ClientManager // DisconnectPeer is used to disconnect this peer if the cooperative close // process fails. DisconnectPeer func(*btcec.PublicKey) error // GenNodeAnnouncement is used to send our node announcement to the remote // on startup. GenNodeAnnouncement func(...netann.NodeAnnModifier) ( lnwire.NodeAnnouncement, error) // PrunePersistentPeerConnection is used to remove all internal state // related to this peer in the server. PrunePersistentPeerConnection func([33]byte) // FetchLastChanUpdate fetches our latest channel update for a target // channel. FetchLastChanUpdate func(lnwire.ShortChannelID) (*lnwire.ChannelUpdate1, error) // FundingManager is an implementation of the funding.Controller interface. FundingManager funding.Controller // Hodl is used when creating ChannelLinks to specify HodlFlags as // breakpoints in dev builds. Hodl *hodl.Config // UnsafeReplay is used when creating ChannelLinks to specify whether or // not to replay adds on its commitment tx. UnsafeReplay bool // MaxOutgoingCltvExpiry is used when creating ChannelLinks and is the max // number of blocks that funds could be locked up for when forwarding // payments. MaxOutgoingCltvExpiry uint32 // MaxChannelFeeAllocation is used when creating ChannelLinks and is the // maximum percentage of total funds that can be allocated to a channel's // commitment fee. This only applies for the initiator of the channel. MaxChannelFeeAllocation float64 // MaxAnchorsCommitFeeRate is the maximum fee rate we'll use as an // initiator for anchor channel commitments. MaxAnchorsCommitFeeRate chainfee.SatPerKWeight // CoopCloseTargetConfs is the confirmation target that will be used // to estimate the fee rate to use during a cooperative channel // closure initiated by the remote peer. CoopCloseTargetConfs uint32 // ServerPubKey is the serialized, compressed public key of our lnd node. // It is used to determine which policy (channel edge) to pass to the // ChannelLink. ServerPubKey [33]byte // ChannelCommitInterval is the maximum time that is allowed to pass between // receiving a channel state update and signing the next commitment. // Setting this to a longer duration allows for more efficient channel // operations at the cost of latency. ChannelCommitInterval time.Duration // PendingCommitInterval is the maximum time that is allowed to pass // while waiting for the remote party to revoke a locally initiated // commitment state. Setting this to a longer duration if a slow // response is expected from the remote party or large number of // payments are attempted at the same time. PendingCommitInterval time.Duration // ChannelCommitBatchSize is the maximum number of channel state updates // that is accumulated before signing a new commitment. ChannelCommitBatchSize uint32 // HandleCustomMessage is called whenever a custom message is received // from the peer. HandleCustomMessage func(peer [33]byte, msg *lnwire.Custom) error // GetAliases is passed to created links so the Switch and link can be // aware of the channel's aliases. GetAliases func(base lnwire.ShortChannelID) []lnwire.ShortChannelID // RequestAlias allows the Brontide struct to request an alias to send // to the peer. RequestAlias func() (lnwire.ShortChannelID, error) // AddLocalAlias persists an alias to an underlying alias store. AddLocalAlias func(alias, base lnwire.ShortChannelID, gossip, liveUpdate bool) error // AuxLeafStore is an optional store that can be used to store auxiliary // leaves for certain custom channel types. AuxLeafStore fn.Option[lnwallet.AuxLeafStore] // AuxSigner is an optional signer that can be used to sign auxiliary // leaves for certain custom channel types. AuxSigner fn.Option[lnwallet.AuxSigner] // AuxResolver is an optional interface that can be used to modify the // way contracts are resolved. AuxResolver fn.Option[lnwallet.AuxContractResolver] // AuxTrafficShaper is an optional auxiliary traffic shaper that can be // used to manage the bandwidth of peer links. AuxTrafficShaper fn.Option[htlcswitch.AuxTrafficShaper] // PongBuf is a slice we'll reuse instead of allocating memory on the // heap. Since only reads will occur and no writes, there is no need // for any synchronization primitives. As a result, it's safe to share // this across multiple Peer struct instances. PongBuf []byte // Adds the option to disable forwarding payments in blinded routes // by failing back any blinding-related payloads as if they were // invalid. DisallowRouteBlinding bool // DisallowQuiescence is a flag that indicates whether the Brontide // should have the quiescence feature disabled. DisallowQuiescence bool // MaxFeeExposure limits the number of outstanding fees in a channel. // This value will be passed to created links. MaxFeeExposure lnwire.MilliSatoshi // MsgRouter is an optional instance of the main message router that // the peer will use. If None, then a new default version will be used // in place. MsgRouter fn.Option[msgmux.Router] // AuxChanCloser is an optional instance of an abstraction that can be // used to modify the way the co-op close transaction is constructed. AuxChanCloser fn.Option[chancloser.AuxChanCloser] // ShouldFwdExpEndorsement is a closure that indicates whether // experimental endorsement signals should be set. ShouldFwdExpEndorsement func() bool // NoDisconnectOnPongFailure indicates whether the peer should *not* be // disconnected if a pong is not received in time or is mismatched. NoDisconnectOnPongFailure bool // Quit is the server's quit channel. If this is closed, we halt operation. Quit chan struct{} }
Config defines configuration fields that are necessary for a peer object to function.
type CoopCloseUpdates ¶
type CoopCloseUpdates struct { UpdateChan chan interface{} ErrChan chan error }
CoopCloseUpdates is a struct used to communicate updates for an active close to the caller.
type LndAdapterCfg ¶
type LndAdapterCfg struct { // MsgSender is capable of sending messages to an arbitrary peer. MsgSender MessageSender // TxBroadcaster is capable of broadcasting a transaction to the // network. TxBroadcaster TxBroadcaster // ChainNotifier is capable of receiving notifications for on-chain // events. ChainNotifier chainntnfs.ChainNotifier }
LndAdapterCfg is a struct that holds the configuration for the LndDaemonAdapters instance.
type LndDaemonAdapters ¶
type LndDaemonAdapters struct {
// contains filtered or unexported fields
}
LndDaemonAdapters is a struct that implements the protofsm.DaemonAdapters interface using common lnd abstractions.
func NewLndDaemonAdapters ¶
func NewLndDaemonAdapters(cfg LndAdapterCfg) *LndDaemonAdapters
NewLndDaemonAdapters creates a new instance of the lndDaemonAdapters struct.
func (*LndDaemonAdapters) BroadcastTransaction ¶
func (l *LndDaemonAdapters) BroadcastTransaction(tx *wire.MsgTx, label string) error
BroadcastTransaction broadcasts a transaction with the target label.
func (*LndDaemonAdapters) RegisterConfirmationsNtfn ¶
func (l *LndDaemonAdapters) RegisterConfirmationsNtfn(txid *chainhash.Hash, pkScript []byte, numConfs, heightHint uint32, opts ...chainntnfs.NotifierOption, ) (*chainntnfs.ConfirmationEvent, error)
RegisterConfirmationsNtfn registers an intent to be notified once txid reaches numConfs confirmations.
func (*LndDaemonAdapters) RegisterSpendNtfn ¶
func (l *LndDaemonAdapters) RegisterSpendNtfn(outpoint *wire.OutPoint, pkScript []byte, heightHint uint32) (*chainntnfs.SpendEvent, error)
RegisterSpendNtfn registers an intent to be notified once the target outpoint is successfully spent within a transaction.
func (*LndDaemonAdapters) SendMessages ¶
func (l *LndDaemonAdapters) SendMessages(pub btcec.PublicKey, msgs []lnwire.Message) error
SendMessages sends the target set of messages to the target peer.
type MessageConn ¶
type MessageConn interface { // RemoteAddr returns the remote address on the other end of the connection. RemoteAddr() net.Addr // LocalAddr returns the local address on our end of the connection. LocalAddr() net.Addr // Read reads bytes from the connection. Read([]byte) (int, error) // Write writes bytes to the connection. Write([]byte) (int, error) // SetDeadline sets the deadline for the connection. SetDeadline(time.Time) error // SetReadDeadline sets the read deadline. SetReadDeadline(time.Time) error // SetWriteDeadline sets the write deadline. SetWriteDeadline(time.Time) error // Close closes the connection. Close() error // Flush attempts a flush. Flush() (int, error) // WriteMessage writes the message. WriteMessage([]byte) error // ReadNextHeader reads the next header. ReadNextHeader() (uint32, error) // ReadNextBody reads the next body. ReadNextBody([]byte) ([]byte, error) }
MessageConn is an interface implemented by anything that delivers an lnwire.Message using a net.Conn interface.
type MessageSender ¶
type MessageSender interface { // SendMessages sends the target set of messages to the target peer. // // TODO(roasbeef): current impl bound to single peer, need server // pointer otherwise SendMessages(btcec.PublicKey, []lnwire.Message) error }
MessageSender is an interface that represents an object capable of sending p2p messages to a destination.
type MusigChanCloser ¶
type MusigChanCloser struct {
// contains filtered or unexported fields
}
MusigChanCloser is an adapter over the normal channel state machine that allows the chan closer to handle the musig2 details of closing taproot channels.
func NewMusigChanCloser ¶
func NewMusigChanCloser(channel *lnwallet.LightningChannel) *MusigChanCloser
NewMusigChanCloser creates a new musig chan closer from a normal channel.
func (*MusigChanCloser) ClosingNonce ¶
func (m *MusigChanCloser) ClosingNonce() (*musig2.Nonces, error)
ClosingNonce returns the nonce that should be used when generating the our partial signature for the remote party.
func (*MusigChanCloser) CombineClosingOpts ¶
func (m *MusigChanCloser) CombineClosingOpts(localSig, remoteSig lnwire.PartialSig) (input.Signature, input.Signature, []lnwallet.ChanCloseOpt, error)
CombineClosingOpts returns the options that should be used when combining the final musig partial signature. The method also maps the lnwire partial signatures into an input.Signature that can be used more generally.
func (*MusigChanCloser) InitRemoteNonce ¶
func (m *MusigChanCloser) InitRemoteNonce(nonce *musig2.Nonces)
InitRemoteNonce saves the remote nonce the party sent during their shutdown message so it can be used later to generate and verify signatures.
func (*MusigChanCloser) ProposalClosingOpts ¶
func (m *MusigChanCloser) ProposalClosingOpts() ( []lnwallet.ChanCloseOpt, error)
ProposalClosingOpts returns the options that should be used when generating a new co-op close signature.
type PendingUpdate ¶
type PendingUpdate struct { // Txid is the txid of the closing transaction. Txid []byte // OutputIndex is the output index of our output in the closing // transaction. OutputIndex uint32 // FeePerVByte is an optional field, that is set only when the new RBF // coop close flow is used. This indicates the new closing fee rate on // the closing transaction. FeePerVbyte fn.Option[chainfee.SatPerVByte] // IsLocalCloseTx is an optional field that indicates if this update is // sent for our local close txn, or the close txn of the remote party. // This is only set if the new RBF coop close flow is used. IsLocalCloseTx fn.Option[bool] }
PendingUpdate describes the pending state of a closing channel.
type PingManager ¶
type PingManager struct {
// contains filtered or unexported fields
}
PingManager is a structure that is designed to manage the internal state of the ping pong lifecycle with the remote peer. We assume there is only one ping outstanding at once.
NOTE: This structure MUST be initialized with NewPingManager.
func NewPingManager ¶
func NewPingManager(cfg *PingManagerConfig) *PingManager
NewPingManager constructs a pingManager in a valid state. It must be started before it does anything useful, though.
func (*PingManager) GetPingTimeMicroSeconds ¶
func (m *PingManager) GetPingTimeMicroSeconds() int64
GetPingTimeMicroSeconds reports back the RTT calculated by the pingManager.
func (*PingManager) ReceivedPong ¶
func (m *PingManager) ReceivedPong(msg *lnwire.Pong)
ReceivedPong is called to evaluate a Pong message against the expectations we have for it. It will cause the PingManager to invoke the supplied OnPongFailure function if the Pong argument supplied violates expectations.
func (*PingManager) Start ¶
func (m *PingManager) Start() error
Start launches the primary goroutine that is owned by the pingManager.
func (*PingManager) Stop ¶
func (m *PingManager) Stop()
Stop interrupts the goroutines that the PingManager owns.
type PingManagerConfig ¶
type PingManagerConfig struct { // NewPingPayload is a closure that returns the payload to be packaged // in the Ping message. NewPingPayload func() []byte // NewPongSize is a closure that returns a random value between // [0, lnwire.MaxPongBytes]. This random value helps to more effectively // pair Pong messages with Ping. NewPongSize func() uint16 // IntervalDuration is the Duration between attempted pings. IntervalDuration time.Duration // TimeoutDuration is the Duration we wait before declaring a ping // attempt failed. TimeoutDuration time.Duration // SendPing is a closure that is responsible for sending the Ping // message out to our peer SendPing func(ping *lnwire.Ping) // OnPongFailure is a closure that is responsible for executing the // logic when a Pong message is either late or does not match our // expectations for that Pong OnPongFailure func(failureReason error, timeWaitedForPong time.Duration, lastKnownRTT time.Duration) }
PingManagerConfig is a structure containing various parameters that govern how the PingManager behaves.
type TimestampedError ¶
TimestampedError is a timestamped error that is used to store the most recent errors we have experienced with our peers.