nip46: implement switch_relays on the signer side.

This commit is contained in:
fiatjaf
2026-01-20 20:34:12 -03:00
parent db61f42b56
commit 10318a3443
2 changed files with 12 additions and 0 deletions

View File

@@ -20,6 +20,9 @@ type StaticKeySigner struct {
sync.Mutex
AuthorizeRequest func(harmless bool, from nostr.PubKey, secret string) bool
// used for switch_relays call
DefaultRelays []string
}
func NewStaticKeySigner(secretKey [32]byte) StaticKeySigner {
@@ -204,6 +207,9 @@ func (p *StaticKeySigner) HandleRequest(_ context.Context, event nostr.Event) (
case "ping":
result = "pong"
harmless = true
case "switch_relays":
j, _ := json.Marshal(p.DefaultRelays)
result = string(j)
default:
return req, resp, eventResponse,
fmt.Errorf("unknown method '%s'", req.Method)