Skip to content

Commit

Permalink
return error for events sent to inactive profiles
Browse files Browse the repository at this point in the history
  • Loading branch information
johncantrell97 committed Apr 23, 2024
1 parent 73710b1 commit 9109707
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions mutiny-core/src/nostr/nwc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
Expand All @@ -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
Expand Down

0 comments on commit 9109707

Please sign in to comment.