mirror of
https://github.com/bumi/lntip
synced 2025-06-16 17:55:35 +00:00
Provide LNURL metadata hash as description_hash in the lightning pr
This commit is contained in:
parent
492ffb2d3f
commit
4fb8fa9a73
@ -43,13 +43,14 @@ 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) (Invoice, error) {
|
func (c LNDclient) AddInvoice(value int64, memo string, descriptionHash []byte) (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)
|
||||||
invoice := lnrpc.Invoice{
|
invoice := lnrpc.Invoice{
|
||||||
Memo: memo,
|
Memo: memo,
|
||||||
Value: value,
|
DescriptionHash: descriptionHash,
|
||||||
|
Value: value,
|
||||||
}
|
}
|
||||||
res, err := c.lndClient.AddInvoice(c.ctx, &invoice)
|
res, err := c.lndClient.AddInvoice(c.ctx, &invoice)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
6
lnme.go
6
lnme.go
@ -2,7 +2,6 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"encoding/hex"
|
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
@ -110,7 +109,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)
|
invoice, err := lnClient.AddInvoice(i.Value, i.Memo, nil)
|
||||||
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")
|
||||||
@ -167,8 +166,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
sats := msats / 1000 // we need sats
|
sats := msats / 1000 // we need sats
|
||||||
metadataHash := sha256.Sum256([]byte(lnurlMetadata))
|
metadataHash := sha256.Sum256([]byte(lnurlMetadata))
|
||||||
memo := hex.EncodeToString(metadataHash[:])
|
invoice, err := lnClient.AddInvoice(sats, lightningAddress, metadataHash[:])
|
||||||
invoice, err := lnClient.AddInvoice(sats, memo)
|
|
||||||
lnurlPayResponse2 := lnurl.LNURLPayResponse2{
|
lnurlPayResponse2 := lnurl.LNURLPayResponse2{
|
||||||
LNURLResponse: lnurl.LNURLResponse{Status: "OK"},
|
LNURLResponse: lnurl.LNURLResponse{Status: "OK"},
|
||||||
PR: invoice.PaymentRequest,
|
PR: invoice.PaymentRequest,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user