routing: add outgoing channel restriction
This commit is contained in:
9 files changed
+735
-579
No files matched your search
+14
-1
@@ -11,7 +11,7 @@ import (
|
||||
"github.com/btcsuite/btcd/btcec"
|
||||
"github.com/coreos/bbolt"
|
||||
|
||||
"github.com/lightningnetwork/lightning-onion"
|
||||
sphinx "github.com/lightningnetwork/lightning-onion"
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
)
|
||||
@@ -453,6 +453,10 @@ type restrictParams struct {
|
||||
// feeLimit is a maximum fee amount allowed to be used on the path from
|
||||
// the source to the target.
|
||||
feeLimit lnwire.MilliSatoshi
|
||||
|
||||
// outgoingChannelID is the channel that needs to be taken to the first
|
||||
// hop. If nil, any channel may be used.
|
||||
outgoingChannelID *uint64
|
||||
}
|
||||
|
||||
// findPath attempts to find a path from the source node within the
|
||||
@@ -563,6 +567,7 @@ func findPath(g *graphParams, r *restrictParams,
|
||||
// TODO(halseth): also ignore disable flags for non-local
|
||||
// channels if bandwidth hint is set?
|
||||
isSourceChan := fromVertex == sourceVertex
|
||||
|
||||
edgeFlags := edge.ChannelFlags
|
||||
isDisabled := edgeFlags&lnwire.ChanUpdateDisabled != 0
|
||||
|
||||
@@ -570,6 +575,14 @@ func findPath(g *graphParams, r *restrictParams,
|
||||
return
|
||||
}
|
||||
|
||||
// If we have an outgoing channel restriction and this is not
|
||||
// the specified channel, skip it.
|
||||
if isSourceChan && r.outgoingChannelID != nil &&
|
||||
*r.outgoingChannelID != edge.ChannelID {
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// If this vertex or edge has been black listed, then we'll
|
||||
// skip exploring this edge.
|
||||
if _, ok := r.ignoredNodes[fromVertex]; ok {
|
||||
|
||||
Reference in new issue
Block a user