loopin: Add --route_hints parameter

Adds the --route_hints parameter to loop quote
routehints
Harsha Goli 3 years ago
parent 2e6adeaa3f
commit 5504368844
No known key found for this signature in database
GPG Key ID: 90E00CCB1C74C611

@ -2,6 +2,7 @@ package main
import ( import (
"context" "context"
"encoding/json"
"fmt" "fmt"
"github.com/lightninglabs/loop" "github.com/lightninglabs/loop"
@ -31,6 +32,11 @@ var (
"with our reserved prefix: %v.", "with our reserved prefix: %v.",
labels.MaxLength, labels.Reserved), 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{ loopInCommand = cli.Command{
Name: "in", Name: "in",
@ -61,6 +67,7 @@ var (
lastHopFlag, lastHopFlag,
labelFlag, labelFlag,
verboseFlag, verboseFlag,
routeHintsFlag,
}, },
Action: loopIn, Action: loopIn,
} }
@ -120,12 +127,20 @@ func loopIn(ctx *cli.Context) error {
lastHop = lastHopVertex[:] 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{ quoteReq := &looprpc.QuoteRequest{
Amt: int64(amt), Amt: int64(amt),
ConfTarget: htlcConfTarget, ConfTarget: htlcConfTarget,
ExternalHtlc: external, ExternalHtlc: external,
LoopInLastHop: lastHop, LoopInLastHop: lastHop,
LoopInRouteHints: hints,
} }
quote, err := client.GetLoopInQuote(context.Background(), quoteReq) quote, err := client.GetLoopInQuote(context.Background(), quoteReq)

Loading…
Cancel
Save