diff --git a/cmd/lncli/cmd_payments.go b/cmd/lncli/cmd_payments.go index 3b0904ee0..42b902ff7 100644 --- a/cmd/lncli/cmd_payments.go +++ b/cmd/lncli/cmd_payments.go @@ -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" @@ -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", @@ -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", @@ -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) } } diff --git a/docs/release-notes/release-notes-0.18.0.md b/docs/release-notes/release-notes-0.18.0.md index 63b4347bd..2f0fb0288 100644 --- a/docs/release-notes/release-notes-0.18.0.md +++ b/docs/release-notes/release-notes-0.18.0.md @@ -171,6 +171,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). diff --git a/lnrpc/routerrpc/router.proto b/lnrpc/routerrpc/router.proto index d2b519635..02ca7244c 100644 --- a/lnrpc/routerrpc/router.proto +++ b/lnrpc/routerrpc/router.proto @@ -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); diff --git a/lnrpc/routerrpc/router.swagger.json b/lnrpc/routerrpc/router.swagger.json index c3be65a0f..f6c20c6c4 100644 --- a/lnrpc/routerrpc/router.swagger.json +++ b/lnrpc/routerrpc/router.swagger.json @@ -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": { diff --git a/lnrpc/routerrpc/router_grpc.pb.go b/lnrpc/routerrpc/router_grpc.pb.go index 2e61b5f85..788d729f7 100644 --- a/lnrpc/routerrpc/router_grpc.pb.go +++ b/lnrpc/routerrpc/router_grpc.pb.go @@ -81,6 +81,10 @@ type RouterClient interface { // 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. BuildRoute(ctx context.Context, in *BuildRouteRequest, opts ...grpc.CallOption) (*BuildRouteResponse, error) // SubscribeHtlcEvents creates a uni-directional stream from the server to // the client which delivers a stream of htlc events. @@ -510,6 +514,10 @@ type RouterServer interface { // 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. BuildRoute(context.Context, *BuildRouteRequest) (*BuildRouteResponse, error) // SubscribeHtlcEvents creates a uni-directional stream from the server to // the client which delivers a stream of htlc events. diff --git a/lnrpc/routerrpc/router_server.go b/lnrpc/routerrpc/router_server.go index fd3f5e6cf..84bfa68ef 100644 --- a/lnrpc/routerrpc/router_server.go +++ b/lnrpc/routerrpc/router_server.go @@ -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,