You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/other_events.md
+5Lines changed: 5 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -117,6 +117,10 @@ This event contains specific data about a Mostro instance. The instance is ident
117
117
"pow",
118
118
"0"
119
119
],
120
+
[
121
+
"protocol_version",
122
+
"1"
123
+
],
120
124
[
121
125
"hold_invoice_expiration_window",
122
126
"120"
@@ -214,6 +218,7 @@ Below is an explanation of the meaning of some of the labels in this event, all
214
218
-`max_orders_per_response`: Maximum complete orders data per response in orders action.
215
219
-`fee`: The fee percentage charged by the instance. For example, "0.006" means a 0.6% fee.
216
220
-`pow`: The Proof of Work required of incoming events.
221
+
-`protocol_version`: The Mostro protocol (wire transport) this node speaks — `"1"` for NIP-59 gift wrap (kind `1059`, DEPRECATED) or `"2"` for NIP-44 direct messages (kind `14`). A node speaks exactly one; clients read this tag to pick the matching wire format. See the [client migration guide](./transport_migration.md).
217
222
-`hold_invoice_expiration_window`: The maximum time, in seconds, for the hold invoice issued by Mostro to be paid by the seller.
218
223
-`hold_invoice_cltv_delta`: The number of blocks in which the Mostro hold invoice will expire.
219
224
-`invoice_expiration_window`: The maximum time, in seconds, for a buyer to submit an invoice to Mostro.
Copy file name to clipboardExpand all lines: src/overview.md
+72-2Lines changed: 72 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,10 +15,43 @@ You can find more details about the order event [here](./order_event.md)
15
15
16
16
## The Message
17
17
18
-
All **_messages_** from/to Mostro should be [Gift wrap Nostr events](https://github.com/nostr-protocol/nips/blob/master/59.md), the `content` of the `rumor` event is a JSON-serialized `array` as a string (with no white space or line breaks), the first element is the message, the second element is the `signature` of the sha256 hash of the serialized first element, here the structure of the first element:
18
+
### Transports
19
+
20
+
Mostro messages travel over one of two interchangeable wire transports. A
21
+
given node speaks **exactly one** of them — there is no dual mode — and
22
+
advertises which in its [instance-info event](./other_events.md#mostro-instance-status)
23
+
(kind `38385`) through the `protocol_version` tag (`"1"` or `"2"`):
24
+
25
+
| Protocol | Transport | Event kind | Status |
26
+
|----------|-----------|------------|--------|
27
+
|**v1**|[NIP-59 Gift Wrap](https://github.com/nostr-protocol/nips/blob/master/59.md)|`1059`|**DEPRECATED** (default through v0.18.x) |
28
+
|**v2**| NIP-44 direct message |`14`| current (default from v0.19.0) |
29
+
30
+
Both transports carry the **same logical message** and, once unwrapped,
31
+
yield the same structure to the daemon's handlers — only the envelope and
32
+
how the identity key is proven differ. Client developers should support
33
+
both during the transition and pick per node from the `protocol_version`
34
+
tag; see the [client migration guide](./transport_migration.md).
35
+
36
+
The logical message itself (the first tuple element described below) is
37
+
identical across transports, except for the `version` field: `1` on the
38
+
gift-wrap transport, `2` on the NIP-44 direct transport.
39
+
40
+
### The logical message
41
+
42
+
In **protocol v1** all **_messages_** from/to Mostro are
the `content` of the `rumor` event is a JSON-serialized `array` as a string
45
+
(with no white space or line breaks), the first element is the message, the
46
+
second element is the `signature` of the sha256 hash of the serialized
47
+
first element. In **protocol v2** the same array travels NIP-44 encrypted
48
+
inside a signed kind-`14` event and gains a third element (the identity
49
+
proof) — see [Keys management](./key_management.md#protocol-v2--nip-44-direct-messages)
50
+
for the v2 wire format. Here the structure of the first element (the
51
+
logical message, shared by both transports):
19
52
20
53
-[Wrapper](https://docs.rs/mostro-core/latest/mostro_core/message/enum.Message.html): Wrapper of the **_Message_**
21
-
- <`version` integer>: Version of the protocol, currently`1`
54
+
- <`version` integer>: Version of the protocol —`1` on the gift-wrap transport, `2` on the NIP-44 direct transport
22
55
-[`id` integer]: (optional) Wrapper Id
23
56
-[`request_id` integer]: (optional) Mostro daemon should send back this same id in the response
24
57
-[`trade_index` integer]: (optional) This field is used by users who wants to maintain reputation, it should be the index of the trade in the user's trade history
@@ -52,6 +85,43 @@ Here an example of a `new-order` order **_message_**:
52
85
}
53
86
```
54
87
88
+
### The content array (v1 vs v2)
89
+
90
+
The first element above is the logical message. The array that actually
91
+
travels in the `content` differs by transport:
92
+
93
+
**Protocol v1** (gift wrap) — a **2-element** array:
94
+
95
+
```json
96
+
[
97
+
{ "order": { "version": 1, "...": "..." } },
98
+
"<trade-key signature, or null>"
99
+
]
100
+
```
101
+
102
+
**Protocol v2** (NIP-44 direct) — a **3-element** array, the v1 pair plus an
103
+
identity proof, NIP-44 encrypted inside a signed kind-`14` event:
104
+
105
+
```json
106
+
[
107
+
{ "order": { "version": 2, "...": "..." } },
108
+
"<trade-key signature, or null>",
109
+
["<identity pubkey>", "<identity signature>"]
110
+
]
111
+
```
112
+
113
+
| element | meaning |
114
+
|---|---|
115
+
| 1 | the logical message (the `version: 2` wrapper shown above) |
116
+
| 2 | the trade key's signature over the serialized first element, or `null` (Mostro replies and full-privacy mode set this element to `null`; the outer kind-14 event is still signed, as in v1) |
117
+
| 3 | the identity proof `["<identity pubkey>", "<identity signature>"]`, or `null` for full-privacy mode (where the identity is the trade key itself) |
118
+
119
+
In v1 the identity key is carried, authenticated, by the gift-wrap *seal*.
120
+
v2 has no seal, so the identity instead travels **inside the ciphertext**
121
+
as element 3 — never visible at the event level, exactly as private as
122
+
before. The full v2 envelope and identity-proof signing rule are documented
123
+
in [Keys management](./key_management.md#protocol-v2--nip-44-direct-messages).
124
+
55
125
## Payment Request Array Structure
56
126
57
127
The `payment_request` field in the payload can have different structures depending on the use case:
0 commit comments