commit eb4e3b692b281d881c9063d33b3b4eda1e29d345
parent fe52381d6373b2075013596c4266d0705b408aa4
Author: Daniel D’Aquino <daniel@daquino.me>
Date: Mon, 5 May 2025 16:24:01 -0700
Do not process NWC responses not meant for the user
Soon after tightening error handling around NWC, it was noticed that
Damus was trying to process NWC responses meant for other people,
which caused a failure around the decryption process and a spam of
errors.
This commit modifies the relay filter to include only responses destined
to the user, and also guards the NWC response processing logic to ignore
responses meant for other users.
Changelog-Changed: Improved handling around NWC responses
Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
Diffstat:
2 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/damus/Models/HomeModel.swift b/damus/Models/HomeModel.swift
@@ -265,6 +265,11 @@ class HomeModel: ContactsDelegate {
return
}
+ guard nwc.relay == relay else { return } // Don't process NWC responses coming from relays other than our designated one
+ guard ev.referenced_pubkeys.first == nwc.keypair.pubkey else {
+ return // This message is not for us. Ignore it.
+ }
+
var resp: WalletConnect.FullWalletResponse? = nil
do {
resp = try await WalletConnect.FullWalletResponse(from: ev, nwc: nwc)
diff --git a/damus/Util/WalletConnect/WalletConnect+.swift b/damus/Util/WalletConnect/WalletConnect+.swift
@@ -20,6 +20,7 @@ extension WalletConnect {
static func subscribe(url: WalletConnectURL, pool: RelayPool) {
var filter = NostrFilter(kinds: [.nwc_response])
filter.authors = [url.pubkey]
+ filter.pubkeys = [url.keypair.pubkey]
filter.limit = 0
let sub = NostrSubscribe(filters: [filter], sub_id: "nwc")