mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-07-28 13:52:55 +02: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/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)
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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).
|
||||
|
@@ -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);
|
||||
|
||||
|
@@ -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": {
|
||||
|
@@ -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.
|
||||
|
@@ -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,
|
||||
|
Reference in New Issue
Block a user