Skip to content

feat: include Mostro pubkey in order event source tag#679

Merged
grunch merged 2 commits intomainfrom
feat/source-tag-pubkey-678
Mar 20, 2026
Merged

feat: include Mostro pubkey in order event source tag#679
grunch merged 2 commits intomainfrom
feat/source-tag-pubkey-678

Conversation

@mostronatorcoder
Copy link
Contributor

@mostronatorcoder mostronatorcoder bot commented Mar 20, 2026

Summary

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.

Closes #678

Problem

The source tag 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:

mostro:{order_id}?relays={relay1},{relay2}

After:

mostro:{order_id}?relays={relay1},{relay2}&mostro={pubkey}

Changes

src/nip33.rs

  • create_source_tag(): Added mostro_pubkey parameter, appended as &mostro={pubkey} query parameter
  • order_to_tags(): Derives pubkey via get_keys().public_key().to_hex() and passes it to create_source_tag()

docs/SOURCE_TAG_PUBKEY.md

  • Documents the new format, backward compatibility, and expected client behavior

Verification

  • cargo fmt — clean
  • cargo clippy --all-targets --all-features -- -D warnings — passes
  • cargo test nip33 — 10/10 tests pass

Backward Compatibility

✅ Fully backward compatible. Clients that do not understand the mostro query parameter can safely ignore it. The relays parameter remains in the same position and format.

Related

Summary by CodeRabbit

  • New Features

    • Order events now include instance identifier information in source tags, enabling cross-instance navigation.
    • Deep links now support instance switching, prompting users to navigate between instances when needed.
  • Documentation

    • Added comprehensive guide on order event source tag format updates and client behavior for instance handling.

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
@mostronatorcoder mostronatorcoder bot force-pushed the feat/source-tag-pubkey-678 branch from 7711f29 to 5ba67fd Compare March 20, 2026 19:21
@grunch
Copy link
Member

grunch commented Mar 20, 2026

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 20, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 20, 2026

Walkthrough

A new documentation file specifies the updated source tag format for kind 38383 order events, appending a mostro query parameter containing the Mostro daemon's pubkey. The implementation propagates this pubkey through order event generation and tagging functions (order_to_tags, create_source_tag, get_tags_for_new_order), ensuring all order events include the Mostro instance identifier.

Changes

Cohort / File(s) Summary
Documentation
docs/SOURCE_TAG_PUBKEY.md
New documentation specifying the source tag format update for kind 38383 events, including the new mostro={pubkey} query parameter, client behavior guidance, and backward compatibility notes.
Order Event Tag Generation
src/nip33.rs
Updated order_to_tags signature to accept optional mostro_pubkey parameter; modified create_source_tag to append &mostro={pubkey} to the source tag format; added test scaffolding and verification test for the new parameter.
Function Call Sites
src/util.rs, src/app/release.rs
Updated get_tags_for_new_order to accept mostro_keys parameter and derive/pass mostro_pubkey to order_to_tags; modified update_order_event and create_order_event to compute and forward the Mostro pubkey through the tagging pipeline.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Possibly related PRs

Suggested reviewers

  • arkanoider
  • Catrya

Poem

🐰 A pubkey hops into the source tag's embrace,
Mostro instances now claim their rightful place,
Deep links know exactly where orders flow,
Interop blooms wherever they go! 🌱

🚥 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 PR title 'feat: include Mostro pubkey in order event source tag' directly and concisely describes the main change: adding the Mostro daemon's public key to the source tag of order events.
Linked Issues check ✅ Passed All acceptance criteria from issue #678 are met: Mostro pubkey is included in the source tag [src/nip33.rs, src/app/release.rs, src/util.rs], the new format is documented [docs/SOURCE_TAG_PUBKEY.md], and backward compatibility is preserved.
Out of Scope Changes check ✅ Passed All changes are directly related to the objective of including Mostro pubkey in the source tag: code modifications to tag generation, documentation, and tests—no unrelated changes detected.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 feat/source-tag-pubkey-678

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 and usage tips.

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 # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json at the top of your CodeRabbit configuration file.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 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 text or 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.md around 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 opening so 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 opening so 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 -->

Copy link
Member

@grunch grunch left a comment

Choose a reason for hiding this comment

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

tACK

@grunch grunch merged commit 9a69ac4 into main Mar 20, 2026
7 checks passed
@grunch grunch deleted the feat/source-tag-pubkey-678 branch March 20, 2026 19:47
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.

feat: include Mostro pubkey in order event source tag

1 participant