mirror of
https://github.com/bumi/lntip
synced 2025-06-16 17:55:35 +00:00
Merge pull request #50 from ziggie1984/add-private-route-hints
add private routing hints for invoices
This commit is contained in:
commit
530c7c0942
@ -47,7 +47,7 @@ type LNDclient struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AddInvoice generates an invoice with the given price and memo.
|
// 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{}
|
result := Invoice{}
|
||||||
|
|
||||||
stdOutLogger.Printf("Adding invoice: memo=%s value=%v", memo, value)
|
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,
|
Memo: memo,
|
||||||
DescriptionHash: descriptionHash,
|
DescriptionHash: descriptionHash,
|
||||||
Value: value,
|
Value: value,
|
||||||
|
Private: private,
|
||||||
}
|
}
|
||||||
res, err := c.lndClient.AddInvoice(c.ctx, &invoice)
|
res, err := c.lndClient.AddInvoice(c.ctx, &invoice)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
5
lnme.go
5
lnme.go
@ -117,7 +117,7 @@ func main() {
|
|||||||
return c.JSON(http.StatusBadRequest, "Bad request")
|
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 {
|
if err != nil {
|
||||||
stdOutLogger.Printf("Error creating invoice: %s", err)
|
stdOutLogger.Printf("Error creating invoice: %s", err)
|
||||||
return c.JSON(http.StatusInternalServerError, "Error adding invoice")
|
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"})
|
return c.JSON(http.StatusOK, lnurl.LNURLErrorResponse{Status: "ERROR", Reason: "Invalid comment length"})
|
||||||
}
|
}
|
||||||
metadataHash := sha256.Sum256([]byte(lnurlMetadata))
|
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 {
|
if err != nil {
|
||||||
stdOutLogger.Printf("Error creating invoice: %s", err)
|
stdOutLogger.Printf("Error creating invoice: %s", err)
|
||||||
return c.JSON(http.StatusOK, lnurl.LNURLErrorResponse{Status: "ERROR", Reason: "Server Error"})
|
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-website", false, "Disable default embedded website.")
|
||||||
f.Bool("disable-ln-address", false, "Disable Lightning Address handling")
|
f.Bool("disable-ln-address", false, "Disable Lightning Address handling")
|
||||||
f.Bool("disable-cors", false, "Disable CORS headers.")
|
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.Float64("request-limit", 5, "Request limit per second.")
|
||||||
f.String("static-path", "", "Path to a static assets directory.")
|
f.String("static-path", "", "Path to a static assets directory.")
|
||||||
f.String("port", "", "Port to bind on (deprecated - use listen).")
|
f.String("port", "", "Port to bind on (deprecated - use listen).")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user