Skip to content

Commit adc5c80

Browse files
committed
routing: add the option to set the income node or channel on blinded path
1 parent fdff391 commit adc5c80

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

routing/pathfind.go

+27
Original file line numberDiff line numberDiff line change
@@ -1165,6 +1165,14 @@ type blindedPathRestrictions struct {
11651165
// nodeOmissionSet holds a set of node IDs of nodes that we should
11661166
// ignore during blinded path selection.
11671167
nodeOmissionSet fn.Set[route.Vertex]
1168+
1169+
// nodeIncomeSet holds a set of node IDs of nodes that we should
1170+
// use as income hope during blinded path selection.
1171+
nodeIncomeSet fn.Set[route.Vertex]
1172+
1173+
// channelIncomeSet holds a set of channel IDs of channels that we
1174+
// should use as income channel during blinded path selection.
1175+
channelIncomeSet fn.Set[uint64]
11681176
}
11691177

11701178
// blindedHop holds the information about a hop we have selected for a blinded
@@ -1274,6 +1282,15 @@ func processNodeForBlindedPath(g Graph, node route.Vertex,
12741282
return nil, false, nil
12751283
}
12761284

1285+
// If we have explicity been told to consider this node as the
1286+
// income hope.
1287+
if !restrictions.nodeIncomeSet.IsEmpty() {
1288+
if len(alreadyVisited) == 1 &&
1289+
!restrictions.nodeIncomeSet.Contains(node) {
1290+
return nil, false, nil
1291+
}
1292+
}
1293+
12771294
supports, err := supportsRouteBlinding(node)
12781295
if err != nil {
12791296
return nil, false, err
@@ -1300,6 +1317,16 @@ func processNodeForBlindedPath(g Graph, node route.Vertex,
13001317
// node that can be used for blinded paths
13011318
err = g.ForEachNodeChannel(node,
13021319
func(channel *channeldb.DirectedChannel) error {
1320+
// If we have explicity been told to consider this
1321+
// channel as the income hope.
1322+
channelIncomeSet := restrictions.channelIncomeSet
1323+
if !channelIncomeSet.IsEmpty() {
1324+
if len(alreadyVisited) == 0 &&
1325+
!channelIncomeSet.Contains(channel.ChannelID) {
1326+
return nil
1327+
}
1328+
}
1329+
13031330
// Keep track of how many incoming channels this node
13041331
// has. We only use a node as an introduction node if it
13051332
// has channels other than the one that lead us to it.

0 commit comments

Comments
 (0)