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 10 additions and 6 deletions
Showing only changes of commit 03da6cf23d - Show all commits

View file

@ -11,11 +11,11 @@ func main() {
/* /*
nostrTest := nostr.NostrRequest{ nostrTest := nostr.NostrRequest{
Name: "asara", Name: "asara",
Key: "abcdefg", Key: "npub180cvv07tjdrrgpa0j7j7tmnyl2yr6yr7l8j4s3evf6u64th6gkwsyjh6w6",
Hostname: "devvul.com", Hostname: "devvul.com",
} }
nostr.AddNostrAddr(nostrTest)
*/ */
nostr.AddNostrAddr(nostrTest)
// matrix endpoints // matrix endpoints
http.HandleFunc("/.well-known/matrix/server", matrix.MatrixServer) http.HandleFunc("/.well-known/matrix/server", matrix.MatrixServer)
http.HandleFunc("/.well-known/matrix/client", matrix.MatrixClient) http.HandleFunc("/.well-known/matrix/client", matrix.MatrixClient)

View file

@ -34,7 +34,7 @@ func RequestNostrAddr(w http.ResponseWriter, r *http.Request) {
relays := make(map[string][]string) relays := make(map[string][]string)
npub := r.FormValue("Key") npub := r.FormValue("Key")
// convert npub to hex // convert npub to hex
hexKey, err := convertNpubtoHex(npub) hexKey, err := convertNpubToHex(npub)
if err != nil { if err != nil {
w.WriteHeader(http.StatusBadRequest) w.WriteHeader(http.StatusBadRequest)
return return
@ -90,10 +90,14 @@ func AddNostrAddr(n NostrRequest) {
// transform request to well known struct // transform request to well known struct
relays := make(map[string][]string) relays := make(map[string][]string)
user := nostrWellKnown{} 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 { 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} user = nostrWellKnown{Names: names, Relays: relays}
} else { } else {
user = nostrWellKnown{Names: names} user = nostrWellKnown{Names: names}
@ -119,7 +123,7 @@ func getHostname(hostname string) string {
return hostname return hostname
} }
func convertNpubtoHex(npub string) (string, error) { func convertNpubToHex(npub string) (string, error) {
if !strings.HasPrefix(npub, "npub1") { if !strings.HasPrefix(npub, "npub1") {
return "", errors.New("Not an npub key") return "", errors.New("Not an npub key")
} }