Skip to content

Commit f648d35

Browse files
committed
loopin: generate route hints correctly if last hop is set
1 parent 48a5f46 commit f648d35

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

loopin.go

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -103,17 +103,20 @@ func newLoopInSwap(globalCtx context.Context, cfg *swapConfig,
103103
return nil, fmt.Errorf("private and route_hints both set")
104104
}
105105

106-
// If Private is set, we generate route hints.
107-
if request.Private {
108-
// If last_hop is set, we'll only add channels with peers set to
109-
// the last_hop parameter.
110-
includeNodes := make(map[route.Vertex]struct{})
111-
if request.LastHop != nil {
112-
includeNodes[*request.LastHop] = struct{}{}
113-
}
114-
115-
// Because the Private flag is set, we'll generate our own set
116-
// of hop hints.
106+
// If last_hop is set, we'll only add channels with peers set to
107+
// the last_hop parameter.
108+
includeNodes := make(map[route.Vertex]struct{})
109+
if request.LastHop != nil {
110+
includeNodes[*request.LastHop] = struct{}{}
111+
}
112+
113+
// SelectHopHints is used to generate route hints for the swap and probe
114+
// invoices. If the user has set the last_hop parameter, we will only
115+
// add channels with peers set to the last_hop parameter. If the user
116+
// has requested a private swap, we'll use the intersection of the last
117+
// hop and the private channels of the node. If the user only requested
118+
// private channels, we'll select from all private channels of the node.
119+
if request.Private || request.LastHop != nil {
117120
request.RouteHints, err = SelectHopHints(
118121
globalCtx, cfg.lnd.Client, request.Amount,
119122
DefaultMaxHopHints, includeNodes,

0 commit comments

Comments
 (0)