From 91097077f430b1e8cf8b888311de0ec68df743cf Mon Sep 17 00:00:00 2001 From: John Cantrell Date: Tue, 23 Apr 2024 09:40:57 -0400 Subject: [PATCH] return error for events sent to inactive profiles --- mutiny-core/src/nostr/nwc.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/mutiny-core/src/nostr/nwc.rs b/mutiny-core/src/nostr/nwc.rs index b87b44118..f57761958 100644 --- a/mutiny-core/src/nostr/nwc.rs +++ b/mutiny-core/src/nostr/nwc.rs @@ -421,10 +421,7 @@ impl NostrWalletConnect { let mut needs_save = false; let mut needs_delete = false; let mut result = None; - if self.profile.active() - && event.kind == Kind::WalletConnectRequest - && event.pubkey == client_pubkey - { + if event.kind == Kind::WalletConnectRequest && event.pubkey == client_pubkey { let server_key = self.server_key.secret_key()?; let decrypted = decrypt(server_key, &client_pubkey, &event.content)?; @@ -446,6 +443,18 @@ impl NostrWalletConnect { } }; + // only respond to commands sent to active profiles + if !self.profile.active() { + return self + .get_skipped_error_event( + &event, + req.method, + ErrorCode::Other, + "Nostr profile inactive".to_string(), + ) + .map(Some); + } + // only respond to commands that are allowed by the profile if !self.profile.available_commands().contains(&req.method) { return self