Skip to content

Replace the outdated protocol documentation with the most up-to-date version#527

Closed
Catrya wants to merge 1 commit intomainfrom
update-protocol-documentation
Closed

Replace the outdated protocol documentation with the most up-to-date version#527
Catrya wants to merge 1 commit intomainfrom
update-protocol-documentation

Conversation

@Catrya
Copy link
Copy Markdown
Member

@Catrya Catrya commented Mar 11, 2026

In this PR, all the protocol documentation is updated to match exactly what is in https://github.com/MostroP2P/protocol.

Summary by CodeRabbit

  • Documentation
    • Added new protocol documentation for dispute chat messaging, last trade index queries, and order detail requests.
    • Updated protocol event structures across multiple message types for standardization.
    • Updated event kind references throughout protocol documentation.
    • Corrected grammar and terminology in protocol descriptions.
    • Renamed public field identifiers in message payloads for clarity.
    • Added new error reason codes for request rate limits and currency validation.
    • Expanded overview with comprehensive event-kind mapping table.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 11, 2026

Walkthrough

Documentation for the Mostro P2P protocol is updated across 20+ files to standardize message formats, rename fields, update event kinds, add new protocol actions, and document dispute chat and order request mechanisms.

Changes

Cohort / File(s) Summary
New Protocol Documentation
docs/protocol/dispute_chat.md, docs/protocol/last_trade_index.md, docs/protocol/orders.md
Added three new documentation files: dispute_chat describes shared-key ECDH and gift-wrap messaging for disputes; last_trade_index documents a new action for querying user trade index; orders documents requesting order details via payload with ID array.
Message Format Standardization (Array Wrapping)
docs/protocol/admin_add_solver.md, docs/protocol/admin_cancel_order.md, docs/protocol/admin_settle_order.md, docs/protocol/cancel.md, docs/protocol/release.md, docs/protocol/restore_session.md, docs/protocol/take_buy.md, docs/protocol/user_rating.md
Updated JSON payload examples from single objects to arrays containing the object followed by trailing null, standardizing serialization format across multiple admin and order-related messages.
Event Kind and Tag Updates
docs/protocol/dispute.md, docs/protocol/list_disputes.md, docs/protocol/other_events.md, docs/protocol/order_event.md
Updated Mostro addressable event kind from 38383 to 38386 in multiple examples; added initiator tags to dispute events; expanded event definitions and kind mappings; added new Development Fee section (kind 8383).
Field Name Standardization
docs/protocol/new_buy_order.md, docs/protocol/new_buy_order_ln_address.md, docs/protocol/seller_pay_hold_invoice.md, docs/protocol/take_sell.md, docs/protocol/take_sell_range_order.md
Renamed pubkey fields from master_buyer_pubkey/master_seller_pubkey to buyer_trade_pubkey/seller_trade_pubkey across multiple order and invoice examples.
Overview and Structure Updates
docs/protocol/SUMMARY.md, docs/protocol/overview.md
Added navigation links for request order details and dispute chat in SUMMARY.md; expanded overview with event kind mapping table, clarified message JSON serialization structure, and added sections for Payment Request Array Structure and Optional Fields.
Documentation and Format Refinements
docs/protocol/key_management.md, docs/protocol/message_suggestions_for_actions.md, docs/protocol/new_sell_order.md, docs/protocol/new_sell_range_order.md, docs/protocol/take_buy_range_order.md, docs/protocol/take_sell_ln_address.md
Minor updates including clarifying comments on null values, adding new CantDo reason codes (too-many-requests, invalid-fiat-currency), adjusting payload formatting, and updating example data structures.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • grunch

Poem

🐰 Hops through the protocols with glee,
Fields renamed, events resized with care,
Array-wrapped messages dance so fair,
Kind 38386 lights the way,
Dispute chat blooms—hip hip hooray! 🎉

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and clearly summarizes the main objective of the pull request—updating protocol documentation across multiple files to reflect the latest version.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch update-protocol-documentation

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.

