From 0a10fcc109940e0e15f4755248da30ce2742de08 Mon Sep 17 00:00:00 2001 From: ekzyis Date: Fri, 27 Dec 2024 01:15:36 +0100 Subject: [PATCH] Add LNURL metadata --- lnurl/lnurl.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lnurl/lnurl.go b/lnurl/lnurl.go index bbdfc4a..800d177 100644 --- a/lnurl/lnurl.go +++ b/lnurl/lnurl.go @@ -38,7 +38,7 @@ func payRequest(c echo.Context) error { "callback": callback, "minSendable": MIN_SENDABLE_AMOUNT, "maxSendable": MAX_SENDABLE_AMOUNT, - "metadata": fmt.Sprintf("[[\"text/plain\",\"paying %s\"]]", name), + "metadata": lnurlMetadata(c), "tag": "payRequest", "commentAllowed": MAX_COMMENT_LENGTH, }, @@ -78,6 +78,14 @@ func pay(ln lightning.Lightning) echo.HandlerFunc { } } +func lnurlMetadata(c echo.Context) string { + s := "[" + s += fmt.Sprintf("[\"text/plain\",\"Paying %s@%s\"]", c.Param("name"), c.Request().Host) + s += fmt.Sprintf(",[\"text/identifier\",\"%s@%s\"]", c.Param("name"), c.Request().Host) + s += "]" + return s +} + func lnurlError(c echo.Context, code int, err error) error { return c.JSON(code, map[string]any{"status": "ERROR", "error": err.Error()}) }