From 80b60d34aa7bf77bc1d6177e43ea98e10c400e41 Mon Sep 17 00:00:00 2001 From: David Gumberg Date: Mon, 19 Feb 2024 11:17:57 -0500 Subject: [PATCH 1/3] lncli: Expose `cltv_expiry` flag of `addinvoice` Allows users of the RPC CLI to set the `min_final_cltv_expiry_delta` described in BOLT's 11, 7, and 2 by setting the `cltv_expiry` flag when calling either of the `addinvoice` or `addholdinvoice` RPC's from `lncli`. --- cmd/lncli/cmd_invoice.go | 9 +++++++++ cmd/lncli/invoicesrpc_active.go | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/cmd/lncli/cmd_invoice.go b/cmd/lncli/cmd_invoice.go index 4c60294ca..7eef6f6d1 100644 --- a/cmd/lncli/cmd_invoice.go +++ b/cmd/lncli/cmd_invoice.go @@ -60,6 +60,14 @@ var addInvoiceCommand = cli.Command{ "specified, an expiry of " + "86400 seconds (24 hours) is implied.", }, + cli.Uint64Flag{ + Name: "cltv_expiry_delta", + Usage: "The minimum CLTV delta to use for the final " + + "hop. If this is set to 0, the default value " + + "is used. The default value for " + + "cltv_expiry_delta is configured by the " + + "'bitcoin.timelockdelta' option.", + }, cli.BoolFlag{ Name: "private", Usage: "encode routing hints in the invoice with " + @@ -127,6 +135,7 @@ func addInvoice(ctx *cli.Context) error { DescriptionHash: descHash, FallbackAddr: ctx.String("fallback_addr"), Expiry: ctx.Int64("expiry"), + CltvExpiry: ctx.Uint64("cltv_expiry_delta"), Private: ctx.Bool("private"), IsAmp: ctx.Bool("amp"), } diff --git a/cmd/lncli/invoicesrpc_active.go b/cmd/lncli/invoicesrpc_active.go index 2ce900695..823af67bf 100644 --- a/cmd/lncli/invoicesrpc_active.go +++ b/cmd/lncli/invoicesrpc_active.go @@ -184,6 +184,14 @@ var addHoldInvoiceCommand = cli.Command{ "specified, an expiry of " + "86400 seconds (24 hours) is implied.", }, + cli.Uint64Flag{ + Name: "cltv_expiry_delta", + Usage: "The minimum CLTV delta to use for the final " + + "hop. If this is set to 0, the default value " + + "is used. The default value for " + + "cltv_expiry_delta is configured by the " + + "'bitcoin.timelockdelta' option.", + }, cli.BoolFlag{ Name: "private", Usage: "encode routing hints in the invoice with " + @@ -241,6 +249,7 @@ func addHoldInvoice(ctx *cli.Context) error { DescriptionHash: descHash, FallbackAddr: ctx.String("fallback_addr"), Expiry: ctx.Int64("expiry"), + CltvExpiry: ctx.Uint64("cltv_expiry_delta"), Private: ctx.Bool("private"), } From 4646afb366f9cb0da6a5ee0a940291888d491bae Mon Sep 17 00:00:00 2001 From: David Gumberg Date: Mon, 19 Feb 2024 12:04:43 -0500 Subject: [PATCH 2/3] lnrpc: Fix bug in 'cltv below minimum' error msg Previously the error message produced when `CltvExpiry` is less than the minimum final cltv (18 at present) set by `routing.MinCLTVDelta` inserted the values into the wrong spots of the formatted string. --- lnrpc/invoicesrpc/addinvoice.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lnrpc/invoicesrpc/addinvoice.go b/lnrpc/invoicesrpc/addinvoice.go index 3e20ebf62..4b55f3f0d 100644 --- a/lnrpc/invoicesrpc/addinvoice.go +++ b/lnrpc/invoicesrpc/addinvoice.go @@ -367,7 +367,7 @@ func AddInvoice(ctx context.Context, cfg *AddInvoiceConfig, if invoice.CltvExpiry < routing.MinCLTVDelta { return nil, nil, fmt.Errorf("CLTV delta of %v must be "+ "greater than minimum of %v", - routing.MinCLTVDelta, invoice.CltvExpiry) + invoice.CltvExpiry, routing.MinCLTVDelta) } options = append(options, From 3c1b7ad59c6000999d59e765a5a24b297abb3ea9 Mon Sep 17 00:00:00 2001 From: David Gumberg Date: Sun, 2 Jun 2024 11:06:25 -0400 Subject: [PATCH 3/3] Release note for cltv_expiry flag to addinvoice --- docs/release-notes/release-notes-0.18.1.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/release-notes/release-notes-0.18.1.md b/docs/release-notes/release-notes-0.18.1.md index 742307b5b..68e6d63b8 100644 --- a/docs/release-notes/release-notes-0.18.1.md +++ b/docs/release-notes/release-notes-0.18.1.md @@ -24,6 +24,10 @@ ## RPC Additions ## lncli Additions +* [Added](https://github.com/lightningnetwork/lnd/pull/8491) the `cltv_expiry` + argument to `addinvoice` and `addholdinvoice`, allowing users to set the + `min_final_cltv_expiry_delta` + # Improvements ## Functional Updates ## RPC Updates