Copy link
Copy Markdown
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.

Actionable comments posted: 6

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
docs/protocol/take_buy.md (1)

5-18: ⚠️ Potential issue | 🟡 Minor

Add language specifiers to all fenced code blocks.

All eight JSON code blocks in this file are missing language identifiers, which violates the markdownlint MD040 rule. As per coding guidelines, every fenced code block in markdown files must have a language specifier.

📝 Proposed fix

Change line 5 from:

-```
+```json

Repeat this change for all JSON code blocks at lines 22, 39, 69, 102, 120, 135, and 164.

Also applies to: 22-32, 39-64, 69-97, 102-112, 120-130, 135-156, 164-179

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/protocol/take_buy.md` around lines 5 - 18, Add the missing language
specifier "json" to each fenced code block in the document where the opening
fence is currently ``` so that they read ```json; update all eight JSON blocks
(the ones shown in the diff and referenced in the comment) by changing their
opening backticks to include the language identifier, ensuring every fenced
block has a language specifier to satisfy MD040.
docs/protocol/dispute.md (1)

5-17: ⚠️ Potential issue | 🟡 Minor

Add language specifiers to all fenced code blocks.

All seven JSON code blocks in this file are missing language identifiers, which violates the markdownlint MD040 rule. As per coding guidelines, every fenced code block in markdown files must have a language specifier.

📝 Proposed fix

Change line 5 from:

-```
+```json

Repeat this change for all JSON code blocks at lines 23, 41, 63, 88, 104, 135, and 155.

Also applies to: 23-37, 41-55, 63-83, 88-98, 104-129, 135-150, 155-174

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/protocol/dispute.md` around lines 5 - 17, Update each JSON fenced code
block in the dispute protocol examples so the opening fence includes the json
language specifier (i.e., change ``` to ```json) for all seven examples (the
blocks that start with JSON arrays/objects such as the one beginning with
[{"order": {"version": 1, "id": "<Order Id>", "action": "dispute", ...}}]).
Ensure every fenced block in this file uses ```json consistently to satisfy
markdownlint MD040.
🧹 Nitpick comments (2)
docs/protocol/dispute_chat.md (1)

39-39: Clarify per-party shared key implementation.

The documentation states: "Each party (buyer and seller) has its own independent shared key with the admin."

However, the code at lib/data/models/session.dart:191-203 shows a single _adminSharedKey computed from tradeKey.private and adminPubkey. Since the Session is tied to a specific orderId and party (via their trade key index), this creates one shared key per session/party, which matches the documentation. But the implementation detail that the key is derived from the party's specific trade key could be made more explicit.

Consider adding a clarifying note:

 Each party (buyer and seller) has its own independent shared key with the admin. 
+The shared key is derived using each party's trade key, ensuring that messages 
+from the buyer and seller remain separate and private.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/protocol/dispute_chat.md` at line 39, Update the docs to explicitly
state that the admin shared key is derived per-session from the party's trade
key by the Session model: the Session computes _adminSharedKey using
tradeKey.private and adminPubkey, and because Session is bound to a specific
orderId and party (via the trade key index), each party (buyer/seller) ends up
with its own independent admin shared key; add a short clarifying sentence in
dispute_chat.md explaining this derivation and that a session can therefore hold
both a peer shared key and an admin shared key simultaneously.
docs/protocol/dispute.md (1)

132-132: Minor grammar correction.

The phrase "different than" is considered colloquial. The preferred formal usage is "different from."

