From 5504368844913d4b58ddeb04aba9124a65995b23 Mon Sep 17 00:00:00 2001 From: Harsha Goli Date: Mon, 23 Aug 2021 18:37:45 -0700 Subject: [PATCH] loopin: Add --route_hints parameter Adds the --route_hints parameter to loop quote --- cmd/loop/loopin.go | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/cmd/loop/loopin.go b/cmd/loop/loopin.go index cbeec12..dbbdc14 100644 --- a/cmd/loop/loopin.go +++ b/cmd/loop/loopin.go @@ -2,6 +2,7 @@ package main import ( "context" + "encoding/json" "fmt" "github.com/lightninglabs/loop" @@ -31,6 +32,11 @@ var ( "with our reserved prefix: %v.", labels.MaxLength, labels.Reserved), } + routeHintsFlag = cli.StringSliceFlag{ + Name: "route_hints", + Usage: "Route hints that can each be individually used " + + "to assist in reaching the invoice's destination.", + } loopInCommand = cli.Command{ Name: "in", @@ -61,6 +67,7 @@ var ( lastHopFlag, labelFlag, verboseFlag, + routeHintsFlag, }, Action: loopIn, } @@ -120,12 +127,20 @@ func loopIn(ctx *cli.Context) error { lastHop = lastHopVertex[:] } + var hints []*looprpc.RouteHint + if ctx.IsSet(routeHints.Name) { + err = json.Unmarshal([]byte(ctx.String(routeHints.Name)), &hints) + if err != nil { + return fmt.Errorf("unable to parse json: %v", err) + } + } quoteReq := &looprpc.QuoteRequest{ - Amt: int64(amt), - ConfTarget: htlcConfTarget, - ExternalHtlc: external, - LoopInLastHop: lastHop, + Amt: int64(amt), + ConfTarget: htlcConfTarget, + ExternalHtlc: external, + LoopInLastHop: lastHop, + LoopInRouteHints: hints, } quote, err := client.GetLoopInQuote(context.Background(), quoteReq)