From d50b52d97bc21fdfe3fa7aafb0b97ffa9f03203b Mon Sep 17 00:00:00 2001
From: "mostronatorcoder[bot]"
<263173566+mostronatorcoder[bot]@users.noreply.github.com>
Date: Fri, 20 Mar 2026 19:07:36 +0000
Subject: [PATCH 1/2] feat: include Mostro pubkey in order event source tag
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
---
docs/SOURCE_TAG_PUBKEY.md | 45 +++++++++++++++++++++++++++++++++++++++
src/nip33.rs | 21 +++++++++++++-----
2 files changed, 61 insertions(+), 5 deletions(-)
create mode 100644 docs/SOURCE_TAG_PUBKEY.md
diff --git a/docs/SOURCE_TAG_PUBKEY.md b/docs/SOURCE_TAG_PUBKEY.md
new file mode 100644
index 00000000..129a5bc9
--- /dev/null
+++ b/docs/SOURCE_TAG_PUBKEY.md
@@ -0,0 +1,45 @@
+# Source Tag: Mostro Pubkey
+
+## Overview
+
+The `source` tag in kind 38383 order events now includes the Mostro daemon's pubkey,
+allowing clients to identify which Mostro instance published the order.
+
+## Format
+
+### Before
+
+```
+mostro:{order_id}?relays={relay1},{relay2}
+```
+
+### After
+
+```
+mostro:{order_id}?relays={relay1},{relay2}&mostro={pubkey}
+```
+
+### Example
+
+```
+mostro:e215c07e-b1f9-45b0-9640-0295067ee99a?relays=wss://relay.mostro.network,wss://nos.lol&mostro=82fa8cb978b43c79b2156585bac2c011176a21d2aead6d9f7c575c005be88390
+```
+
+## Backward Compatibility
+
+Clients that do not understand the `mostro` query parameter can safely ignore it.
+The `relays` parameter remains in the same position and format as before.
+
+## Client Behavior
+
+When a client receives a deep link with a `mostro` parameter:
+
+1. If the pubkey matches the currently selected Mostro instance → open order directly
+2. If different → prompt user to switch instances, then navigate to order detail
+
+See [MostroP2P/mobile#541](https://github.com/MostroP2P/mobile/issues/541) for client implementation.
+
+## Related
+
+- [Order Event spec](https://mostro.network/protocol/order_event.html)
+- Issue: [#678](https://github.com/MostroP2P/mostro/issues/678)
diff --git a/src/nip33.rs b/src/nip33.rs
index c19257ae..a1524c43 100644
--- a/src/nip33.rs
+++ b/src/nip33.rs
@@ -1,6 +1,6 @@
use crate::config::settings::Settings;
use crate::lightning::LnStatus;
-use crate::util::get_expiration_timestamp_for_kind;
+use crate::util::{get_expiration_timestamp_for_kind, get_keys};
use crate::LN_STATUS;
use mostro_core::prelude::*;
use nostr::event::builder::Error;
@@ -237,16 +237,25 @@ fn create_status_tags(order: &Order) -> Result<(bool, Status), MostroError> {
/// includes:
/// - Order ID
/// - List of relays where the event can be found
+/// - Mostro daemon's pubkey (so clients can identify the instance)
///
-/// The resulting reference uses a custom format: `mostro:{order_id}?{relay1,relay2,...}`
+/// The resulting reference uses a custom format:
+/// `mostro:{order_id}?relays={relay1,relay2,...}&mostro={pubkey}`
///
fn create_source_tag(
order: &Order,
mostro_relays: &[String],
+ mostro_pubkey: &str,
) -> Result