Add LNURL metadata

This commit is contained in:
ekzyis 2024-12-27 01:15:36 +01:00
parent 79d473b0f5
commit 0a10fcc109
1 changed files with 9 additions and 1 deletions

View File

@ -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()})
}