From 23a134b28ecc95017dbb9ade763bfcfe4b9f0f4f Mon Sep 17 00:00:00 2001 From: ziggie Date: Mon, 23 Jan 2023 10:08:26 +0100 Subject: [PATCH] add private routing hints for invoices --- ln/lnd.go | 3 ++- lnme.go | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ln/lnd.go b/ln/lnd.go index 8b9549a..999dad9 100644 --- a/ln/lnd.go +++ b/ln/lnd.go @@ -47,7 +47,7 @@ type LNDclient struct { } // AddInvoice generates an invoice with the given price and memo. -func (c LNDclient) AddInvoice(value int64, memo string, descriptionHash []byte) (Invoice, error) { +func (c LNDclient) AddInvoice(value int64, memo string, descriptionHash []byte, private bool) (Invoice, error) { result := Invoice{} stdOutLogger.Printf("Adding invoice: memo=%s value=%v", memo, value) @@ -55,6 +55,7 @@ func (c LNDclient) AddInvoice(value int64, memo string, descriptionHash []byte) Memo: memo, DescriptionHash: descriptionHash, Value: value, + Private: private, } res, err := c.lndClient.AddInvoice(c.ctx, &invoice) if err != nil { diff --git a/lnme.go b/lnme.go index 5c81fda..b2b2abf 100644 --- a/lnme.go +++ b/lnme.go @@ -117,7 +117,7 @@ func main() { return c.JSON(http.StatusBadRequest, "Bad request") } - invoice, err := lnClient.AddInvoice(i.Value, i.Memo, nil) + invoice, err := lnClient.AddInvoice(i.Value, i.Memo, nil, cfg.Bool("enable-private-channels")) if err != nil { stdOutLogger.Printf("Error creating invoice: %s", err) return c.JSON(http.StatusInternalServerError, "Error adding invoice") @@ -190,7 +190,7 @@ func main() { return c.JSON(http.StatusOK, lnurl.LNURLErrorResponse{Status: "ERROR", Reason: "Invalid comment length"}) } metadataHash := sha256.Sum256([]byte(lnurlMetadata)) - invoice, err := lnClient.AddInvoice(sats, comment, metadataHash[:]) + invoice, err := lnClient.AddInvoice(sats, comment, metadataHash[:], cfg.Bool("enable-private-channels")) if err != nil { stdOutLogger.Printf("Error creating invoice: %s", err) return c.JSON(http.StatusOK, lnurl.LNURLErrorResponse{Status: "ERROR", Reason: "Server Error"}) @@ -248,6 +248,7 @@ func LoadConfig() *koanf.Koanf { f.Bool("disable-website", false, "Disable default embedded website.") f.Bool("disable-ln-address", false, "Disable Lightning Address handling") f.Bool("disable-cors", false, "Disable CORS headers.") + f.Bool("enable-private-channels", false, "Adds private routing hints to invoices") f.Float64("request-limit", 5, "Request limit per second.") f.String("static-path", "", "Path to a static assets directory.") f.String("port", "", "Port to bind on (deprecated - use listen).")