radrootsd

JSON-RPC bridge for Radroots event publishing
git clone https://radroots.dev/git/radrootsd.git
Log | Files | Refs | README | LICENSE

commit 219c6b2c95b9cbf72d90bd5a760a0df1095d9e9f
parent eb59dfdd3ee94792c9638ae17a61c83b99805d27
Author: triesap <triesap@radroots.dev>
Date:   Tue,  6 Jan 2026 17:08:53 +0000

nostr: handle signevent nip-46 requests

- add signevent request handling in listener
- reject unsigned events with pubkey mismatch
- sign events using radrootsd keys and return signevent result
- return formatted error on signing failure

Diffstat:
Msrc/transport/nostr/listener.rs | 16+++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/src/transport/nostr/listener.rs b/src/transport/nostr/listener.rs @@ -2,7 +2,12 @@ use std::time::Duration; use anyhow::{anyhow, Result}; use nostr::nips::nip44; -use nostr::nips::nip46::{NostrConnectMessage, NostrConnectRequest, NostrConnectResponse, ResponseResult}; +use nostr::nips::nip46::{ + NostrConnectMessage, + NostrConnectRequest, + NostrConnectResponse, + ResponseResult, +}; use nostr::JsonUtil; use tokio::sync::broadcast; use tracing::{info, warn}; @@ -116,6 +121,15 @@ fn handle_request(radrootsd: &Radrootsd, request: NostrConnectRequest) -> NostrC NostrConnectRequest::GetPublicKey => { NostrConnectResponse::with_result(ResponseResult::GetPublicKey(radrootsd.pubkey)) } + NostrConnectRequest::SignEvent(unsigned) => { + if unsigned.pubkey != radrootsd.pubkey { + return NostrConnectResponse::with_error("pubkey mismatch"); + } + match unsigned.sign_with_keys(&radrootsd.keys) { + Ok(event) => NostrConnectResponse::with_result(ResponseResult::SignEvent(Box::new(event))), + Err(err) => NostrConnectResponse::with_error(format!("sign_event failed: {err}")), + } + } NostrConnectRequest::Ping => NostrConnectResponse::with_result(ResponseResult::Pong), _ => NostrConnectResponse::with_error("unsupported request"), }