feat: include Mostro pubkey in order event source tag#679
Conversation
Adds the Mostro daemon's pubkey to the source tag in kind 38383 order
events, enabling clients to identify which Mostro instance published
the order.
## Changes
### src/nip33.rs
- `create_source_tag()`: Added `mostro_pubkey` parameter, appended as
`&mostro={pubkey}` query parameter to the source URL
- `order_to_tags()`: Derives pubkey via `get_keys()` and passes it to
`create_source_tag()`
### docs/SOURCE_TAG_PUBKEY.md
- Documents the new format, backward compatibility, and client behavior
## Source Tag Format
Before: `mostro:{order_id}?relays={relay1},{relay2}`
After: `mostro:{order_id}?relays={relay1},{relay2}&mostro={pubkey}`
## Backward Compatibility
Clients that do not understand the `mostro` query parameter can
safely ignore it. The `relays` parameter remains unchanged.
Closes #678
Related: MostroP2P/mobile#541
Instead of silently skipping the source tag when keys are unavailable, properly pass the Mostro pubkey as an optional parameter to order_to_tags(). ## Changes ### API signature change - order_to_tags() now takes an optional `mostro_pubkey: Option<&str>` - If None, derives pubkey from get_keys() (production behavior) - If Some, uses the provided pubkey (test behavior) ### Updated call sites - src/app/release.rs: Pass my_keys.public_key().to_hex() - src/util.rs: get_tags_for_new_order() now takes mostro_keys parameter - src/util.rs: update_order_event() passes keys.public_key().to_hex() ### New test - order_to_tags_source_tag_includes_mostro_pubkey: Verifies the source tag contains the correct Mostro pubkey in the expected format ## Verification - 195 tests pass (was 194, +1 for new source tag test) - cargo fmt: clean - cargo clippy: clean
7711f29 to
5ba67fd
Compare
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
WalkthroughA new documentation file specifies the updated Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~15 minutes 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 Tip You can validate your CodeRabbit configuration file in your editor.If your editor has YAML language server, you can enable auto-completion and validation by adding |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
docs/SOURCE_TAG_PUBKEY.md (1)
12-26: Add language specifiers to fenced code blocks.As per coding guidelines, all fenced code blocks in documentation should have a language specifier. Since these are URL-like format strings, use
textor leave them as plain text with a specifier.📝 Suggested fix
### Before -``` +```text mostro:{order_id}?relays={relay1},{relay2}After
-
+text
mostro:{order_id}?relays={relay1},{relay2}&mostro={pubkey}### Example -``` +```text mostro:e215c07e-b1f9-45b0-9640-0295067ee99a?relays=wss://relay.mostro.network,wss://nos.lol&mostro=82fa8cb978b43c79b2156585bac2c011176a21d2aead6d9f7c575c005be88390</details> <details> <summary>🤖 Prompt for AI Agents</summary>Verify each finding against the current code and only fix it if needed.
In
@docs/SOURCE_TAG_PUBKEY.mdaround lines 12 - 26, The fenced code blocks in
docs/SOURCE_TAG_PUBKEY.md lack language specifiers; update each triple-backtick
block containing the URL examples (the blocks showing
"mostro:{order_id}?relays={relay1},{relay2}", the "After" block with
"&mostro={pubkey}", and the "Example" block with the long mostro URL) to include
a language specifier (use "text") after the openingso they readtext
instead of ``` to satisfy the documentation code-block guideline.</details> </blockquote></details> </blockquote></details> <details> <summary>🤖 Prompt for all review comments with AI agents</summary>Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In@docs/SOURCE_TAG_PUBKEY.md:
- Around line 12-26: The fenced code blocks in docs/SOURCE_TAG_PUBKEY.md lack
language specifiers; update each triple-backtick block containing the URL
examples (the blocks showing "mostro:{order_id}?relays={relay1},{relay2}", the
"After" block with "&mostro={pubkey}", and the "Example" block with the long
mostro URL) to include a language specifier (use "text") after the openingso they readtext instead of ``` to satisfy the documentation code-block
guideline.</details> --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> **Configuration used**: Organization UI **Review profile**: CHILL **Plan**: Pro **Run ID**: `ef2d26f3-64f7-458e-b047-efc634ca24e7` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 245b344a19b5badc9888665776f142d80d3abbe6 and 5ba67fd46e485df0c2a9289cf014a1f6c0055c60. </details> <details> <summary>📒 Files selected for processing (4)</summary> * `docs/SOURCE_TAG_PUBKEY.md` * `src/app/release.rs` * `src/nip33.rs` * `src/util.rs` </details> </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
Summary
Adds the Mostro daemon's pubkey to the
sourcetag in kind 38383 order events, enabling clients to identify which Mostro instance published the order.Closes #678
Problem
The
sourcetag in order events did not identify which Mostro instance published the order. Clients assumed all deep links belonged to the default Mostro, causing links from other instances to fail.Solution
Append
&mostro={pubkey}to the existing source URL:Before:
After:
Changes
src/nip33.rscreate_source_tag(): Addedmostro_pubkeyparameter, appended as&mostro={pubkey}query parameterorder_to_tags(): Derives pubkey viaget_keys().public_key().to_hex()and passes it tocreate_source_tag()docs/SOURCE_TAG_PUBKEY.mdVerification
cargo fmt— cleancargo clippy --all-targets --all-features -- -D warnings— passescargo test nip33— 10/10 tests passBackward Compatibility
✅ Fully backward compatible. Clients that do not understand the
mostroquery parameter can safely ignore it. Therelaysparameter remains in the same position and format.Related
Summary by CodeRabbit
New Features
Documentation