|
| 1 | +# Request order details |
| 2 | + |
| 3 | +Clients can request detailed information for existing orders by sending a nip59 Gift wrap message with the action `orders`. This is useful for refreshing stale UI state or restoring a session from the mnemonic seed on a new device. |
| 4 | + |
| 5 | +## Request message |
| 6 | + |
| 7 | +The client sends a message where the payload object includes an `ids` array of order IDs. At least one ID must be provided, and Mostro may reject the request if the array exceeds its configured limits. |
| 8 | + |
| 9 | +```json |
| 10 | +{ |
| 11 | + "order": { |
| 12 | + "version": 1, |
| 13 | + "request_id": 8721, |
| 14 | + "action": "orders", |
| 15 | + "payload": { |
| 16 | + "ids": [ |
| 17 | + "c7dba9db-f13f-4c3f-a77f-3b82e43c2b1a", |
| 18 | + "751bc178-801a-4cc4-983c-68682e6fb6af" |
| 19 | + ] |
| 20 | + } |
| 21 | + } |
| 22 | +} |
| 23 | +``` |
| 24 | + |
| 25 | +Field: |
| 26 | +- `ids`: Array of order ids exactly as published in the order event `d` tag. |
| 27 | + |
| 28 | +The client only can request their own orders; mostrod will not provide information about any ID if it does not belong to the requesting party. |
| 29 | + |
| 30 | +## Mostro response |
| 31 | + |
| 32 | +Mostro replies with the same action and includes a structured payload describing each order that could be resolved, here is how the message look like: |
| 33 | + |
| 34 | +```json |
| 35 | +{ |
| 36 | + "order": { |
| 37 | + "version": 1, |
| 38 | + "request_id": 8721, |
| 39 | + "action": "orders", |
| 40 | + "payload": { |
| 41 | + "orders": [ |
| 42 | + { |
| 43 | + "order": { |
| 44 | + "id": "c7dba9db-f13f-4c3f-a77f-3b82e43c2b1a", |
| 45 | + "kind": "sell", |
| 46 | + "status": "active", |
| 47 | + "amount": 3307, |
| 48 | + "fiat_code": "ARS", |
| 49 | + "min_amount": 1000, |
| 50 | + "max_amount": 5000, |
| 51 | + "fiat_amount": 5000, |
| 52 | + "payment_method": "Mercado Pago,Lemon", |
| 53 | + "premium": 2, |
| 54 | + "buyer_trade_pubkey": "<trade pubkey>", |
| 55 | + "seller_trade_pubkey": "<trade pubkey>", |
| 56 | + "created_at": 1758889527, |
| 57 | + "expires_at": 1758975927 |
| 58 | + } |
| 59 | + }, |
| 60 | + { |
| 61 | + "order": { |
| 62 | + "id": "751bc178-801a-4cc4-983c-68682e6fb6af", |
| 63 | + "kind": "sell", |
| 64 | + "status": "fiat-sent", |
| 65 | + "amount": 1201, |
| 66 | + "fiat_code": "ARS", |
| 67 | + "min_amount": null, |
| 68 | + "max_amount": null, |
| 69 | + "fiat_amount": 2000, |
| 70 | + "payment_method": "MODO", |
| 71 | + "premium": 0, |
| 72 | + "buyer_trade_pubkey": "<trade pubkey>", |
| 73 | + "seller_trade_pubkey": "<trade pubkey>", |
| 74 | + "created_at": 1759168820, |
| 75 | + "expires_at": 1759255220 |
| 76 | + } |
| 77 | + }, |
| 78 | + ] |
| 79 | + } |
| 80 | + } |
| 81 | +} |
| 82 | +``` |
| 83 | + |
| 84 | +Orders that are missing or unauthorized for the requesting user are not listed in the orders array. |
| 85 | + |
| 86 | +## Limits and rate control |
| 87 | + |
| 88 | +Mostrod enforces per-request limits to protect the daemon. Common policies include a `max_orders_per_response` cap (for example, 20 orders) and a rolling request quota per pubkey. |
| 89 | + |
| 90 | +When a response is truncated because too many ids were requested, Mostrod returns only the first allowed ids. Clients should re-issue the call with the remaining ids after respecting the rate limits. |
| 91 | + |
| 92 | +When a user exceeds the allowed request rate, Mostrod can answer with an error action such as `too-many-requests`. Implementations should surface these conditions to the user and back off accordingly. |
0 commit comments