Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 33 additions & 8 deletions src/restore_session.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Client sends a Gift wrap Nostr event to Mostro with the following rumor's conten

## Response

Mostro will respond with a message containing all non-finalized orders (e.g., statuses such as `pending`, `active`, `fiat-sent`, `waiting-buyer-invoice`, `waiting-payment`, `settled-hold-invoice`) and any active disputes. The response format will be:
Mostro will respond with a message containing all non-finalized orders (e.g., statuses such as `pending`, `active`, `fiat-sent`, `waiting-buyer-invoice`, `waiting-payment`) and any active disputes. Orders currently under dispute are not included in `orders`; their information is reported through the `disputes` array instead. The response format will be:

```json
[
Expand Down Expand Up @@ -54,7 +54,16 @@ Mostro will respond with a message containing all non-finalized orders (e.g., st
"order_id": "<Order Id>",
"trade_index": 4,
"status": "initiated",
"initiator": "seller"
"initiator": "seller",
"solver_pubkey": null
},
{
"dispute_id": "<Dispute Id>",
"order_id": "<Order Id>",
"trade_index": 5,
"status": "in-progress",
"initiator": "buyer",
"solver_pubkey": "<Solver Pubkey>"
}
]
}
Expand All @@ -68,16 +77,32 @@ Mostro will respond with a message containing all non-finalized orders (e.g., st
### Fields

* `restore_data`: Wrapper object that contains the session recovery data.
* `restore_data.orders`: An array of active or ongoing orders with their `order_id`, `trade_index`, and current `status`.
* `restore_data.disputes`: An array of ongoing disputes with `dispute_id`, the associated `order_id`, `trade_index`, current `status`, and `initiator` (`"buyer"`, `"seller"`, or `null` if unknown).
* `restore_data.orders`: An array of active or ongoing orders. Each entry contains:
* `order_id`: unique identifier of the order.
* `trade_index`: user's trade index for the order. Used with the mnemonic seed to derive the trade key pair subscribed to it.
* `status`: current order state (e.g., `pending`, `active`, `fiat-sent`, `waiting-buyer-invoice`, `waiting-payment`).
* `restore_data.disputes`: An array of ongoing disputes. Each entry contains:
* `dispute_id`: unique identifier of the dispute.
* `order_id`: id of the order in dispute.
* `trade_index`: trade index of that order. Used with the mnemonic seed to derive the same trade key pair already subscribed to it.
* `status`: current state of the dispute (e.g., `initiated`, `in-progress`).
* `initiator`: party that opened the dispute (`buyer` or `seller`). Tells the client whether the user or the counterparty started it.
* `solver_pubkey`: hex pubkey of the assigned solver, or `null` if none yet. Set once an admin assigns one via `admin-add-solver`. Also used to derive the ECDH shared key for the dispute chat.
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

no need to tell that the solver pubkey was added once via admin-add-solver because a mostro node can have many solvers added that way, what it should say is the solver_pubkey value is the pubkey of one of the solvers previously added that took that dispute via admin-take-dispute


> **Note:** When an order is in dispute it does not appear in `orders`, it appears in `disputes`. In each dispute entry:
>
> * `trade_index` is the order's `trade_index`.
> * `order_id` is the id of that order.
> * The order's `status` is implicitly `dispute`.

## Example Use Case

A user has the following:

* Two `pending` orders (trade index 1 and 2)
* One `active` order (trade index 3)
* One active dispute (trade index 4)
* One dispute just opened, still waiting for a solver (trade index 4)
* One dispute already taken by a solver (trade index 5)

When switching to desktop, after restoring the mnemonic, the client sends `restore-session` and receives:

Expand All @@ -92,11 +117,11 @@ When switching to desktop, after restoring the mnemonic, the client sends `resto
"orders": [
{ "order_id": "abc-123", "trade_index": 1, "status": "pending" },
{ "order_id": "def-456", "trade_index": 2, "status": "pending" },
{ "order_id": "ghi-789", "trade_index": 3, "status": "active" },
{ "order_id": "xyz-999", "trade_index": 4, "status": "dispute" }
{ "order_id": "ghi-789", "trade_index": 3, "status": "active" }
],
"disputes": [
{ "dispute_id": "dis-001", "order_id": "xyz-999", "trade_index": 4, "status": "initiated", "initiator": "seller" }
{ "dispute_id": "dis-001", "order_id": "xyz-999", "trade_index": 4, "status": "initiated", "initiator": "seller", "solver_pubkey": null },
{ "dispute_id": "dis-002", "order_id": "uvw-555", "trade_index": 5, "status": "in-progress", "initiator": "buyer", "solver_pubkey": "<Solver Pubkey>" }
]
}
}
Expand Down