Add nostr nip-05 registration with lnd invoices #1

Merged
Asara merged 33 commits from nostr_lnd into main 2023-05-30 00:10:37 +00:00
2 changed files with 9 additions and 1 deletions
Showing only changes of commit 9ecec99310 - Show all commits

4
.gitignore vendored
View file

@ -21,3 +21,7 @@
# Go workspace file
go.work
# binary outputs
well-goknown
cmd/lnd-verifier/lnd-verifier

View file

@ -125,7 +125,7 @@ func RequestNostrAddr(w http.ResponseWriter, r *http.Request) {
tmplt, err := template.ParseFiles("html/nostr_qr_response.html")
if err != nil {
l.Error().Msg("unable to parse template")
l.Error().Msg("unable to parse qr response template")
w.WriteHeader(http.StatusServiceUnavailable)
json.NewEncoder(w).Encode(&jsonErrorMessage{
Error: "service unavailable",
@ -147,6 +147,7 @@ func RequestNostrAddr(w http.ResponseWriter, r *http.Request) {
func GetNostrAddr(w http.ResponseWriter, r *http.Request) {
ctx := context.TODO()
l := logger.Get()
// get query string for username
r.ParseForm()
requestedName := r.FormValue("name")
@ -158,6 +159,7 @@ func GetNostrAddr(w http.ResponseWriter, r *http.Request) {
search := getRkey("verified", requestedName, getHostname(r.Host))
addr, err := redisCli.Get(ctx, search).Result()
if err != nil {
l.Info().Msg(fmt.Sprintf("get %s: not found", search))
w.WriteHeader(http.StatusNotFound)
json.NewEncoder(w).Encode(&jsonErrorMessage{
Error: "username not registered",
@ -166,6 +168,7 @@ func GetNostrAddr(w http.ResponseWriter, r *http.Request) {
}
dec, err := b64.StdEncoding.DecodeString(addr)
if err != nil {
l.Error().Msg(fmt.Sprintf("get %s: unable to decode key", search))
w.WriteHeader(http.StatusInternalServerError)
json.NewEncoder(w).Encode(&jsonErrorMessage{
Error: "internal server error",
@ -173,6 +176,7 @@ func GetNostrAddr(w http.ResponseWriter, r *http.Request) {
return
}
l.Info().Msg(fmt.Sprintf("get %s: found and returned", search))
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
w.Write(dec)