Skip to content

fix: ensure rumor id is serialized inside the gift wrap - #164

Merged
grunch merged 1 commit into
mainfrom
fix/gift-wrap-rumor-missing-id
Aug 15, 2026
Merged

fix: ensure rumor id is serialized inside the gift wrap#164
grunch merged 1 commit into
mainfrom
fix/gift-wrap-rumor-missing-id

Conversation

@Catrya

@Catrya Catrya commented Aug 15, 2026

Copy link
Copy Markdown
Member

Since the migration to nostr 0.45.0, gift-wrapped rumors go out without the id field: GiftWrapSealBuilder encrypts the rumor JSON before ensuring its id, so the id computed inside build_seal is silently discarded. This is a bug in nostr itself, reported in nostrdevkit/nostr#1443 and fixed in nostrdevkit/nostr#1444, but until that fix ships in a release, every daemon on mostro-core ≥ 0.14.3 emits rumors that strict NIP-59 clients reject. In practice this broke the Mostro mobile app against upgraded nodes: it fails to decrypt every reply from the daemon, so orders time out client-side and trading is impossible.

The workaround is a single rumor.ensure_id() in wrap_message before sealing, which restores the pre-0.45 wire format. It becomes a cheap no-op once the upstream fix lands, and it's worth keeping even then as a guard. The wrap_with_raw_inner test helper mirrors the call so test wraps stay representative of production ones.

Also adds a regression test that unwraps the gift wrap by hand, our own unwrap_message tolerates a missing id, so it can't catch this, and checks the rumor id survives inside the encrypted payload.

Verified end to end with mostrod pointing at this branch, the mobile client can create and take orders again.

Summary by CodeRabbit

  • Bug Fixes

    • Improved event finalization so sealed events consistently include their computed identifiers.
    • Fixed serialized event data to preserve matching IDs.
  • Tests

    • Added regression coverage to verify event IDs remain consistent after serialization and sealing.

Call  on the rumor in  before sealing:
 in nostr 0.45 encrypts the rumor JSON before
ensuring its id (nostrdevkit/nostr#1443), so wraps went out without the
rumor uid=1000(catry) gid=1000(catry) grupos=1000(catry),4(adm),27(sudo),109(kvm),124(lpadmin),134(docker),138(libvirt) field and strict NIP-59 clients rejected them. Mirror the
call in the  test helper and add a regression test
that unwraps by hand and checks the id survives the wrap.
@coderabbitai

coderabbitai Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 45ef083f-7960-4b16-bbf1-87ca73e29a63

📥 Commits

Reviewing files that changed from the base of the PR and between e62f0d6 and a0350f9.

📒 Files selected for processing (1)
  • src/nip59.rs

Walkthrough

Rumors now receive an ID before sealing. A regression test verifies that the serialized rumor ID matches its computed ID. The raw-inner test helper follows the same behavior.

Changes

Rumor ID finalization

Layer / File(s) Summary
Assign and verify rumor IDs
src/nip59.rs
Production wrapping assigns an ID before sealing. The regression test validates the serialized ID after decryption. The raw-inner helper applies the same assignment.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to a0350

This localized change ensures rumor IDs are preserved in gift-wrapped messages and adds regression coverage; no actionable merge-blocking risk remains after normal checks and review.

Suggested reviewers: arkanoider, grunch

Poem

A rabbit sealed a rumor tight,
Then gave its ID a place in sight.
The tests unwrapped each layer with care,
And found the matching number there.
“Hop!” said Bun, “the seal is right.”

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: preserving the rumor ID in the gift wrap.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/gift-wrap-rumor-missing-id

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ermeme ermeme Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the current head a0350f9.

The workaround is scoped correctly: wrap_message now finalizes the rumor id before GiftWrapSealBuilder serializes/encrypts it, which matches the observed nostr 0.45.1 behavior. The regression test unwraps the encrypted payload and verifies the serialized rumor carries the computed id; I also mutation-checked that the test fails when the production ensure_id() call is removed.

Local verification passed:

  • cargo fmt --all -- --check
  • cargo test nip59::tests::rumor_id_serialized_inside_wrap -- --exact
  • cargo test
  • cargo clippy --all-targets --all-features -- -D warnings

CI is green on the current head and I did not find blockers.

@Catrya
Catrya requested review from arkanoider and grunch August 15, 2026 05:49

@grunch grunch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@grunch
grunch merged commit 475169b into main Aug 15, 2026
11 checks passed
@grunch
grunch deleted the fix/gift-wrap-rumor-missing-id branch August 15, 2026 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants