multi: pass private, routehints from loopcli - loopd - loop server

This commit passes routehints all the way from when/if the user passes
them from the cli all the way to the backend loop server. If private is
used, this commit passes that boolean down to different stages, where it
is then converted into routehints.

main: add --private and --route_hints to quote

Adds --private and --route_hints flags to quote cli
This commit is contained in:
Harsha Goli 2021-10-19 18:05:59 -04:00
parent 4299147895
commit f1a7d8fb49
No known key found for this signature in database
GPG key ID: 90E00CCB1C74C611
11 changed files with 654 additions and 432 deletions

View file

@ -15,6 +15,7 @@ import (
"github.com/lightninglabs/loop/loopdb"
"github.com/lightninglabs/loop/swap"
"github.com/lightninglabs/loop/sweep"
"github.com/lightningnetwork/lnd/routing/route"
"google.golang.org/grpc/status"
)
@ -563,6 +564,30 @@ func (s *Client) LoopInQuote(ctx context.Context,
return nil, ErrSwapAmountTooHigh
}
// Private and routehints are mutually exclusive as setting private
// means we retrieve our own routehints from the connected node.
if len(request.RouteHints) != 0 && request.Private {
return nil, fmt.Errorf("private and route_hints both set")
}
if request.Private {
// If last_hop is set, we'll only add channels with peers
// set to the last_hop parameter
includeNodes := make(map[route.Vertex]struct{})
if request.LastHop != nil {
includeNodes[*request.LastHop] = struct{}{}
}
// Because the Private flag is set, we'll generate our own
// set of hop hints and use that
request.RouteHints, err = SelectHopHints(
ctx, s.lndServices, request.Amount, DefaultMaxHopHints, includeNodes,
)
if err != nil {
return nil, err
}
}
quote, err := s.Server.GetLoopInQuote(
ctx, request.Amount, s.lndServices.NodePubkey, request.LastHop,
request.RouteHints,