mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-08-03 16:32:10 +02:00
nip46: support nip05 identifier in client.
This commit is contained in:
26
nip46/wellknownnostrjson.go
Normal file
26
nip46/wellknownnostrjson.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package nip46
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/nbd-wtf/go-nostr/nip05"
|
||||
)
|
||||
|
||||
func queryWellKnownNostrJson(ctx context.Context, fullname string) (pubkey string, relays []string, err error) {
|
||||
result, name, err := nip05.Fetch(ctx, fullname)
|
||||
if err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
|
||||
pubkey, ok := result.Names[name]
|
||||
if !ok {
|
||||
return "", nil, fmt.Errorf("no entry found for the '%s' name", name)
|
||||
}
|
||||
relays, _ = result.NIP46[pubkey]
|
||||
if !ok {
|
||||
return "", nil, fmt.Errorf("no bunker relays found for the '%s' name", name)
|
||||
}
|
||||
|
||||
return pubkey, relays, nil
|
||||
}
|
Reference in New Issue
Block a user