mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-11-10 22:27:22 +01:00
Merge pull request #8387 from ziggie1984/buildroute-use-lnd-default
buildroute use lnd default
This commit is contained in:
@@ -17,7 +17,6 @@ import (
|
|||||||
"github.com/btcsuite/btcd/btcutil"
|
"github.com/btcsuite/btcd/btcutil"
|
||||||
"github.com/jedib0t/go-pretty/v6/table"
|
"github.com/jedib0t/go-pretty/v6/table"
|
||||||
"github.com/jedib0t/go-pretty/v6/text"
|
"github.com/jedib0t/go-pretty/v6/text"
|
||||||
"github.com/lightningnetwork/lnd/chainreg"
|
|
||||||
"github.com/lightningnetwork/lnd/lnrpc"
|
"github.com/lightningnetwork/lnd/lnrpc"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
|
||||||
"github.com/lightningnetwork/lnd/lntypes"
|
"github.com/lightningnetwork/lnd/lntypes"
|
||||||
@@ -1556,7 +1555,18 @@ var buildRouteCommand = cli.Command{
|
|||||||
Name: "buildroute",
|
Name: "buildroute",
|
||||||
Category: "Payments",
|
Category: "Payments",
|
||||||
Usage: "Build a route from a list of hop pubkeys.",
|
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{
|
Flags: []cli.Flag{
|
||||||
cli.Int64Flag{
|
cli.Int64Flag{
|
||||||
Name: "amt",
|
Name: "amt",
|
||||||
@@ -1566,8 +1576,8 @@ var buildRouteCommand = cli.Command{
|
|||||||
cli.Int64Flag{
|
cli.Int64Flag{
|
||||||
Name: "final_cltv_delta",
|
Name: "final_cltv_delta",
|
||||||
Usage: "number of blocks the last hop has to reveal " +
|
Usage: "number of blocks the last hop has to reveal " +
|
||||||
"the preimage",
|
"the preimage; if not set the default lnd " +
|
||||||
Value: chainreg.DefaultBitcoinTimeLockDelta,
|
"final_cltv_delta is used",
|
||||||
},
|
},
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "hops",
|
Name: "hops",
|
||||||
@@ -1622,10 +1632,11 @@ func buildRoute(ctx *cli.Context) error {
|
|||||||
payAddr []byte
|
payAddr []byte
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
|
|
||||||
if ctx.IsSet("payment_addr") {
|
if ctx.IsSet("payment_addr") {
|
||||||
payAddr, err = hex.DecodeString(ctx.String("payment_addr"))
|
payAddr, err = hex.DecodeString(ctx.String("payment_addr"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("error parsing payment_addr: %v", err)
|
return fmt.Errorf("error parsing payment_addr: %w", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -171,6 +171,9 @@
|
|||||||
the ability to specify multiple outgoing channel ids for the `sendpayment`
|
the ability to specify multiple outgoing channel ids for the `sendpayment`
|
||||||
command.
|
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
|
## Code Health
|
||||||
|
|
||||||
* [Remove Litecoin code](https://github.com/lightningnetwork/lnd/pull/7867).
|
* [Remove Litecoin code](https://github.com/lightningnetwork/lnd/pull/7867).
|
||||||
|
|||||||
@@ -124,6 +124,10 @@ service Router {
|
|||||||
BuildRoute builds a fully specified route based on a list of hop public
|
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
|
keys. It retrieves the relevant channel policies from the graph in order to
|
||||||
calculate the correct fees and time locks.
|
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);
|
rpc BuildRoute (BuildRouteRequest) returns (BuildRouteResponse);
|
||||||
|
|
||||||
|
|||||||
@@ -293,7 +293,7 @@
|
|||||||
},
|
},
|
||||||
"/v2/router/route": {
|
"/v2/router/route": {
|
||||||
"post": {
|
"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",
|
"operationId": "Router_BuildRoute",
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
|
|||||||
@@ -81,6 +81,10 @@ type RouterClient interface {
|
|||||||
// BuildRoute builds a fully specified route based on a list of hop public
|
// 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
|
// keys. It retrieves the relevant channel policies from the graph in order to
|
||||||
// calculate the correct fees and time locks.
|
// 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)
|
BuildRoute(ctx context.Context, in *BuildRouteRequest, opts ...grpc.CallOption) (*BuildRouteResponse, error)
|
||||||
// SubscribeHtlcEvents creates a uni-directional stream from the server to
|
// SubscribeHtlcEvents creates a uni-directional stream from the server to
|
||||||
// the client which delivers a stream of htlc events.
|
// 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
|
// 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
|
// keys. It retrieves the relevant channel policies from the graph in order to
|
||||||
// calculate the correct fees and time locks.
|
// 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)
|
BuildRoute(context.Context, *BuildRouteRequest) (*BuildRouteResponse, error)
|
||||||
// SubscribeHtlcEvents creates a uni-directional stream from the server to
|
// SubscribeHtlcEvents creates a uni-directional stream from the server to
|
||||||
// the client which delivers a stream of htlc events.
|
// the client which delivers a stream of htlc events.
|
||||||
|
|||||||
@@ -999,6 +999,12 @@ func (s *Server) BuildRoute(ctx context.Context,
|
|||||||
payAddr = &backingPayAddr
|
payAddr = &backingPayAddr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if req.FinalCltvDelta == 0 {
|
||||||
|
req.FinalCltvDelta = int32(
|
||||||
|
s.cfg.RouterBackend.DefaultFinalCltvDelta,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
// Build the route and return it to the caller.
|
// Build the route and return it to the caller.
|
||||||
route, err := s.cfg.Router.BuildRoute(
|
route, err := s.cfg.Router.BuildRoute(
|
||||||
amt, hops, outgoingChan, req.FinalCltvDelta, payAddr,
|
amt, hops, outgoingChan, req.FinalCltvDelta, payAddr,
|
||||||
|
|||||||
Reference in New Issue
Block a user