From e8bc11e4f9c26e8568197860f7b0143660398731 Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Sat, 26 Nov 2022 19:31:49 -0300 Subject: [PATCH] support nip-35. --- nip05/nip05.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/nip05/nip05.go b/nip05/nip05.go index 252f08d..2c5ebb0 100644 --- a/nip05/nip05.go +++ b/nip05/nip05.go @@ -7,6 +7,16 @@ import ( "strings" ) +type ( + Name2KeyMap map[string]string + Key2RelaysMap map[string][]string +) + +type WellKnownResponse struct { + Names Name2KeyMap `json:"names"` // NIP-05 + Relays Key2RelaysMap `json:"relays"` // NIP-35 +} + func QueryIdentifier(fullname string) string { spl := strings.Split(fullname, "@") if len(spl) != 2 { @@ -20,9 +30,7 @@ func QueryIdentifier(fullname string) string { return "" } - var result struct { - Names map[string]string `json:"names"` - } + var result WellKnownResponse if err := json.NewDecoder(res.Body).Decode(&result); err != nil { return "" }