Documentation ¶
Index ¶
- Constants
- Variables
- func DisableLog()
- func IsError(e interface{}, codes ...errorCode) bool
- func UseLogger(logger btclog.Logger)
- func ValidateChannelAnn(a *lnwire.ChannelAnnouncement) error
- func ValidateChannelUpdateAnn(pubKey *pfcec.PublicKey, a *lnwire.ChannelUpdate) error
- func ValidateNodeAnn(a *lnwire.NodeAnnouncement) error
- type ChannelEdgeUpdate
- type ChannelGraphSource
- type ChannelPolicy
- type ChannelRouter
- func (r *ChannelRouter) AddEdge(edge *channeldb.ChannelEdgeInfo) error
- func (r *ChannelRouter) AddNode(node *channeldb.LightningNode) error
- func (r *ChannelRouter) AddProof(chanID lnwire.ShortChannelID, proof *channeldb.ChannelAuthProof) error
- func (r *ChannelRouter) CurrentBlockHeight() (uint32, error)
- func (r *ChannelRouter) FetchLightningNode(node Vertex) (*channeldb.LightningNode, error)
- func (r *ChannelRouter) FindRoutes(target *pfcec.PublicKey, amt, feeLimit lnwire.MilliSatoshi, numPaths uint32, ...) ([]*Route, error)
- func (r *ChannelRouter) ForAllOutgoingChannels(cb func(*channeldb.ChannelEdgeInfo, *channeldb.ChannelEdgePolicy) error) error
- func (r *ChannelRouter) ForEachChannel(...) error
- func (r *ChannelRouter) ForEachNode(cb func(*channeldb.LightningNode) error) error
- func (r *ChannelRouter) GetChannelByID(chanID lnwire.ShortChannelID) (*channeldb.ChannelEdgeInfo, *channeldb.ChannelEdgePolicy, ...)
- func (r *ChannelRouter) IsKnownEdge(chanID lnwire.ShortChannelID) bool
- func (r *ChannelRouter) IsPublicNode(node Vertex) (bool, error)
- func (r *ChannelRouter) IsStaleEdgePolicy(chanID lnwire.ShortChannelID, timestamp time.Time, flags lnwire.ChanUpdateFlag) bool
- func (r *ChannelRouter) IsStaleNode(node Vertex, timestamp time.Time) bool
- func (r *ChannelRouter) SendPayment(payment *LightningPayment) ([32]byte, *Route, error)
- func (r *ChannelRouter) SendToRoute(routes []*Route, payment *LightningPayment) ([32]byte, *Route, error)
- func (r *ChannelRouter) Start() error
- func (r *ChannelRouter) Stop() error
- func (r *ChannelRouter) SubscribeTopology() (*TopologyClient, error)
- func (r *ChannelRouter) UpdateEdge(update *channeldb.ChannelEdgePolicy) error
- type ClosedChanSummary
- type Conf
- type Config
- type FeeSchema
- type Hop
- type HopHint
- type LightningPayment
- type NetworkNodeUpdate
- type Route
- type TopologyChange
- type TopologyClient
- type ValidationBarrier
- type Vertex
Constants ¶
const ( // ErrNoPathFound is returned when a path to the target destination // does not exist in the graph. ErrNoPathFound errorCode = iota // ErrNoRouteFound is returned when the router is unable to find a // valid route to the target destination after fees and time-lock // limitations are factored in. ErrNoRouteFound // ErrInsufficientCapacity is returned when a path if found, yet the // capacity of one of the channels in the path is insufficient to carry // the payment. ErrInsufficientCapacity // ErrMaxHopsExceeded is returned when a candidate path is found, but // the length of that path exceeds HopLimit. ErrMaxHopsExceeded // ErrTargetNotInNetwork is returned when the target of a path-finding // or payment attempt isn't known to be within the current version of // the channel graph. ErrTargetNotInNetwork // ErrOutdated is returned when the routing update already have // been applied, or a newer update is already known. ErrOutdated // ErrIgnored is returned when the update have been ignored because // this update can't bring us something new, or because a node // announcement was given for node not found in any channel. ErrIgnored // ErrRejected is returned if the update is for a channel ID that was // previously added to the reject cache because of an invalid update // was attempted to be processed. ErrRejected // ErrPaymentAttemptTimeout is an error that indicates that a payment // attempt timed out before we were able to successfully route an HTLC. ErrPaymentAttemptTimeout // ErrFeeLimitExceeded is returned when the total fees of a route exceed // the user-specified fee limit. ErrFeeLimitExceeded )
const ( // HopLimit is the maximum number hops that is permissible as a route. // Any potential paths found that lie above this limit will be rejected // with an error. This value is computed using the current fixed-size // packet length of the Sphinx construction. HopLimit = 20 // RiskFactorBillionths controls the influence of time lock delta // of a channel on route selection. It is expressed as billionths // of msat per msat sent through the channel per time lock delta // block. See edgeWeight function below for more details. // The chosen value is based on the previous incorrect weight function // 1 + timelock + fee * fee. In this function, the fee penalty // diminishes the time lock penalty for all but the smallest amounts. // To not change the behaviour of path finding too drastically, a // relatively small value is chosen which is still big enough to give // some effect with smaller time lock values. The value may need // tweaking and/or be made configurable in the future. RiskFactorBillionths = 15 )
const ( // DefaultFinalCLTVDelta is the default value to be used as the final // CLTV delta for a route if one is unspecified. DefaultFinalCLTVDelta = 9 )
Variables ¶
var ( // ErrNoRouteHopsProvided is returned when a caller attempts to // construct a new sphinx packet, but provides an empty set of hops for // each route. ErrNoRouteHopsProvided = fmt.Errorf("empty route hops provided") )
var ErrVBarrierShuttingDown = errors.New("validation barrier shutting down")
ErrVBarrierShuttingDown signals that the barrier has been requested to shutdown, and that the caller should not treat the wait condition as fulfilled.
Functions ¶
func DisableLog ¶
func DisableLog()
DisableLog disables all library log output. Logging output is disabled by by default until UseLogger is called.
func IsError ¶
func IsError(e interface{}, codes ...errorCode) bool
IsError is a helper function which is needed to have ability to check that returned error has specific error code.
func UseLogger ¶
UseLogger uses a specified Logger to output package logging info. This should be used in preference to SetLogWriter if the caller is also using btclog.
func ValidateChannelAnn ¶
func ValidateChannelAnn(a *lnwire.ChannelAnnouncement) error
ValidateChannelAnn validates the channel announcement message and checks that node signatures covers the announcement message, and that the picfightcoin signatures covers the node keys.
func ValidateChannelUpdateAnn ¶
func ValidateChannelUpdateAnn(pubKey *pfcec.PublicKey, a *lnwire.ChannelUpdate) error
ValidateChannelUpdateAnn validates the channel update announcement by checking that the included signature covers he announcement and has been signed by the node's private key.
func ValidateNodeAnn ¶
func ValidateNodeAnn(a *lnwire.NodeAnnouncement) error
ValidateNodeAnn validates the node announcement by ensuring that the attached signature is needed a signature of the node announcement under the specified node public key.
Types ¶
type ChannelEdgeUpdate ¶
type ChannelEdgeUpdate struct { // ChanID is the unique short channel ID for the channel. This encodes // where in the blockchain the channel's funding transaction was // originally confirmed. ChanID uint64 // ChanPoint is the outpoint which represents the multi-sig funding // output for the channel. ChanPoint wire.OutPoint // Capacity is the capacity of the newly created channel. Capacity pfcutil.Amount // MinHTLC is the minimum HTLC amount that this channel will forward. MinHTLC lnwire.MilliSatoshi // BaseFee is the base fee that will charged for all HTLC's forwarded // across the this channel direction. BaseFee lnwire.MilliSatoshi // FeeRate is the fee rate that will be shared for all HTLC's forwarded // across this channel direction. FeeRate lnwire.MilliSatoshi // TimeLockDelta is the time-lock expressed in blocks that will be // added to outgoing HTLC's from incoming HTLC's. This value is the // difference of the incoming and outgoing HTLC's time-locks routed // through this hop. TimeLockDelta uint16 // AdvertisingNode is the node that's advertising this edge. AdvertisingNode *pfcec.PublicKey // ConnectingNode is the node that the advertising node connects to. ConnectingNode *pfcec.PublicKey // Disabled, if true, signals that the channel is unavailable to relay // payments. Disabled bool }
ChannelEdgeUpdate is an update for a new channel within the ChannelGraph. This update is sent out once a new authenticated channel edge is discovered within the network. These updates are directional, so if a channel is fully public, then there will be two updates sent out: one for each direction within the channel. Each update will carry that particular routing edge policy for the channel direction.
An edge is a channel in the direction of AdvertisingNode -> ConnectingNode.
type ChannelGraphSource ¶
type ChannelGraphSource interface { // AddNode is used to add information about a node to the router // database. If the node with this pubkey is not present in an existing // channel, it will be ignored. AddNode(node *channeldb.LightningNode) error // AddEdge is used to add edge/channel to the topology of the router, // after all information about channel will be gathered this // edge/channel might be used in construction of payment path. AddEdge(edge *channeldb.ChannelEdgeInfo) error // AddProof updates the channel edge info with proof which is needed to // properly announce the edge to the rest of the network. AddProof(chanID lnwire.ShortChannelID, proof *channeldb.ChannelAuthProof) error // UpdateEdge is used to update edge information, without this message // edge considered as not fully constructed. UpdateEdge(policy *channeldb.ChannelEdgePolicy) error // IsStaleNode returns true if the graph source has a node announcement // for the target node with a more recent timestamp. This method will // also return true if we don't have an active channel announcement for // the target node. IsStaleNode(node Vertex, timestamp time.Time) bool // IsPublicNode determines whether the given vertex is seen as a public // node in the graph from the graph's source node's point of view. IsPublicNode(node Vertex) (bool, error) // IsKnownEdge returns true if the graph source already knows of the // passed channel ID. IsKnownEdge(chanID lnwire.ShortChannelID) bool // IsStaleEdgePolicy returns true if the graph source has a channel // edge for the passed channel ID (and flags) that have a more recent // timestamp. IsStaleEdgePolicy(chanID lnwire.ShortChannelID, timestamp time.Time, flags lnwire.ChanUpdateFlag) bool // ForAllOutgoingChannels is used to iterate over all channels // emanating from the "source" node which is the center of the // star-graph. ForAllOutgoingChannels(cb func(c *channeldb.ChannelEdgeInfo, e *channeldb.ChannelEdgePolicy) error) error // CurrentBlockHeight returns the block height from POV of the router // subsystem. CurrentBlockHeight() (uint32, error) // GetChannelByID return the channel by the channel id. GetChannelByID(chanID lnwire.ShortChannelID) (*channeldb.ChannelEdgeInfo, *channeldb.ChannelEdgePolicy, *channeldb.ChannelEdgePolicy, error) // FetchLightningNode attempts to look up a target node by its identity // public key. channeldb.ErrGraphNodeNotFound is returned if the node // doesn't exist within the graph. FetchLightningNode(Vertex) (*channeldb.LightningNode, error) // ForEachNode is used to iterate over every node in the known graph. ForEachNode(func(node *channeldb.LightningNode) error) error // ForEachChannel is used to iterate over every channel in the known // graph. ForEachChannel(func(chanInfo *channeldb.ChannelEdgeInfo, e1, e2 *channeldb.ChannelEdgePolicy) error) error }
ChannelGraphSource represents the source of information about the topology of the lightning network. It's responsible for the addition of nodes, edges, applying edge updates, and returning the current block height with which the topology is synchronized.
type ChannelPolicy ¶
type ChannelPolicy struct { // FeeSchema holds the fee configuration for a channel. FeeSchema // TimeLockDelta is the required HTLC timelock delta to be used // when forwarding payments. TimeLockDelta uint32 }
ChannelPolicy holds the parameters that determine the policy we enforce when forwarding payments on a channel. These parameters are communicated to the rest of the network in ChannelUpdate messages.
type ChannelRouter ¶
ChannelRouter is the layer 3 router within the Lightning stack. Below the ChannelRouter is the HtlcSwitch, and below that is the Picfightcoin blockchain itself. The primary role of the ChannelRouter is to respond to queries for potential routes that can support a payment amount, and also general graph reachability questions. The router will prune the channel graph automatically as new blocks are discovered which spend certain known funding outpoints, thereby closing their respective channels.
func New ¶
func New(cfg Config) (*ChannelRouter, error)
New creates a new instance of the ChannelRouter with the specified configuration parameters. As part of initialization, if the router detects that the channel graph isn't fully in sync with the latest UTXO (since the channel graph is a subset of the UTXO set) set, then the router will proceed to fully sync to the latest state of the UTXO set.
func (*ChannelRouter) AddEdge ¶
func (r *ChannelRouter) AddEdge(edge *channeldb.ChannelEdgeInfo) error
AddEdge is used to add edge/channel to the topology of the router, after all information about channel will be gathered this edge/channel might be used in construction of payment path.
NOTE: This method is part of the ChannelGraphSource interface.
func (*ChannelRouter) AddNode ¶
func (r *ChannelRouter) AddNode(node *channeldb.LightningNode) error
AddNode is used to add information about a node to the router database. If the node with this pubkey is not present in an existing channel, it will be ignored.
NOTE: This method is part of the ChannelGraphSource interface.
func (*ChannelRouter) AddProof ¶
func (r *ChannelRouter) AddProof(chanID lnwire.ShortChannelID, proof *channeldb.ChannelAuthProof) error
AddProof updates the channel edge info with proof which is needed to properly announce the edge to the rest of the network.
NOTE: This method is part of the ChannelGraphSource interface.
func (*ChannelRouter) CurrentBlockHeight ¶
func (r *ChannelRouter) CurrentBlockHeight() (uint32, error)
CurrentBlockHeight returns the block height from POV of the router subsystem.
NOTE: This method is part of the ChannelGraphSource interface.
func (*ChannelRouter) FetchLightningNode ¶
func (r *ChannelRouter) FetchLightningNode(node Vertex) (*channeldb.LightningNode, error)
FetchLightningNode attempts to look up a target node by its identity public key. channeldb.ErrGraphNodeNotFound is returned if the node doesn't exist within the graph.
NOTE: This method is part of the ChannelGraphSource interface.
func (*ChannelRouter) FindRoutes ¶
func (r *ChannelRouter) FindRoutes(target *pfcec.PublicKey, amt, feeLimit lnwire.MilliSatoshi, numPaths uint32, finalExpiry ...uint16) ([]*Route, error)
FindRoutes attempts to query the ChannelRouter for a bounded number available paths to a particular target destination which is able to send `amt` after factoring in channel capacities and cumulative fees along each route. To `numPaths eligible paths, we use a modified version of Yen's algorithm which itself uses a modified version of Dijkstra's algorithm within its inner loop. Once we have a set of candidate routes, we calculate the required fee and time lock values running backwards along the route. The route that will be ranked the highest is the one with the lowest cumulative fee along the route.
func (*ChannelRouter) ForAllOutgoingChannels ¶
func (r *ChannelRouter) ForAllOutgoingChannels(cb func(*channeldb.ChannelEdgeInfo, *channeldb.ChannelEdgePolicy) error) error
ForAllOutgoingChannels is used to iterate over all outgoing channels owned by the router.
NOTE: This method is part of the ChannelGraphSource interface.
func (*ChannelRouter) ForEachChannel ¶
func (r *ChannelRouter) ForEachChannel(cb func(chanInfo *channeldb.ChannelEdgeInfo, e1, e2 *channeldb.ChannelEdgePolicy) error) error
ForEachChannel is used to iterate over every known edge (channel) within our view of the channel graph.
NOTE: This method is part of the ChannelGraphSource interface.
func (*ChannelRouter) ForEachNode ¶
func (r *ChannelRouter) ForEachNode(cb func(*channeldb.LightningNode) error) error
ForEachNode is used to iterate over every node in router topology.
NOTE: This method is part of the ChannelGraphSource interface.
func (*ChannelRouter) GetChannelByID ¶
func (r *ChannelRouter) GetChannelByID(chanID lnwire.ShortChannelID) ( *channeldb.ChannelEdgeInfo, *channeldb.ChannelEdgePolicy, *channeldb.ChannelEdgePolicy, error)
GetChannelByID return the channel by the channel id.
NOTE: This method is part of the ChannelGraphSource interface.
func (*ChannelRouter) IsKnownEdge ¶
func (r *ChannelRouter) IsKnownEdge(chanID lnwire.ShortChannelID) bool
IsKnownEdge returns true if the graph source already knows of the passed channel ID.
NOTE: This method is part of the ChannelGraphSource interface.
func (*ChannelRouter) IsPublicNode ¶
func (r *ChannelRouter) IsPublicNode(node Vertex) (bool, error)
IsPublicNode determines whether the given vertex is seen as a public node in the graph from the graph's source node's point of view.
NOTE: This method is part of the ChannelGraphSource interface.
func (*ChannelRouter) IsStaleEdgePolicy ¶
func (r *ChannelRouter) IsStaleEdgePolicy(chanID lnwire.ShortChannelID, timestamp time.Time, flags lnwire.ChanUpdateFlag) bool
IsStaleEdgePolicy returns true if the graph soruce has a channel edge for the passed channel ID (and flags) that have a more recent timestamp.
NOTE: This method is part of the ChannelGraphSource interface.
func (*ChannelRouter) IsStaleNode ¶
func (r *ChannelRouter) IsStaleNode(node Vertex, timestamp time.Time) bool
IsStaleNode returns true if the graph source has a node announcement for the target node with a more recent timestamp.
NOTE: This method is part of the ChannelGraphSource interface.
func (*ChannelRouter) SendPayment ¶
func (r *ChannelRouter) SendPayment(payment *LightningPayment) ([32]byte, *Route, error)
SendPayment attempts to send a payment as described within the passed LightningPayment. This function is blocking and will return either: when the payment is successful, or all candidates routes have been attempted and resulted in a failed payment. If the payment succeeds, then a non-nil Route will be returned which describes the path the successful payment traversed within the network to reach the destination. Additionally, the payment preimage will also be returned.
func (*ChannelRouter) SendToRoute ¶
func (r *ChannelRouter) SendToRoute(routes []*Route, payment *LightningPayment) ([32]byte, *Route, error)
SendToRoute attempts to send a payment as described within the passed LightningPayment through the provided routes. This function is blocking and will return either: when the payment is successful, or all routes have been attempted and resulted in a failed payment. If the payment succeeds, then a non-nil Route will be returned which describes the path the successful payment traversed within the network to reach the destination. Additionally, the payment preimage will also be returned.
func (*ChannelRouter) Start ¶
func (r *ChannelRouter) Start() error
Start launches all the goroutines the ChannelRouter requires to carry out its duties. If the router has already been started, then this method is a noop.
func (*ChannelRouter) Stop ¶
func (r *ChannelRouter) Stop() error
Stop signals the ChannelRouter to gracefully halt all routines. This method will *block* until all goroutines have excited. If the channel router has already stopped then this method will return immediately.
func (*ChannelRouter) SubscribeTopology ¶
func (r *ChannelRouter) SubscribeTopology() (*TopologyClient, error)
SubscribeTopology returns a new topology client which can be used by the caller to receive notifications whenever a change in the channel graph topology occurs. Changes that will be sent at notifications include: new nodes appearing, node updating their attributes, new channels, channels closing, and updates in the routing policies of a channel's directed edges.
func (*ChannelRouter) UpdateEdge ¶
func (r *ChannelRouter) UpdateEdge(update *channeldb.ChannelEdgePolicy) error
UpdateEdge is used to update edge information, without this message edge considered as not fully constructed.
NOTE: This method is part of the ChannelGraphSource interface.
type ClosedChanSummary ¶
type ClosedChanSummary struct { // ChanID is the short-channel ID which uniquely identifies the // channel. ChanID uint64 // Capacity was the total capacity of the channel before it was closed. Capacity pfcutil.Amount // ClosedHeight is the height in the chain that the channel was closed // at. ClosedHeight uint32 // ChanPoint is the funding point, or the multi-sig utxo which // previously represented the channel. ChanPoint wire.OutPoint }
ClosedChanSummary is a summary of a channel that was detected as being closed by monitoring the blockchain. Once a channel's funding point has been spent, the channel will automatically be marked as closed by the ChainNotifier.
TODO(roasbeef): add nodes involved?
type Conf ¶
type Conf struct{}
Conf provides the command line routing configuration. There are no fields in the production build so that this section is hidden by default.
func (*Conf) UseAssumeChannelValid ¶
UseAssumeChannelValid always returns false when not in experimental builds.
type Config ¶
type Config struct { // Graph is the channel graph that the ChannelRouter will use to gather // metrics from and also to carry out path finding queries. // TODO(roasbeef): make into an interface Graph *channeldb.ChannelGraph // Chain is the router's source to the most up-to-date blockchain data. // All incoming advertised channels will be checked against the chain // to ensure that the channels advertised are still open. Chain lnwallet.BlockChainIO // ChainView is an instance of a FilteredChainView which is used to // watch the sub-set of the UTXO set (the set of active channels) that // we need in order to properly maintain the channel graph. ChainView chainview.FilteredChainView // SendToSwitch is a function that directs a link-layer switch to // forward a fully encoded payment to the first hop in the route // denoted by its public key. A non-nil error is to be returned if the // payment was unsuccessful. SendToSwitch func(firstHop lnwire.ShortChannelID, htlcAdd *lnwire.UpdateAddHTLC, circuit *sphinx.Circuit) ([sha256.Size]byte, error) // ChannelPruneExpiry is the duration used to determine if a channel // should be pruned or not. If the delta between now and when the // channel was last updated is greater than ChannelPruneExpiry, then // the channel is marked as a zombie channel eligible for pruning. ChannelPruneExpiry time.Duration // GraphPruneInterval is used as an interval to determine how often we // should examine the channel graph to garbage collect zombie channels. GraphPruneInterval time.Duration // QueryBandwidth is a method that allows the router to query the lower // link layer to determine the up to date available bandwidth at a // prospective link to be traversed. If the link isn't available, then // a value of zero should be returned. Otherwise, the current up to // date knowledge of the available bandwidth of the link should be // returned. QueryBandwidth func(edge *channeldb.ChannelEdgeInfo) lnwire.MilliSatoshi // AssumeChannelValid toggles whether or not the router will check for // spentness of channel outpoints. For neutrino, this saves long rescans // from blocking initial usage of the wallet. This should only be // enabled on testnet. AssumeChannelValid bool }
Config defines the configuration for the ChannelRouter. ALL elements within the configuration MUST be non-nil for the ChannelRouter to carry out its duties.
type FeeSchema ¶
type FeeSchema struct { // BaseFee is the base amount of milli-satoshis that will be chained // for ANY payment forwarded. BaseFee lnwire.MilliSatoshi // FeeRate is the rate that will be charged for forwarding payments. // This value should be interpreted as the numerator for a fraction // (fixed point arithmetic) whose denominator is 1 million. As a result // the effective fee rate charged per mSAT will be: (amount * // FeeRate/1,000,000). FeeRate uint32 }
FeeSchema is the set fee configuration for a Lightning Node on the network. Using the coefficients described within the schema, the required fee to forward outgoing payments can be derived.
type Hop ¶
type Hop struct { // PubKeyBytes is the raw bytes of the public key of the target node. PubKeyBytes Vertex // ChannelID is the unique channel ID for the channel. The first 3 // bytes are the block height, the next 3 the index within the block, // and the last 2 bytes are the output index for the channel. ChannelID uint64 // OutgoingTimeLock is the timelock value that should be used when // crafting the _outgoing_ HTLC from this hop. OutgoingTimeLock uint32 // AmtToForward is the amount that this hop will forward to the next // hop. This value is less than the value that the incoming HTLC // carries as a fee will be subtracted by the hop. AmtToForward lnwire.MilliSatoshi }
Hop represents an intermediate or final node of the route. This naming is in line with the definition given in BOLT #4: Onion Routing Protocol. The struct houses the channel along which this hop can be reached and the values necessary to create the HTLC that needs to be sent to the next hop. It is also used to encode the per-hop payload included within the Sphinx packet.
type HopHint ¶
type HopHint struct { // NodeID is the public key of the node at the start of the channel. NodeID *pfcec.PublicKey // ChannelID is the unique identifier of the channel. ChannelID uint64 // FeeBaseMSat is the base fee of the channel in millisatoshis. FeeBaseMSat uint32 // FeeProportionalMillionths is the fee rate, in millionths of a // satoshi, for every satoshi sent through the channel. FeeProportionalMillionths uint32 // CLTVExpiryDelta is the time-lock delta of the channel. CLTVExpiryDelta uint16 }
HopHint is a routing hint that contains the minimum information of a channel required for an intermediate hop in a route to forward the payment to the next. This should be ideally used for private channels, since they are not publicly advertised to the network for routing.
type LightningPayment ¶
type LightningPayment struct { // Target is the node in which the payment should be routed towards. Target *pfcec.PublicKey // Amount is the value of the payment to send through the network in // milli-satoshis. Amount lnwire.MilliSatoshi // FeeLimit is the maximum fee in millisatoshis that the payment should // accept when sending it through the network. The payment will fail // if there isn't a route with lower fees than this limit. FeeLimit lnwire.MilliSatoshi // PaymentHash is the r-hash value to use within the HTLC extended to // the first hop. PaymentHash [32]byte // FinalCLTVDelta is the CTLV expiry delta to use for the _final_ hop // in the route. This means that the final hop will have a CLTV delta // of at least: currentHeight + FinalCLTVDelta. If this value is // unspecified, then a default value of DefaultFinalCLTVDelta will be // used. FinalCLTVDelta *uint16 // PayAttemptTimeout is a timeout value that we'll use to determine // when we should should abandon the payment attempt after consecutive // payment failure. This prevents us from attempting to send a payment // indefinitely. PayAttemptTimeout time.Duration // RouteHints represents the different routing hints that can be used to // assist a payment in reaching its destination successfully. These // hints will act as intermediate hops along the route. // // NOTE: This is optional unless required by the payment. When providing // multiple routes, ensure the hop hints within each route are chained // together and sorted in forward order in order to reach the // destination successfully. RouteHints [][]HopHint }
LightningPayment describes a payment to be sent through the network to the final destination.
type NetworkNodeUpdate ¶
type NetworkNodeUpdate struct { // Addresses is a slice of all the node's known addresses. Addresses []net.Addr // IdentityKey is the identity public key of the target node. This is // used to encrypt onion blobs as well as to authenticate any new // updates. IdentityKey *pfcec.PublicKey // GlobalFeatures is a set of opaque bytes that describe the set of // features supported by the node. GlobalFeatures []byte // Alias is the alias or nick name of the node. Alias string }
NetworkNodeUpdate is an update for a node within the Lightning Network. A NetworkNodeUpdate is sent out either when a new node joins the network, or a node broadcasts a new update with a newer time stamp that supersedes its old update. All updates are properly authenticated.
type Route ¶
type Route struct { // TotalTimeLock is the cumulative (final) time lock across the entire // route. This is the CLTV value that should be extended to the first // hop in the route. All other hops will decrement the time-lock as // advertised, leaving enough time for all hops to wait for or present // the payment preimage to complete the payment. TotalTimeLock uint32 // TotalFees is the sum of the fees paid at each hop within the final // route. In the case of a one-hop payment, this value will be zero as // we don't need to pay a fee to ourself. TotalFees lnwire.MilliSatoshi // TotalAmount is the total amount of funds required to complete a // payment over this route. This value includes the cumulative fees at // each hop. As a result, the HTLC extended to the first-hop in the // route will need to have at least this many satoshis, otherwise the // route will fail at an intermediate node due to an insufficient // amount of fees. TotalAmount lnwire.MilliSatoshi // SourcePubKey is the pubkey of the node where this route originates // from. SourcePubKey Vertex // Hops contains details concerning the specific forwarding details at // each hop. Hops []*Hop // contains filtered or unexported fields }
Route represents a path through the channel graph which runs over one or more channels in succession. This struct carries all the information required to craft the Sphinx onion packet, and send the payment along the first hop in the path. A route is only selected as valid if all the channels have sufficient capacity to carry the initial payment amount after fees are accounted for.
func NewRouteFromHops ¶
func NewRouteFromHops(amtToSend lnwire.MilliSatoshi, timeLock uint32, sourceVertex Vertex, hops []*Hop) (*Route, error)
NewRouteFromHops creates a new Route structure from the minimally required information to perform the payment. It infers fee amounts and populates the node, chan and prev/next hop maps.
func (*Route) HopFee ¶
func (r *Route) HopFee(hopIndex int) lnwire.MilliSatoshi
HopFee returns the fee charged by the route hop indicated by hopIndex.
func (*Route) ToHopPayloads ¶
func (r *Route) ToHopPayloads() []sphinx.HopData
ToHopPayloads converts a complete route into the series of per-hop payloads that is to be encoded within each HTLC using an opaque Sphinx packet.
type TopologyChange ¶
type TopologyChange struct { // NodeUpdates is a slice of nodes which are either new to the channel // graph, or have had their attributes updated in an authenticated // manner. NodeUpdates []*NetworkNodeUpdate // ChanelEdgeUpdates is a slice of channel edges which are either newly // opened and authenticated, or have had their routing policies // updated. ChannelEdgeUpdates []*ChannelEdgeUpdate // ClosedChannels contains a slice of close channel summaries which // described which block a channel was closed at, and also carry // supplemental information such as the capacity of the former channel. ClosedChannels []*ClosedChanSummary }
TopologyChange represents a new set of modifications to the channel graph. Topology changes will be dispatched in real-time as the ChannelGraph validates and process modifications to the authenticated channel graph.
type TopologyClient ¶
type TopologyClient struct { // TopologyChanges is a receive only channel that new channel graph // updates will be sent over. // // TODO(roasbeef): chan for each update type instead? TopologyChanges <-chan *TopologyChange // Cancel is a function closure that should be executed when the client // wishes to cancel their notification intent. Doing so allows the // ChannelRouter to free up resources. Cancel func() }
TopologyClient represents an intent to receive notifications from the channel router regarding changes to the topology of the channel graph. The TopologyChanges channel will be sent upon with new updates to the channel graph in real-time as they're encountered.
type ValidationBarrier ¶
ValidationBarrier is a barrier used to ensure proper validation order while concurrently validating new announcements for channel edges, and the attributes of channel edges. It uses this set of maps (protected by this mutex) to track validation dependencies. For a given channel our dependencies look like this: chanAnn <- chanUp <- nodeAnn. That is we must validate the item on the left of the arrow before that on the right.
func NewValidationBarrier ¶
func NewValidationBarrier(numActiveReqs int, quitChan chan struct{}) *ValidationBarrier
NewValidationBarrier creates a new instance of a validation barrier given the total number of active requests, and a quit channel which will be used to know when to kill pending, but unfilled jobs.
func (*ValidationBarrier) CompleteJob ¶
func (v *ValidationBarrier) CompleteJob()
CompleteJob returns a free slot to the set of available job slots. This should be called once a job has been fully completed. Otherwise, slots may not be returned to the internal scheduling, causing a deadlock when a new overflow job is attempted.
func (*ValidationBarrier) InitJobDependencies ¶
func (v *ValidationBarrier) InitJobDependencies(job interface{})
InitJobDependencies will wait for a new job slot to become open, and then sets up any dependent signals/trigger for the new job
func (*ValidationBarrier) SignalDependants ¶
func (v *ValidationBarrier) SignalDependants(job interface{})
SignalDependants will signal any jobs that are dependent on this job that they can continue execution. If the job doesn't have any dependants, then this function sill exit immediately.
func (*ValidationBarrier) WaitForDependants ¶
func (v *ValidationBarrier) WaitForDependants(job interface{}) error
WaitForDependants will block until any jobs that this job dependants on have finished executing. This allows us a graceful way to schedule goroutines based on any pending uncompleted dependent jobs. If this job doesn't have an active dependent, then this function will return immediately.