-
Notifications
You must be signed in to change notification settings - Fork 13
fix(pow): filter wait_for_dm notifications so PoW detection actually fires #174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: MostroP2P/mostro-cli
Length of output: 168
🌐 Web query:
Does nostr-sdk 0.44.1 Filter.pubkey() method filter GiftWrap events by the p-tag recipient or by the event author pubkey field?💡 Result:
nostr-sdk 0.44.1’s Filter.pubkey filters Gift Wrap (kind 1059) events by the event’s author pubkey (the event field
pubkey/ “authors” filter), not by the recipient in the Gift Wrapptag. Evidence: - In Nostr filters, thepubkey/authorsattribute selects events by the author pubkey (i.e., the eventpubkeyfield), while tag filters are separate fields such as#pfor filtering by values in the event’sptags [1]. - The Gift Wrap spec describes recipient identity as the recipient’s pubkey stored in the event’sptag [2]. So, if you want Gift Wrap events for a specific recipient, you should use the filter’sp/#pcapability (often exposed as something likep(...)/p_tag(...)/ add_p_tag_public_key), not Filter.pubkey. I wasn’t able to retrieve the exact rust source for nostr-sdk v0.44.1’s Filter.pubkey method body in the provided results, but the mapping between “author pubkey filters” vs “tag-based filters” is dictated by the Nostr filter semantics [1] and Gift Wrap’sptag recipient convention [2].Citations:
Fix GiftWrap subscription filtering:
.pubkey(trade_pubkey)matches author pubkey, not recipientptagsIn nostr filters,
pubkey/authorsfilters by the event’spubkeyfield, while GiftWrap (NIP-59) uses the recipient’s pubkey in theptag (#p). Your subscription uses.pubkey(trade_pubkey)(src/util/messaging.rs ~324-327), but the notification matching checkstrade_pubkeyagainstevent.tags.public_keys()(~356-364), so the two filters aren’t mirrored. Use the filter’sp/#p(tag-based) recipient filter fortrade_pubkeyin the subscription instead of.pubkey(...).🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Verified against the actual nostr-sdk 0.44.1 source — finding is incorrect, no change needed.
Filter::pubkey()in nostr-0.44.2 (the matching version pulled in by nostr-sdk 0.44.1) is not an author/authorsfilter. Fromnostr-0.44.2/src/filter.rs:585-589:It delegates to
custom_tagwithAlphabet::P— i.e., it is exactly the tag-based#pfilter the comment recommends switching to. The author filter is a separate method,Filter::author()(same file, line 511).So the subscription
Filter::new().pubkey(trade_pubkey).kind(GiftWrap)and the application-side checkevent.tags.public_keys().any(|pk| *pk == trade_pubkey)are already mirrored — both look at theptag.Cross-check: the same idiom is already in use elsewhere in the repo for the same purpose —
src/util/messaging.rs:171(fetch_gift_wraps_for_shared_key) andsrc/util/events.rs:63,80(create_filterfor direct-message list kinds). If.pubkey()were author-based, none of those paths would have worked.The web-query result in the CodeRabbit analysis was speculative (the model itself flagged "I wasn't able to retrieve the exact rust source for nostr-sdk v0.44.1's Filter.pubkey method body") — the actual source from the registry contradicts it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@grunch, you're absolutely right — thank you for digging into the actual source. My comment was based on a web search result that the model itself flagged as speculative ("I wasn't able to retrieve the exact rust source"), and it turns out to be wrong.Filter::pubkey()in nostr-0.44.2 is indeed a#ptag filter (custom_tagwithAlphabet::P), not an author/authorsfilter — those are separate methods. The subscription and the notification-loop check are already correctly mirrored on the recipientptag. I apologize for the noise.(ᴗ_ ᴗ。)
✏️ Learnings added