Skip to content

Commit eb224f2

Browse files
committed
Add restore session
1 parent 5fd5f71 commit eb224f2

2 files changed

Lines changed: 94 additions & 0 deletions

File tree

src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
- [Admin Settle order](./admin_settle_order.md)
2525
- [Admin Cancel order](./admin_cancel_order.md)
2626
- [Admin Add Solver](./admin_add_solver.md)
27+
- [Restore session](./restore_session.md)
2728
- [Actions](./actions.md)
2829
- [Message suggestions for actions](./message_suggestions_for_actions.md)
2930
- [P2P Order event. NIP-69](./order_event.md)

src/restore_session.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Restore Session
2+
3+
To restore a session from the mnemonic seed on a new device (e.g., moving from mobile to desktop), the client sends a `restore-session` message. Mostro will respond with the relevant orders and disputes so the client can rebuild the session state using the same `trade_index` values.
4+
5+
## Request
6+
7+
Client sends a Gift wrap Nostr event to Mostro with the following rumor's content:
8+
9+
```json
10+
{
11+
"order": {
12+
"version": 1,
13+
"action": "restore-session",
14+
"payload": null
15+
}
16+
}
17+
```
18+
19+
## Response
20+
21+
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:
22+
23+
```json
24+
{
25+
"order": {
26+
"version": 1,
27+
"action": "restore-session",
28+
"payload": {
29+
"orders": [
30+
{
31+
"id": "<Order Id>",
32+
"trade_index": 1,
33+
"status": "pending"
34+
},
35+
{
36+
"id": "<Order Id>",
37+
"trade_index": 2,
38+
"status": "active"
39+
},
40+
{
41+
"id": "<Order Id>",
42+
"trade_index": 3,
43+
"status": "fiat-sent"
44+
}
45+
],
46+
"disputes": [
47+
{
48+
"dispute_id": "<Dispute Id>",
49+
"order_id": "<Order Id>",
50+
"trade_index": 4,
51+
"status": "initiated"
52+
}
53+
]
54+
}
55+
}
56+
}
57+
```
58+
59+
### Fields
60+
61+
* `orders`: An array of active or ongoing orders with their `id`, `trade_index`, and current `status`.
62+
* `disputes`: An array of ongoing disputes with `dispute_id`, the associated `order_id`, and `trade_index`.
63+
64+
## Example Use Case
65+
66+
A user has the following:
67+
68+
* Two `pending` orders (trade index 1 and 2)
69+
* One `active` order (trade index 3)
70+
* One active dispute (trade index 4)
71+
72+
When switching to desktop, after restoring the mnemonic, the client sends `restore-session` and receives:
73+
74+
```json
75+
{
76+
"order": {
77+
"version": 1,
78+
"action": "restore-session",
79+
"payload": {
80+
"orders": [
81+
{ "id": "abc-123", "trade_index": 1, "status": "pending" },
82+
{ "id": "def-456", "trade_index": 2, "status": "pending" },
83+
{ "id": "ghi-789", "trade_index": 3, "status": "active" },
84+
{ "id": "xyz-999", "trade_index": 4, "status": "dispute" }
85+
],
86+
"disputes": [
87+
{ "dispute_id": "dis-001", "order_id": "xyz-999", "trade_index": 4, "status": "initiated" }
88+
]
89+
}
90+
}
91+
}
92+
```
93+

0 commit comments

Comments
 (0)