Implement NIP-86 signevent
Adds the signevent capability from nostr-protocol/nips#2389: a relay admin can ask the relay to sign an unsigned event template with the relay's own (self) key and get back the full signed event. Useful for minting NIP-43 relay-level role events on behalf of the relay. - ManagementStore.SignEvent signs the template via Config.Sign (relay self key). - Wired to instance.Relay.ManagementAPI.SignEvent; admin-gated by the existing OnAPICall middleware, and auto-advertised via supportedmethods. - Bumps the nostrlib replace to the signevent branch which adds the nip86 decode case + khatru dispatch hook. NOTE: go.sum still needs `go mod tidy` to record the new nostrlib pseudo-version hash (no Go toolchain was available in this environment to run it). Not built or tested here. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BsMjvv7krpZeHK1Njeneru
This commit is contained in:
@@ -132,4 +132,4 @@ require (
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
|
||||
replace fiatjaf.com/nostr => gitea.coracle.social/Coracle/nostrlib v0.0.0-20260505183642-fefc85d50080
|
||||
replace fiatjaf.com/nostr => gitea.coracle.social/Coracle/nostrlib v0.0.0-20260620150617-d1bc98d0f85b
|
||||
|
||||
@@ -324,6 +324,19 @@ func (m *ManagementStore) ValidateJoinRequest(event nostr.Event) (reject bool, e
|
||||
return true, "invalid: failed to validate invite code"
|
||||
}
|
||||
|
||||
// Signing
|
||||
|
||||
// SignEvent signs an unsigned event template with the relay's own (self) key and
|
||||
// returns the full signed event. Used by relay admins to mint events on behalf of
|
||||
// the relay — e.g. NIP-43 relay-level role events (NIP-86 signevent).
|
||||
func (m *ManagementStore) SignEvent(event nostr.Event) (nostr.Event, error) {
|
||||
if err := m.Config.Sign(&event); err != nil {
|
||||
return event, err
|
||||
}
|
||||
|
||||
return event, nil
|
||||
}
|
||||
|
||||
// Middleware
|
||||
|
||||
func (m *ManagementStore) Enable(instance *Instance) {
|
||||
@@ -386,4 +399,8 @@ func (m *ManagementStore) Enable(instance *Instance) {
|
||||
instance.Relay.ManagementAPI.ListBannedEvents = func(ctx context.Context) ([]nip86.IDReason, error) {
|
||||
return m.GetBannedEventItems(), nil
|
||||
}
|
||||
|
||||
instance.Relay.ManagementAPI.SignEvent = func(ctx context.Context, event nostr.Event) (nostr.Event, error) {
|
||||
return m.SignEvent(event)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user