✏️ Proposed fix
-Then mostrod send messages to each trade participant, the buyer and seller for them to know the pubkey of the admin who took the dispute, that way the client can start listening events from that specific pubkey, by default clients should discard any messages received from any pubkey different than Mostro node or dispute solver, the message looks like this:
+Then mostrod send messages to each trade participant, the buyer and seller for them to know the pubkey of the admin who took the dispute, that way the client can start listening events from that specific pubkey, by default clients should discard any messages received from any pubkey different from Mostro node or dispute solver, the message looks like this:
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/protocol/dispute.md` at line 132, Update the sentence in the dispute
protocol docs to use formal phrasing: replace "different than Mostro node or
dispute solver" with "different from Mostro node or dispute solver" in the
sentence that begins "Then mostrod send messages to each trade participant..."
so the line reads that clients should discard any messages received from any
pubkey different from Mostro node or dispute solver; ensure only that wording
change is made.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/protocol/dispute_chat.md`:
- Around line 29-31: The fenced code blocks containing the ECDH formulas (e.g.,
"Shared Key = ECDH(tradeKey.private, adminPubkey)" and "Shared Key =
ECDH(adminPrivateKey, tradeKey.public)" and the similar block at lines 35-37)
are missing language specifiers; update each fence to include a language tag
(suggest "text") so each block becomes ```text ... ``` to satisfy MD040 and the
repo markdown guideline.

In `@docs/protocol/dispute.md`:
- Line 75: Dispute.fromNostrEvent currently only extracts "d" and "s" tags so
the initiator tag from events is dropped; update the Dispute model to add an
initiator field and modify Dispute.fromNostrEvent to parse the ["initiator",
<value>] tag (same convention used in docs/protocol/dispute.md) and assign it to
the new field, ensuring the field is added to the Dispute class (and
constructor/serialization if applicable) so it aligns with RestoredDispute which
already preserves initiator.

In `@docs/protocol/message_suggestions_for_actions.md`:
- Around line 148-149: Add support for the documented too-many-requests CantDo
reason: update the CantDoReason enum (lib/data/models/enums/cant_do_reason.dart)
to include a tooManyRequests variant, ensure CantDoReason.fromString()
recognizes the "too_many_requests" string, and add a corresponding entry for
'too_many_requests' in CantDoNotificationMapper._messageMap
(lib/shared/widgets/notification_listener_widget.dart) so CantDo.fromJson()
won't throw ArgumentError/FormatException; alternatively, if you prefer to
remove the reason, delete references to "too-many-requests"/"too_many_requests"
from the docs and any server contracts so the enum and mapper remain unchanged.

In `@docs/protocol/new_buy_order.md`:
- Around line 62-63: Update the test fixtures in
test/notifiers/add_order_notifier_test.dart to use the current protocol field
names buyer_trade_pubkey and seller_trade_pubkey instead of the deprecated
master_buyer_pubkey and master_seller_pubkey (replace the occurrences around the
existing fixtures at the two places mentioned), keeping the same values
(including null) so Order.fromJson continues to parse the fixtures correctly;
after replacing, run the tests to confirm no behavior changes.

In `@docs/protocol/new_sell_order.md`:
- Around line 3-27: The example shows a bare object but the client serializes
new-order messages as an array envelope; update the example to match
MostroMessage serialization by wrapping the object in an array of two elements
(the body object and a signature or null), i.e., mirror the serialization logic
used in lib/data/models/mostro_message.dart for "new-order" messages so the
request example matches the client and the confirmation example later in the
doc.

In `@docs/protocol/restore_session.md`:
- Around line 9-20: Several fenced code blocks in the restore_session.md
document that contain JSON examples (for example the block showing the array
with the "restore" object containing "version", "action": "restore-session", and
"payload") are missing language specifiers; update each JSON fenced block by
replacing the opening triple backticks (```) with language-marked backticks
(```json) for all JSON examples in the file so they comply with MD040. Ensure
you change every JSON example block (the three blocks currently without
specifiers) to start with ```json.

---

Outside diff comments:
In `@docs/protocol/dispute.md`:
- Around line 5-17: Update each JSON fenced code block in the dispute protocol
examples so the opening fence includes the json language specifier (i.e., change
``` to ```json) for all seven examples (the blocks that start with JSON
arrays/objects such as the one beginning with [{"order": {"version": 1, "id":
"<Order Id>", "action": "dispute", ...}}]). Ensure every fenced block in this
file uses ```json consistently to satisfy markdownlint MD040.

In `@docs/protocol/take_buy.md`:
- Around line 5-18: Add the missing language specifier "json" to each fenced
code block in the document where the opening fence is currently ``` so that they
read ```json; update all eight JSON blocks (the ones shown in the diff and
referenced in the comment) by changing their opening backticks to include the
language identifier, ensuring every fenced block has a language specifier to
satisfy MD040.

---

Nitpick comments:
In `@docs/protocol/dispute_chat.md`:
- Line 39: Update the docs to explicitly state that the admin shared key is
derived per-session from the party's trade key by the Session model: the Session
computes _adminSharedKey using tradeKey.private and adminPubkey, and because
Session is bound to a specific orderId and party (via the trade key index), each
party (buyer/seller) ends up with its own independent admin shared key; add a
short clarifying sentence in dispute_chat.md explaining this derivation and that
a session can therefore hold both a peer shared key and an admin shared key
simultaneously.

In `@docs/protocol/dispute.md`:
- Line 132: Update the sentence in the dispute protocol docs to use formal
phrasing: replace "different than Mostro node or dispute solver" with "different
from Mostro node or dispute solver" in the sentence that begins "Then mostrod
send messages to each trade participant..." so the line reads that clients
should discard any messages received from any pubkey different from Mostro node
or dispute solver; ensure only that wording change is made.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 171697f0-fd69-4bc7-a3eb-dded50a58d5a

📥 Commits

Reviewing files that changed from the base of the PR and between 902a650 and eba4539.

📒 Files selected for processing (28)
  • docs/protocol/SUMMARY.md
  • docs/protocol/admin_add_solver.md
  • docs/protocol/admin_cancel_order.md
  • docs/protocol/admin_settle_order.md
  • docs/protocol/cancel.md
  • docs/protocol/dispute.md
  • docs/protocol/dispute_chat.md
  • docs/protocol/key_management.md
  • docs/protocol/last_trade_index.md
  • docs/protocol/list_disputes.md
  • docs/protocol/message_suggestions_for_actions.md
  • docs/protocol/new_buy_order.md
  • docs/protocol/new_buy_order_ln_address.md
  • docs/protocol/new_sell_order.md
  • docs/protocol/new_sell_range_order.md
  • docs/protocol/order_event.md
  • docs/protocol/orders.md
  • docs/protocol/other_events.md
  • docs/protocol/overview.md
  • docs/protocol/release.md
  • docs/protocol/restore_session.md
  • docs/protocol/seller_pay_hold_invoice.md
  • docs/protocol/take_buy.md
  • docs/protocol/take_buy_range_order.md
  • docs/protocol/take_sell.md
  • docs/protocol/take_sell_ln_address.md
  • docs/protocol/take_sell_range_order.md
  • docs/protocol/user_rating.md

Comment thread docs/protocol/dispute_chat.md
Comment thread docs/protocol/dispute.md
Comment thread docs/protocol/message_suggestions_for_actions.md
Comment thread docs/protocol/new_buy_order.md
Comment thread docs/protocol/new_sell_order.md
Comment thread docs/protocol/restore_session.md
@grunch
Copy link
Copy Markdown
Member

grunch commented Mar 19, 2026

I think we should remove this documentation from here and not spend time maintaining two repositories with the same info

@Catrya
Copy link
Copy Markdown
Member Author

Catrya commented Mar 19, 2026

I think we should remove this documentation from here and not spend time maintaining two repositories with the same info

Agree, I'll remove that documentation and reference it in one of the existing ones.

@grunch
Copy link
Copy Markdown
Member

grunch commented Mar 19, 2026

great closing it

@grunch grunch closed this Mar 19, 2026
@grunch grunch deleted the update-protocol-documentation branch March 19, 2026 18:45
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