nip46: support nip05 identifier in client.

This commit is contained in:
fiatjaf
2024-02-29 16:28:46 -03:00
parent e4f0509689
commit e0ba846a03
3 changed files with 73 additions and 35 deletions

View 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
}