diff --git a/main.go b/main.go index 2fb310f..3dfcd9d 100644 --- a/main.go +++ b/main.go @@ -11,11 +11,11 @@ func main() { /* nostrTest := nostr.NostrRequest{ Name: "asara", - Key: "abcdefg", + Key: "npub180cvv07tjdrrgpa0j7j7tmnyl2yr6yr7l8j4s3evf6u64th6gkwsyjh6w6", Hostname: "devvul.com", } - nostr.AddNostrAddr(nostrTest) */ + nostr.AddNostrAddr(nostrTest) // matrix endpoints http.HandleFunc("/.well-known/matrix/server", matrix.MatrixServer) http.HandleFunc("/.well-known/matrix/client", matrix.MatrixClient) diff --git a/nostr/nostr.go b/nostr/nostr.go index d1af79a..adad339 100644 --- a/nostr/nostr.go +++ b/nostr/nostr.go @@ -34,7 +34,7 @@ func RequestNostrAddr(w http.ResponseWriter, r *http.Request) { relays := make(map[string][]string) npub := r.FormValue("Key") // convert npub to hex - hexKey, err := convertNpubtoHex(npub) + hexKey, err := convertNpubToHex(npub) if err != nil { w.WriteHeader(http.StatusBadRequest) return @@ -90,10 +90,14 @@ func AddNostrAddr(n NostrRequest) { // transform request to well known struct relays := make(map[string][]string) user := nostrWellKnown{} - names := map[string]string{n.Name: n.Key} + hexKey, err := convertNpubToHex(n.Key) + if err != nil { + fmt.Printf("Not an npub") + } + names := map[string]string{n.Name: hexKey} if n.Relays != nil { - relays = map[string][]string{n.Key: n.Relays} + relays = map[string][]string{hexKey: n.Relays} user = nostrWellKnown{Names: names, Relays: relays} } else { user = nostrWellKnown{Names: names} @@ -119,7 +123,7 @@ func getHostname(hostname string) string { return hostname } -func convertNpubtoHex(npub string) (string, error) { +func convertNpubToHex(npub string) (string, error) { if !strings.HasPrefix(npub, "npub1") { return "", errors.New("Not an npub key") }