Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

buildroute use lnd default #8387

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions cmd/lncli/cmd_payments.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"github.com/btcsuite/btcd/btcutil"
"github.com/jedib0t/go-pretty/v6/table"
"github.com/jedib0t/go-pretty/v6/text"
"github.com/lightningnetwork/lnd/chainreg"
"github.com/lightningnetwork/lnd/lnrpc"
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
"github.com/lightningnetwork/lnd/lntypes"
Expand Down Expand Up @@ -1556,7 +1555,18 @@ var buildRouteCommand = cli.Command{
Name: "buildroute",
Category: "Payments",
Usage: "Build a route from a list of hop pubkeys.",
Action: actionDecorator(buildRoute),
Description: `
Builds a sphinx route for the supplied hops (public keys). Make sure to
use a custom final_cltv_delta to create the route depending on the
restrictions in the invoice otherwise LND will use its default specified
via the bitcoin.timelockdelta setting (default 80).
If the final_cltv_delta mismatch you will likely see the error
INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS returned by the receiving node.

Moreover a payment_addr has to be provided if the invoice supplied it as
well otherwise the payment will be rejected by the receiving node.
`,
Action: actionDecorator(buildRoute),
Flags: []cli.Flag{
cli.Int64Flag{
Name: "amt",
Expand All @@ -1566,8 +1576,8 @@ var buildRouteCommand = cli.Command{
cli.Int64Flag{
Name: "final_cltv_delta",
Usage: "number of blocks the last hop has to reveal " +
"the preimage",
Value: chainreg.DefaultBitcoinTimeLockDelta,
"the preimage; if not set the default lnd " +
"final_cltv_delta is used",
},
cli.StringFlag{
Name: "hops",
Expand Down Expand Up @@ -1622,10 +1632,11 @@ func buildRoute(ctx *cli.Context) error {
payAddr []byte
err error
)

if ctx.IsSet("payment_addr") {
payAddr, err = hex.DecodeString(ctx.String("payment_addr"))
if err != nil {
return fmt.Errorf("error parsing payment_addr: %v", err)
return fmt.Errorf("error parsing payment_addr: %w", err)
}
}

Expand Down
3 changes: 3 additions & 0 deletions docs/release-notes/release-notes-0.18.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@
the ability to specify multiple outgoing channel ids for the `sendpayment`
command.

* [Use the default LND value in the buildroute rpc command for the
final cltv delta](https://github.com/lightningnetwork/lnd/pull/8387).

## Code Health

* [Remove Litecoin code](https://github.com/lightningnetwork/lnd/pull/7867).
Expand Down
4 changes: 4 additions & 0 deletions lnrpc/routerrpc/router.proto
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ service Router {
BuildRoute builds a fully specified route based on a list of hop public
keys. It retrieves the relevant channel policies from the graph in order to
calculate the correct fees and time locks.
Note that LND will use its default final_cltv_delta if no value is supplied.
Make sure to add the correct final_cltv_delta depending on the invoice
restriction. Moreover the caller has to make sure to provide the
payment_addr if the route is paying an invoice which signaled it.
*/
rpc BuildRoute (BuildRouteRequest) returns (BuildRouteResponse);

Expand Down
2 changes: 1 addition & 1 deletion lnrpc/routerrpc/router.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@
},
"/v2/router/route": {
"post": {
"summary": "lncli: `buildroute`\nBuildRoute builds a fully specified route based on a list of hop public\nkeys. It retrieves the relevant channel policies from the graph in order to\ncalculate the correct fees and time locks.",
"summary": "lncli: `buildroute`\nBuildRoute builds a fully specified route based on a list of hop public\nkeys. It retrieves the relevant channel policies from the graph in order to\ncalculate the correct fees and time locks.\nNote that LND will use its default final_cltv_delta if no value is supplied.\nMake sure to add the correct final_cltv_delta depending on the invoice\nrestriction. Moreover the caller has to make sure to provide the\npayment_addr if the route is paying an invoice which signaled it.",
"operationId": "Router_BuildRoute",
"responses": {
"200": {
Expand Down
8 changes: 8 additions & 0 deletions lnrpc/routerrpc/router_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions lnrpc/routerrpc/router_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -999,6 +999,12 @@ func (s *Server) BuildRoute(ctx context.Context,
payAddr = &backingPayAddr
}

if req.FinalCltvDelta == 0 {
req.FinalCltvDelta = int32(
s.cfg.RouterBackend.DefaultFinalCltvDelta,
)
}

// Build the route and return it to the caller.
route, err := s.cfg.Router.BuildRoute(
amt, hops, outgoingChan, req.FinalCltvDelta, payAddr,
Expand Down
Loading