-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
172 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# Creating a new order | ||
|
||
## Overview | ||
|
||
All Mostro messages are [Parameterized Replaceable Events](https://github.com/nostr-protocol/nips/blob/master/01.md#kinds) and use `30078` as event `kind`, a list of standard event kinds can be found [here](https://github.com/nostr-protocol/nips#event-kinds) | ||
|
||
## Communication between users and Mostro | ||
|
||
All messages from/to Mostro should be a Nostr event kind 4, the content of the event should be a JSON-serialized string (with no white space or line breaks) of the following structure: | ||
|
||
- `version` | ||
- `order_id` (optional) | ||
- `pubkey` (optional) | ||
- `action` (https://docs.rs/mostro-core/latest/mostro_core/enum.Action.html) | ||
- `content` (optional https://docs.rs/mostro-core/latest/mostro_core/enum.Content.html) | ||
|
||
## New order | ||
|
||
To create a new sell order the user should send a Nostr event kind 4 to Mostro with the following content: | ||
|
||
```json | ||
{ | ||
"version": "0", | ||
"pubkey": "npub1qqq...", | ||
"action": "Order", | ||
"content": { | ||
"Order": { | ||
"kind": "Sell", | ||
"status": "Pending", | ||
"amount": 0, | ||
"fiat_code": "VES", | ||
"fiat_amount": 100, | ||
"payment_method": "face to face", | ||
"premium": 1, | ||
"master_seller_pubkey": "npub1qqq...", | ||
"created_at": 0 | ||
} | ||
} | ||
} | ||
``` | ||
|
||
Let's explain some of the fields: | ||
|
||
- kind: `Sell` or `Buy` | ||
- status: Is always `Pending` when creating a new order | ||
- amount: 0 for when we want to sell with at market price, otherwise the amount in satoshis | ||
- master_seller_pubkey: Real user's pubkey, we use this when the message was sent from an ephemeral key | ||
- created_at: No need to send the correct unix timestamp, Mostro will replace it with the current time | ||
|
||
## Confirmation message | ||
|
||
Mostro will send back a confirmation message to the user like the following: | ||
|
||
```json | ||
{ | ||
"version": "0", | ||
"order_id": "ede61c96-4c13-4519-bf3a-dcf7f1e9d842", | ||
"pubkey": null, | ||
"action": "Order", | ||
"content": { | ||
"Order": { | ||
"id": "ede61c96-4c13-4519-bf3a-dcf7f1e9d842", | ||
"kind": "Sell", | ||
"status": "Pending", | ||
"amount": 0, | ||
"fiat_code": "VES", | ||
"fiat_amount": 100, | ||
"payment_method": "face to face", | ||
"premium": 1, | ||
"created_at": 1698870173 | ||
} | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# Take a sell order | ||
|
||
## Overview | ||
|
||
All Mostro messages are [Parameterized Replaceable Events](https://github.com/nostr-protocol/nips/blob/master/01.md#kinds) and use `30078` as event `kind`, a list of standard event kinds can be found [here](https://github.com/nostr-protocol/nips#event-kinds) | ||
|
||
## Communication between users and Mostro | ||
|
||
All messages from/to Mostro should be a Nostr event kind 4, the content of the event should be a JSON-serialized string (with no white space or line breaks) of the following structure: | ||
|
||
- `version` | ||
- `order_id` (optional) | ||
- `pubkey` (optional) | ||
- `action` (https://docs.rs/mostro-core/latest/mostro_core/enum.Action.html) | ||
- `content` (optional https://docs.rs/mostro-core/latest/mostro_core/enum.Content.html) | ||
|
||
## Taking a sell order | ||
|
||
To take a new sell order the user should send a Nostr event kind 4 to Mostro with the following content: | ||
|
||
```json | ||
{ | ||
"version": "0", | ||
"pubkey": "npub1qqq...", | ||
"order_id": "68e373ef-898b-4312-9f49-dfc50404e3b2", | ||
"action": "TakeSell", | ||
"content": null | ||
} | ||
``` | ||
|
||
## Mostro response | ||
|
||
In order to continue the buyer needs to send a lightning network invoice to Mostro, if the amount of the order is `0`, Mostro will need to calculate the amount of sats of this order, then Mostro will send back a message asking for a LN invoice indicating the correct amount of sats that the invoice should have: | ||
|
||
```json | ||
{ | ||
"version": "0", | ||
"order_id": "68e373ef-898b-4312-9f49-dfc50404e3b2", | ||
"pubkey": null, | ||
"action": "AddInvoice", | ||
"content": { | ||
"SmallOrder": { | ||
"id": "68e373ef-898b-4312-9f49-dfc50404e3b2", | ||
"amount": 7851, | ||
"fiat_code": "VES", | ||
"fiat_amount": 100, | ||
"payment_method": "face to face", | ||
"premium": 1, | ||
"buyer_pubkey": null, | ||
"seller_pubkey": null | ||
} | ||
} | ||
} | ||
``` | ||
|
||
## Buyer sends LN invoice | ||
|
||
```json | ||
{ | ||
"version": "0", | ||
"order_id": "ede61c96-4c13-4519-bf3a-dcf7f1e9d842", | ||
"pubkey": null, | ||
"action": "TakeSell", | ||
"content": { | ||
"PaymentRequest": [ | ||
null, | ||
"lnbcrt32680n1pj59wmepp50677g8tffdqa2p8882y0x6newny5vtz0hjuyngdwv226nanv4uzsdqqcqzzsxqyz5vqsp5skn973360gp4yhlpmefwvul5hs58lkkl3u3ujvt57elmp4zugp4q9qyyssqw4nzlr72w28k4waycf27qvgzc9sp79sqlw83j56txltz4va44j7jda23ydcujj9y5k6k0rn5ms84w8wmcmcyk5g3mhpqepf7envhdccp72nz6e" | ||
] | ||
} | ||
} | ||
``` | ||
|
||
## Mostro response | ||
|
||
```json | ||
{ | ||
"version": "0", | ||
"order_id": "ede61c96-4c13-4519-bf3a-dcf7f1e9d842", | ||
"pubkey": null, | ||
"action": "WaitingSellerToPay", | ||
"content": null | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters