mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-07-18 15:32:18 +02:00
support nip-35.
This commit is contained in:
@ -7,6 +7,16 @@ import (
|
|||||||
"strings"
|
"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 {
|
func QueryIdentifier(fullname string) string {
|
||||||
spl := strings.Split(fullname, "@")
|
spl := strings.Split(fullname, "@")
|
||||||
if len(spl) != 2 {
|
if len(spl) != 2 {
|
||||||
@ -20,9 +30,7 @@ func QueryIdentifier(fullname string) string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
var result struct {
|
var result WellKnownResponse
|
||||||
Names map[string]string `json:"names"`
|
|
||||||
}
|
|
||||||
if err := json.NewDecoder(res.Body).Decode(&result); err != nil {
|
if err := json.NewDecoder(res.Body).Decode(&result); err != nil {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user