diff --git a/html/nostr_qr_response.html b/html/nostr_qr_response.html
new file mode 100644
index 0000000..f01ddee
--- /dev/null
+++ b/html/nostr_qr_response.html
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
Nostr NIP-05 {{ .RequestKey }}
+
+
+
+
diff --git a/nostr/nostr.go b/nostr/nostr.go
index db21b7c..773319e 100644
--- a/nostr/nostr.go
+++ b/nostr/nostr.go
@@ -6,6 +6,7 @@ import (
"encoding/json"
"errors"
"fmt"
+ "html/template"
"net/http"
"strings"
"time"
@@ -33,6 +34,11 @@ type NostrRequest struct {
Relays []string `json:"relays,omitempty"`
}
+type NostrResponse struct {
+ RequestKey string `json:"request_key"`
+ QRCode string `json:"QRCode"`
+}
+
func RequestNostrAddr(w http.ResponseWriter, r *http.Request) {
ctx := context.TODO()
l := logger.Get()
@@ -99,6 +105,7 @@ func RequestNostrAddr(w http.ResponseWriter, r *http.Request) {
// generate qr png
png, err := qrcode.Encode(paymentReq, qrcode.Medium, 256)
+ pngB64 := b64.StdEncoding.EncodeToString(png)
// write request to redis
err = redisCli.Set(ctx, rKey, enc, 15*time.Minute).Err()
@@ -107,9 +114,22 @@ func RequestNostrAddr(w http.ResponseWriter, r *http.Request) {
}
// return qr code
- w.Header().Set("Content-Type", "image/png")
+ response := NostrResponse{
+ RequestKey: rKey,
+ QRCode: pngB64,
+ }
+
+ tmplt, err := template.ParseFiles("html/nostr_qr_response.html")
+ if err != nil {
+ l.Error().Msg("unable to parse template")
+ }
+ w.Header().Set("Content-Type", "text/html")
w.WriteHeader(http.StatusOK)
- w.Write(png)
+ err = tmplt.Execute(w, response)
+ if err != nil {
+ l.Error().Msg("unable to connect to render template")
+ }
+ return
}
}