Step 3 - refactor(dm): parse inbound GiftWrap with mostro_core unwrap_message#65
Conversation
Replace nostr-sdk nip59::extract_rumor for inbound trade DMs with mostro_core::unwrap_message (Ok(None) for wrong recipient). Reuse UnwrappedMessage in parse_dm_events_single / resolve_order_for_event / startup replay / listener probes; simplify rumor_cache keys to PublicKey. Co-authored-by: Cursor <cursoragent@cursor.com>
|
ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThis PR refactors GiftWrap parsing throughout ChangesGiftWrap Unwrap Centralization
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
I reviewed this carefully and I do not see a blocker in the current diff.
What I checked:
- the inbound GiftWrap refactor from
nostr-sdkextraction tomostro_core::unwrap_message - the semantics of
Ok(None)for non-recipient / non-decryptable events, especially in the waiter path and tracked-subscription path - the startup replay path, where this PR now reuses
UnwrappedMessageinstead of re-extracting the rumor again - the unknown-subscription fallback (
resolve_order_for_event) and whether the decoded message is still reused correctly there - the per-event decryptability cache, now keyed by
PublicKey, to make sure the key space is still correct for a single incoming event
The behavior looks coherent to me:
unwrap_messageis now the single inbound decode primitive, which matches the outbound migration done in the previous step- the
Ok(None)handling is a good fit for the current routing logic, because “not for this key” is not treated as an error anymore - startup replay / fallback paths still preserve the important optimization of avoiding a second unwrap when one already succeeded
- simplifying the cache key to
PublicKeyis fine here because the cache lifetime is scoped to one event handler block
Checks are green too, so this looks good from my side. Nice follow-up to the outbound NIP-59 cleanup, and it reduces another source of drift between Mostrix and mostro-core.
Replace nostr-sdk nip59::extract_rumor for inbound trade DMs with mostro_core::unwrap_message (Ok(None) for wrong recipient). Reuse UnwrappedMessage in parse_dm_events_single / resolve_order_for_event / startup replay / listener probes; simplify rumor_cache keys to PublicKey.
Summary by CodeRabbit
Release Notes