Documentation ¶
Index ¶
- Variables
- func ChanUpdSetTimestamp(update *lnwire.ChannelUpdate)
- func ChannelUpdateFromEdge(info *channeldb.ChannelEdgeInfo, policy *channeldb.ChannelEdgePolicy) (*lnwire.ChannelUpdate, error)
- func CreateChanAnnouncement(chanProof *channeldb.ChannelAuthProof, chanInfo *channeldb.ChannelEdgeInfo, ...) (*lnwire.ChannelAnnouncement, *lnwire.ChannelUpdate, *lnwire.ChannelUpdate, ...)
- func DisableLog()
- func ExtractChannelUpdate(ownerPubKey []byte, info *channeldb.ChannelEdgeInfo, ...) (*lnwire.ChannelUpdate, error)
- func IPAnnouncer(annUpdater NodeAnnUpdater) func([]net.Addr, map[string]struct{}) error
- func NodeAnnSetAddrs(addrs []net.Addr) func(*lnwire.NodeAnnouncement)
- func NodeAnnSetTimestamp(nodeAnn *lnwire.NodeAnnouncement)
- func SignAnnouncement(signer lnwallet.MessageSigner, keyLoc keychain.KeyLocator, msg lnwire.Message) (input.Signature, error)
- func SignChannelUpdate(signer lnwallet.MessageSigner, keyLoc keychain.KeyLocator, ...) error
- func SignNodeAnnouncement(signer lnwallet.MessageSigner, keyLoc keychain.KeyLocator, ...) error
- func UnsignedChannelUpdateFromEdge(info *channeldb.ChannelEdgeInfo, policy *channeldb.ChannelEdgePolicy) *lnwire.ChannelUpdate
- func UseLogger(logger bronlog.Logger)
- type ChanStatus
- type ChanStatusConfig
- type ChanStatusManager
- func (m *ChanStatusManager) RequestAuto(outpoint wire.OutPoint) error
- func (m *ChanStatusManager) RequestDisable(outpoint wire.OutPoint, manual bool) error
- func (m *ChanStatusManager) RequestEnable(outpoint wire.OutPoint, manual bool) error
- func (m *ChanStatusManager) Start() error
- func (m *ChanStatusManager) Stop() error
- type ChannelGraph
- type ChannelState
- type ChannelUpdateModifier
- type DB
- type HostAnnouncer
- type HostAnnouncerConfig
- type NodeAnnModifier
- type NodeAnnUpdater
- type NodeSigner
Constants ¶
This section is empty.
Variables ¶
var ( // ErrChanStatusManagerExiting signals that a shutdown of the // ChanStatusManager has already been requested. ErrChanStatusManagerExiting = errors.New("chan status manager exiting") // ErrInvalidTimeoutConstraints signals that the ChanStatusManager could // not be initialized because the timeouts and sample intervals were // malformed. ErrInvalidTimeoutConstraints = errors.New("chan-enable-timeout + " + "chan-status-sample-interval must <= chan-disable-timeout " + "and all three chan configs must be positive integers") // ErrEnableInactiveChan signals that a request to enable a channel // could not be completed because the channel isn't actually active at // the time of the request. ErrEnableInactiveChan = errors.New("unable to enable channel which " + "is not currently active") // ErrEnableManuallyDisabledChan signals that an automatic / background // request to enable a channel could not be completed because the channel // was manually disabled. ErrEnableManuallyDisabledChan = errors.New("unable to enable channel " + "which was manually disabled") )
var ErrUnableToExtractChanUpdate = fmt.Errorf("unable to extract ChannelUpdate")
ErrUnableToExtractChanUpdate is returned when a channel update cannot be found for one of our active channels.
Functions ¶
func ChanUpdSetTimestamp ¶
func ChanUpdSetTimestamp(update *lnwire.ChannelUpdate)
ChanUpdSetTimestamp is a functional option that sets the timestamp of the update to the current time, or increments it if the timestamp is already in the future.
func ChannelUpdateFromEdge ¶
func ChannelUpdateFromEdge(info *channeldb.ChannelEdgeInfo, policy *channeldb.ChannelEdgePolicy) (*lnwire.ChannelUpdate, error)
ChannelUpdateFromEdge reconstructs a signed ChannelUpdate from the given edge info and policy.
func CreateChanAnnouncement ¶
func CreateChanAnnouncement(chanProof *channeldb.ChannelAuthProof, chanInfo *channeldb.ChannelEdgeInfo, e1, e2 *channeldb.ChannelEdgePolicy) (*lnwire.ChannelAnnouncement, *lnwire.ChannelUpdate, *lnwire.ChannelUpdate, error)
CreateChanAnnouncement is a helper function which creates all channel announcements given the necessary channel related database items. This function is used to transform out database structs into the corresponding wire structs for announcing new channels to other peers, or simply syncing up a peer's initial routing table upon connect.
func DisableLog ¶
func DisableLog()
DisableLog disables all library log output. Logging output is disabled by by default until UseLogger is called.
func ExtractChannelUpdate ¶
func ExtractChannelUpdate(ownerPubKey []byte, info *channeldb.ChannelEdgeInfo, policies ...*channeldb.ChannelEdgePolicy) ( *lnwire.ChannelUpdate, error)
ExtractChannelUpdate attempts to retrieve a lnwire.ChannelUpdate message from an edge's info and a set of routing policies.
NOTE: The passed policies can be nil.
func IPAnnouncer ¶
func IPAnnouncer(annUpdater NodeAnnUpdater) func([]net.Addr, map[string]struct{}) error
IPAnnouncer is a factory function that generates a new function that uses the passed annUpdater function to to announce new IP changes for a given host.
func NodeAnnSetAddrs ¶
func NodeAnnSetAddrs(addrs []net.Addr) func(*lnwire.NodeAnnouncement)
NodeAnnSetAddrs is a functional option that allows updating the addresses of the given node announcement.
func NodeAnnSetTimestamp ¶
func NodeAnnSetTimestamp(nodeAnn *lnwire.NodeAnnouncement)
NodeAnnSetTimestamp is a functional option that sets the timestamp of the announcement to the current time, or increments it if the timestamp is already in the future.
func SignAnnouncement ¶
func SignAnnouncement(signer lnwallet.MessageSigner, keyLoc keychain.KeyLocator, msg lnwire.Message) (input.Signature, error)
SignAnnouncement signs any type of gossip message that is announced on the network.
func SignChannelUpdate ¶
func SignChannelUpdate(signer lnwallet.MessageSigner, keyLoc keychain.KeyLocator, update *lnwire.ChannelUpdate, mods ...ChannelUpdateModifier) error
SignChannelUpdate applies the given modifiers to the passed lnwire.ChannelUpdate, then signs the resulting update. The provided update should be the most recent, valid update, otherwise the timestamp may not monotonically increase from the prior.
NOTE: This method modifies the given update.
func SignNodeAnnouncement ¶
func SignNodeAnnouncement(signer lnwallet.MessageSigner, keyLoc keychain.KeyLocator, nodeAnn *lnwire.NodeAnnouncement, mods ...NodeAnnModifier) error
SignNodeAnnouncement applies the given modifies to the passed lnwire.NodeAnnouncement, then signs the resulting announcement. The provided update should be the most recent, valid update, otherwise the timestamp may not monotonically increase from the prior.
func UnsignedChannelUpdateFromEdge ¶
func UnsignedChannelUpdateFromEdge(info *channeldb.ChannelEdgeInfo, policy *channeldb.ChannelEdgePolicy) *lnwire.ChannelUpdate
UnsignedChannelUpdateFromEdge reconstructs an unsigned ChannelUpdate from the given edge info and policy.
Types ¶
type ChanStatus ¶
type ChanStatus uint8
ChanStatus is a type that enumerates the possible states a ChanStatusManager tracks for its known channels.
const ( // ChanStatusEnabled indicates that the channel's last announcement has // the disabled bit cleared. ChanStatusEnabled ChanStatus = iota // ChanStatusPendingDisabled indicates that the channel's last // announcement has the disabled bit cleared, but that the channel was // detected in an inactive state. Channels in this state will have a // disabling announcement sent after the ChanInactiveTimeout expires // from the time of the first detection--unless the channel is // explicitly reenabled before the disabling occurs. ChanStatusPendingDisabled // ChanStatusDisabled indicates that the channel's last announcement has // the disabled bit set. ChanStatusDisabled // ChanStatusManuallyDisabled indicates that the channel's last // announcement had the disabled bit set, and that a user manually // requested disabling the channel. Channels in this state will ignore // automatic / background attempts to re-enable the channel. // // Note that there's no corresponding ChanStatusManuallyEnabled state // because even if a user manually requests enabling a channel, we still // DO want to allow automatic / background processes to disable it. // Otherwise, the network might be cluttered with channels that are // advertised as enabled, but don't actually work or even exist. ChanStatusManuallyDisabled )
type ChanStatusConfig ¶
type ChanStatusConfig struct { // OurPubKey is the public key identifying this node on the network. OurPubKey *bronec.PublicKey // OurKeyLoc is the locator for the public key identifying this node on // the network. OurKeyLoc keychain.KeyLocator // MessageSigner signs messages that validate under OurPubKey. MessageSigner lnwallet.MessageSigner // IsChannelActive checks whether the channel identified by the provided // ChannelID is considered active. This should only return true if the // channel has been sufficiently confirmed, the channel has received // FundingLocked, and the remote peer is online. IsChannelActive func(lnwire.ChannelID) bool // ApplyChannelUpdate processes new ChannelUpdates signed by our node by // updating our local routing table and broadcasting the update to our // peers. ApplyChannelUpdate func(*lnwire.ChannelUpdate) error // DB stores the set of channels that are to be monitored. DB DB // Graph stores the channel info and policies for channels in DB. Graph ChannelGraph // ChanEnableTimeout is the duration a peer's connect must remain stable // before attempting to reenable the channel. // // NOTE: This value is only used to verify that the relation between // itself, ChanDisableTimeout, and ChanStatusSampleInterval is correct. // The user is still responsible for ensuring that the same duration // elapses before attempting to reenable a channel. ChanEnableTimeout time.Duration // ChanDisableTimeout is the duration the manager will wait after // detecting that a channel has become inactive before broadcasting an // update to disable the channel. ChanDisableTimeout time.Duration // ChanStatusSampleInterval is the long-polling interval used by the // manager to check if the channels being monitored have become // inactive. ChanStatusSampleInterval time.Duration }
ChanStatusConfig holds parameters and resources required by the ChanStatusManager to perform its duty.
type ChanStatusManager ¶
type ChanStatusManager struct {
// contains filtered or unexported fields
}
ChanStatusManager facilitates requests to enable or disable a channel via a network announcement that sets the disable bit on the ChannelUpdate accordingly. The manager will periodically sample to detect cases where a link has become inactive, and facilitate the process of disabling the channel passively. The ChanStatusManager state machine is designed to reduce the likelihood of spamming the network with updates for flapping peers.
func NewChanStatusManager ¶
func NewChanStatusManager(cfg *ChanStatusConfig) (*ChanStatusManager, error)
NewChanStatusManager initializes a new ChanStatusManager using the given configuration. An error is returned if the timeouts and sample interval fail to meet do not satisfy the equation:
ChanEnableTimeout + ChanStatusSampleInterval > ChanDisableTimeout.
func (*ChanStatusManager) RequestAuto ¶
func (m *ChanStatusManager) RequestAuto(outpoint wire.OutPoint) error
RequestAuto submits a request to restore automatic channel state management. If the channel is in the state ChanStatusManuallyDisabled, it will be moved back to the state ChanStatusDisabled. Otherwise, no action will be taken.
func (*ChanStatusManager) RequestDisable ¶
func (m *ChanStatusManager) RequestDisable(outpoint wire.OutPoint, manual bool) error
RequestDisable submits a request to immediately disable a channel identified by the provided outpoint. If the channel is already disabled, no action will be taken. Otherwise, a new announcement will be signed with the disabled bit set and broadcast to the network.
The channel state will be changed to either ChanStatusDisabled or ChanStatusManuallyDisabled, depending on the passed-in value of manual. In particular, note the following state transitions:
current state | manual | new state --------------------------------------------------- Disabled | false | Disabled ManuallyDisabled | false | ManuallyDisabled (*) Disabled | true | ManuallyDisabled ManuallyDisabled | true | ManuallyDisabled
(*) If a channel was manually disabled, subsequent automatic / background
requests to disable the channel do not change the fact that the channel was manually disabled.
func (*ChanStatusManager) RequestEnable ¶
func (m *ChanStatusManager) RequestEnable(outpoint wire.OutPoint, manual bool) error
RequestEnable submits a request to immediately enable a channel identified by the provided outpoint. If the channel is already enabled, no action will be taken. If the channel is marked pending-disable the channel will be returned to an active status as the scheduled disable was never sent. Otherwise if the channel is found to be disabled, a new announcement will be signed with the disabled bit cleared and broadcast to the network.
If the channel was manually disabled and RequestEnable is called with manual = false, then the request will be ignored.
NOTE: RequestEnable should only be called after a stable connection with the channel's peer has lasted at least the ChanEnableTimeout. Failure to do so may result in behavior that deviates from the expected behavior of the state machine.
func (*ChanStatusManager) Start ¶
func (m *ChanStatusManager) Start() error
Start safely starts the ChanStatusManager.
func (*ChanStatusManager) Stop ¶
func (m *ChanStatusManager) Stop() error
Stop safely shuts down the ChanStatusManager.
type ChannelGraph ¶
type ChannelGraph interface { // FetchChannelEdgesByOutpoint returns the channel edge info and most // recent channel edge policies for a given outpoint. FetchChannelEdgesByOutpoint(*wire.OutPoint) (*channeldb.ChannelEdgeInfo, *channeldb.ChannelEdgePolicy, *channeldb.ChannelEdgePolicy, error) }
ChannelGraph abstracts the required channel graph queries used by the ChanStatusManager.
type ChannelState ¶
type ChannelState struct { // Status is the channel's current ChanStatus from the POV of the // ChanStatusManager. Status ChanStatus // SendDisableTime is the earliest time at which the ChanStatusManager // will passively send a new disable announcement on behalf of this // channel. // // NOTE: This field is only non-zero if status is // ChanStatusPendingDisabled. SendDisableTime time.Time }
ChannelState describes the ChanStatusManager's view of a channel, and describes the current state the channel's disabled status on the network.
type ChannelUpdateModifier ¶
type ChannelUpdateModifier func(*lnwire.ChannelUpdate)
ChannelUpdateModifier is a closure that makes in-place modifications to an lnwire.ChannelUpdate.
func ChanUpdSetDisable ¶
func ChanUpdSetDisable(disabled bool) ChannelUpdateModifier
ChanUpdSetDisable is a functional option that sets the disabled channel flag if disabled is true, and clears the bit otherwise.
type DB ¶
type DB interface { // FetchAllOpenChannels returns a slice of all open channels known to // the daemon. This may include private or pending channels. FetchAllOpenChannels() ([]*channeldb.OpenChannel, error) }
DB abstracts the required database functionality needed by the ChanStatusManager.
type HostAnnouncer ¶
type HostAnnouncer struct {
// contains filtered or unexported fields
}
HostAnnouncer is a sub-system that allows a user to specify a set of hosts for broln that will be continually resolved to notice any IP address changes. If the target IP address for a host changes, then we'll generate a new NodeAnnouncement that includes these new IPs.
func NewHostAnnouncer ¶
func NewHostAnnouncer(cfg HostAnnouncerConfig) *HostAnnouncer
NewHostAnnouncer returns a new instance of the HostAnnouncer.
func (*HostAnnouncer) Stop ¶
func (h *HostAnnouncer) Stop() error
Stop signals the HostAnnouncer for a graceful stop.
type HostAnnouncerConfig ¶
type HostAnnouncerConfig struct { // Hosts is the set of hosts we should watch for IP changes. Hosts []string // RefreshTicker ticks each time we should check for any address // changes. RefreshTicker ticker.Ticker // LookupHost performs DNS resolution on a given host and returns its // addresses. LookupHost func(string) (net.Addr, error) // AdvertisedIPs is the set of IPs that we've already announced with // our current NodeAnnouncement. This set will be constructed to avoid // unnecessary node NodeAnnouncement updates. AdvertisedIPs map[string]struct{} // AnnounceNewIPs announces a new set of IP addresses for the backing // Lightning node. The first set of addresses is the new set of // addresses that we should advertise, while the other set are the // stale addresses that we should no longer advertise. AnnounceNewIPs func([]net.Addr, map[string]struct{}) error }
HostAnnouncerConfig is the main config for the HostAnnouncer.
type NodeAnnModifier ¶
type NodeAnnModifier func(*lnwire.NodeAnnouncement)
NodeAnnModifier is a closure that makes in-place modifications to an lnwire.NodeAnnouncement.
type NodeAnnUpdater ¶
type NodeAnnUpdater func(refresh bool, modifier ...NodeAnnModifier, ) (lnwire.NodeAnnouncement, error)
NodeAnnUpdater describes a function that's able to update our current node announcement on disk. It returns the updated node announcement given a set of updates to be applied to the current node announcement.
type NodeSigner ¶
type NodeSigner struct {
// contains filtered or unexported fields
}
NodeSigner is an implementation of the MessageSigner interface backed by the identity private key of running broln node.
func NewNodeSigner ¶
func NewNodeSigner(keySigner keychain.SingleKeyMessageSigner) *NodeSigner
NewNodeSigner creates a new instance of the NodeSigner backed by the target private key.
func (*NodeSigner) SignMessage ¶
func (n *NodeSigner) SignMessage(keyLoc keychain.KeyLocator, msg []byte, doubleHash bool) (*bronec.Signature, error)
SignMessage signs a double-sha256 digest of the passed msg under the resident node's private key described in the key locator. If the target key locator is _not_ the node's private key, then an error will be returned.
func (*NodeSigner) SignMessageCompact ¶
func (n *NodeSigner) SignMessageCompact(msg []byte, doubleHash bool) ([]byte, error)
SignMessageCompact signs a single or double sha256 digest of the msg parameter under the resident node's private key. The returned signature is a pubkey-recoverable signature.