Skip to content

Commit

Permalink
Updates docs with new gift wrap implementation (#357)
Browse files Browse the repository at this point in the history
* Updates docs with new gift wrap implementation

* Finish gift wrap documentation
  • Loading branch information
grunch authored Sep 17, 2024
1 parent 8673ff5 commit 9ed2628
Show file tree
Hide file tree
Showing 19 changed files with 57 additions and 110 deletions.
2 changes: 0 additions & 2 deletions book/src/admin_add_solver.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ To add a solver the admin will need to send an `order` message to Mostro with ac
{
"order": {
"version": 1,
"pubkey": null,
"action": "admin-add-solver",
"content": {
"text_message": "npub1qqq884wtp2jn96lqhqlnarl4kk3rmvrc9z2nmrvqujx3m4l2ea5qd5d0fq"
Expand All @@ -29,7 +28,6 @@ Mostro will send this message to the admin:
{
"order": {
"version": 1,
"pubkey": null,
"action": "admin-add-solver",
"content": null
}
Expand Down
4 changes: 1 addition & 3 deletions book/src/admin_cancel_order.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# Cancel order

An admin can cancel an order, most of the time this is done when admin is solving a dispute, for this the admin will need to send an `order` message to Mostro with action `admin-cancel` with the `Id` of the order like this:
An admin can cancel an order, most of the time this is done when admin is solving a dispute, for this the admin will need to send an `order` message to Mostro with action `admin-cancel` with the `id` of the order like this:

```json
{
"order": {
"version": 1,
"id": "ede61c96-4c13-4519-bf3a-dcf7f1e9d842",
"pubkey": null,
"action": "admin-cancel",
"content": null
}
Expand All @@ -23,7 +22,6 @@ Mostro will send this message to the both parties buyer/seller and to the admin:
"order": {
"version": 1,
"id": "ede61c96-4c13-4519-bf3a-dcf7f1e9d842",
"pubkey": null,
"action": "admin-canceled",
"content": null
}
Expand Down
4 changes: 1 addition & 3 deletions book/src/admin_settle_order.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# Settle order

An admin can settle an order, most of the time this is done when admin is solving a dispute, for this the admin will need to send an `order` message to Mostro with action `admin-settle` with the `Id` of the order like this:
An admin can settle an order, most of the time this is done when admin is solving a dispute, for this the admin will need to send an `order` message to Mostro with action `admin-settle` with the `id` of the order like this:

```json
{
"order": {
"version": 1,
"id": "ede61c96-4c13-4519-bf3a-dcf7f1e9d842",
"pubkey": null,
"action": "admin-settle",
"content": null
}
Expand All @@ -23,7 +22,6 @@ Mostro will send this message to the both parties buyer/seller and to the admin:
"order": {
"version": 1,
"id": "ede61c96-4c13-4519-bf3a-dcf7f1e9d842",
"pubkey": null,
"action": "admin-settled",
"content": null
}
Expand Down
11 changes: 2 additions & 9 deletions book/src/cancel.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# Cancel Order

A user can cancel an Order created by himself and with status `pending` sending action `cancel`, the message content will look like this:
A user can cancel an order created by himself and with status `pending` sending action `cancel`, the rumor's content of the message will look like this:

```json
{
"order": {
"version": 1,
"id": "ede61c96-4c13-4519-bf3a-dcf7f1e9d842",
"pubkey": "00000ba40c5795451705bb9c165b3af93c846894d3062a9cd7fcba090eb3bf78",
"action": "cancel",
"content": null
}
Expand All @@ -16,14 +15,13 @@ A user can cancel an Order created by himself and with status `pending` sending

## Mostro response

Mostro will send a message with action `cancel` confirming the order was canceled, here an example of the message:
Mostro will send a message with action `cancel` confirming the order was canceled, here an example of rumor's content of the message:

```json
{
"order": {
"version": 1,
"id": "ede61c96-4c13-4519-bf3a-dcf7f1e9d842",
"pubkey": null,
"action": "canceled",
"content": null
}
Expand Down Expand Up @@ -71,7 +69,6 @@ A user can cancel an `active` order, but will need the counterparty to agree, le
"order": {
"version": 1,
"id": "ede61c96-4c13-4519-bf3a-dcf7f1e9d842",
"pubkey": null,
"action": "cancel",
"content": null
}
Expand All @@ -85,7 +82,6 @@ Mostro will send this message to the seller:
"order": {
"version": 1,
"id": "ede61c96-4c13-4519-bf3a-dcf7f1e9d842",
"pubkey": null,
"action": "cooperative-cancel-initiated-by-you",
"content": null
}
Expand All @@ -99,7 +95,6 @@ And this message to the buyer:
"order": {
"version": 1,
"id": "ede61c96-4c13-4519-bf3a-dcf7f1e9d842",
"pubkey": null,
"action": "cooperative-cancel-initiated-by-peer",
"content": null
}
Expand Down Expand Up @@ -142,7 +137,6 @@ The buyer can accept the cooperative cancellation sending this message:
"order": {
"version": 1,
"id": "ede61c96-4c13-4519-bf3a-dcf7f1e9d842",
"pubkey": null,
"action": "cancel",
"content": null
}
Expand All @@ -156,7 +150,6 @@ And Mostro will send this message to both parties:
"order": {
"version": 1,
"id": "ede61c96-4c13-4519-bf3a-dcf7f1e9d842",
"pubkey": null,
"action": "cooperative-cancel-accepted",
"content": null
}
Expand Down
9 changes: 2 additions & 7 deletions book/src/dispute.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ A use can start a dispute in an order with status `active` or `fiat-sent` sendin
"order": {
"version": 1,
"id": "ede61c96-4c13-4519-bf3a-dcf7f1e9d842",
"pubkey": "00000ba40c5795451705bb9c165b3af93c846894d3062a9cd7fcba090eb3bf78",
"action": "dispute",
"content": null
}
Expand All @@ -23,7 +22,6 @@ Mostro will send this message to the seller:
"order": {
"version": 1,
"id": "ede61c96-4c13-4519-bf3a-dcf7f1e9d842",
"pubkey": null,
"action": "dispute-initiated-by-you",
"content": {
"dispute": "efc75871-2568-40b9-a6ee-c382d4d6de01"
Expand All @@ -39,7 +37,6 @@ And here is the message to the buyer:
"order": {
"version": 1,
"id": "ede61c96-4c13-4519-bf3a-dcf7f1e9d842",
"pubkey": null,
"action": "dispute-initiated-by-peer",
"content": {
"dispute": "efc75871-2568-40b9-a6ee-c382d4d6de01"
Expand Down Expand Up @@ -82,21 +79,19 @@ Mostro admin will see the dispute and can take it using the dispute `Id` from `d
"dispute": {
"version": 1,
"id": "efc75871-2568-40b9-a6ee-c382d4d6de01",
"pubkey": null,
"action": "admin-take-dispute",
"content": null
}
}
```

Mostro will send a confirmation message to the admin with the Order details:
Mostro will send a confirmation message to the admin with the order details:

```json
{
"dispute": {
"version": 1,
"id": "efc75871-2568-40b9-a6ee-c382d4d6de01",
"pubkey": null,
"action": "admin-took-dispute",
"content": {
"order": {
Expand All @@ -118,7 +113,7 @@ Mostro will send a confirmation message to the admin with the Order details:
}
```

Also Mostro will broadcast a new parameterized replaceable dispute event to update the Dispute `status` to `in-progress`:
Also Mostro will broadcast a new parameterized replaceable dispute event to update the dispute `status` to `in-progress`:

```json
[
Expand Down
10 changes: 4 additions & 6 deletions book/src/fiatsent.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# Fiat sent

After the buyer sends the fiat money to the seller, the buyer should send a message to Mostro indicating that the fiat money was sent, the message will look like this:
After the buyer sends the fiat money to the seller, the buyer should send a message in a Gift wrap Nostr event to Mostro indicating that the fiat money was sent, the rumor's content would look like this:

```json
{
"order": {
"version": 1,
"id": "ede61c96-4c13-4519-bf3a-dcf7f1e9d842",
"pubkey": "0000147e939bef2b81c27af4c1b702c90c3843f7212a34934bff1e049b7f1427",
"action": "fiat-sent",
"content": null
}
Expand All @@ -19,9 +18,9 @@ The event to send to Mostro would look like this:
```json
{
"id": "cade205b849a872d74ba4d2a978135dbc05b4e5f483bb4403c42627dfd24f67d",
"kind": 4,
"kind": 1059,
"pubkey": "9a42ac72d6466a6dbe5b4b07a8717ee13e55abb6bdd810ea9c321c9a32ee837b",
"content": "base64-encoded-aes-256-cbc-encrypted-JSON-serialized-string",
"content": "sealed-rumor-content",
"tags": [
["p", "dbe0b1be7aafd3cfba92d7463edbd4e33b2969f61bd554d37ac56f032e13355a"]
],
Expand All @@ -32,14 +31,13 @@ The event to send to Mostro would look like this:

## Mostro response

Mostro send a messages to both parties confirming `fiat-sent` action and sending again the counterpart pubkey, here an example of the message to the buyer:
Mostro send messages to both parties confirming `fiat-sent` action and sending again the counterpart pubkey, here an example of the message to the buyer:

```json
{
"order": {
"version": 1,
"id": "ede61c96-4c13-4519-bf3a-dcf7f1e9d842",
"pubkey": "0000147e939bef2b81c27af4c1b702c90c3843f7212a34934bff1e049b7f1427",
"action": "fiat-sent-ok",
"content": {
"Peer": {
Expand Down
14 changes: 6 additions & 8 deletions book/src/new_buy_order.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# Creating a new buy order

To create a new buy order the user should send a Nostr event kind 4 (an encrypted message) to Mostro with the following content:
To create a new buy order the user should send a Gift wrap Nostr event to Mostro with the following rumor's content:

```json
{
"order": {
"version": 1,
"pubkey": "0000147e939bef2b81c27af4c1b702c90c3843f7212a34934bff1e049b7f1427", // Buyer's real pubkey
"action": "new-order",
"content": {
"order": {
Expand All @@ -29,9 +28,9 @@ The nostr event will look like this:
```json
{
"id": "cade205b849a872d74ba4d2a978135dbc05b4e5f483bb4403c42627dfd24f67d",
"kind": 4,
"kind": 1059,
"pubkey": "9a42ac72d6466a6dbe5b4b07a8717ee13e55abb6bdd810ea9c321c9a32ee837b", // Buyer's ephemeral pubkey
"content": "base64-encoded-aes-256-cbc-encrypted-JSON-serialized-string",
"content": "sealed-rumor-content",
"tags": [
["p", "dbe0b1be7aafd3cfba92d7463edbd4e33b2969f61bd554d37ac56f032e13355a"] // Mostro's pubkey
],
Expand All @@ -42,18 +41,17 @@ The nostr event will look like this:

## Confirmation message

Mostro will send back a nip04 event as a confirmation message to the user like the following:
Mostro will send back a nip59 event as a confirmation message to the user like the following:

```json
{
"order": {
"version": 1,
"id": "ede61c96-4c13-4519-bf3a-dcf7f1e9d842",
"pubkey": "0000147e939bef2b81c27af4c1b702c90c3843f7212a34934bff1e049b7f1427",
"content": {
"order": {
"id": "ede61c96-4c13-4519-bf3a-dcf7f1e9d842",
"kind": "sell",
"kind": "buy",
"status": "pending",
"amount": 0,
"fiat_code": "VES",
Expand Down Expand Up @@ -83,7 +81,7 @@ Mostro publishes this order as an event kind `38383` with status `pending`:
"kind": 38383,
"tags": [
["d", "ede61c96-4c13-4519-bf3a-dcf7f1e9d842"],
["k", "sell"],
["k", "buy"],
["f", "VES"],
["s", "pending"],
["amt", "0"],
Expand Down
14 changes: 6 additions & 8 deletions book/src/new_buy_order_ln_address.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# Creating a new order

Creating buy order with a [lightning address](https://github.com/andrerfneves/lightning-address) would make the process way faster and easy going, to acomplish the buyer should send a Nostr event kind 4 (an encrypted message) to Mostro with the following content:
Creating buy order with a [lightning address](https://github.com/andrerfneves/lightning-address) would make the process way faster and easy going, to acomplish the buyer should send a Gift wrap Nostr event to Mostro with the following rumor's content:

```json
{
"order": {
"version": 1,
"pubkey": "0000147e939bef2b81c27af4c1b702c90c3843f7212a34934bff1e049b7f1427", // Buyer's real pubkey
"action": "new-order",
"content": {
"order": {
Expand All @@ -30,9 +29,9 @@ The nostr event will look like this:
```json
{
"id": "cade205b849a872d74ba4d2a978135dbc05b4e5f483bb4403c42627dfd24f67d",
"kind": 4,
"kind": 1059,
"pubkey": "9a42ac72d6466a6dbe5b4b07a8717ee13e55abb6bdd810ea9c321c9a32ee837b", // Buyer's ephemeral pubkey
"content": "base64-encoded-aes-256-cbc-encrypted-JSON-serialized-string",
"content": "sealed-rumor-content",
"tags": [
["p", "dbe0b1be7aafd3cfba92d7463edbd4e33b2969f61bd554d37ac56f032e13355a"] // Mostro's pubkey
],
Expand All @@ -43,18 +42,17 @@ The nostr event will look like this:

## Confirmation message

Mostro will send back a nip04 event as a confirmation message to the user like the following:
Mostro will send back a nip59 event as a confirmation message to the user like the following:

```json
{
"order": {
"version": 1,
"id": "ede61c96-4c13-4519-bf3a-dcf7f1e9d842",
"pubkey": "0000147e939bef2b81c27af4c1b702c90c3843f7212a34934bff1e049b7f1427",
"content": {
"order": {
"id": "ede61c96-4c13-4519-bf3a-dcf7f1e9d842",
"kind": "sell",
"kind": "buy",
"status": "pending",
"amount": 0,
"fiat_code": "VES",
Expand Down Expand Up @@ -84,7 +82,7 @@ Mostro publishes this order as an event kind `38383` with status `pending`:
"kind": 38383,
"tags": [
["d", "ede61c96-4c13-4519-bf3a-dcf7f1e9d842"],
["k", "sell"],
["k", "buy"],
["f", "VES"],
["s", "pending"],
["amt", "0"],
Expand Down
10 changes: 4 additions & 6 deletions book/src/new_sell_order.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# Creating a new sell order

To create a new sell order the user should send a Nostr event kind 4 (an encrypted message) to Mostro with the following content:
To create a new sell order the user should send a Gift wrap Nostr event to Mostro, the rumor event should have the following rumor's content:

```json
{
"order": {
"version": 1,
"pubkey": "00000ba40c5795451705bb9c165b3af93c846894d3062a9cd7fcba090eb3bf78", // Seller's real pubkey
"action": "new-order",
"content": {
"order": {
Expand All @@ -31,17 +30,16 @@ 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
- pubkey: Real user's npub, 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

The event to send to Mostro would look like this:

```json
{
"id": "cade205b849a872d74ba4d2a978135dbc05b4e5f483bb4403c42627dfd24f67d",
"kind": 4,
"kind": 1059,
"pubkey": "1f5bb148a25bca31506594722e746b10acf2641a12725b12072dcbc46ade544d", // Seller's ephemeral pubkey
"content": "base64-encoded-aes-256-cbc-encrypted-JSON-serialized-string",
"content": "sealed-rumor-content",
"tags": [
["p", "dbe0b1be7aafd3cfba92d7463edbd4e33b2969f61bd554d37ac56f032e13355a"] // Mostro's pubkey
],
Expand All @@ -52,7 +50,7 @@ The event to send to Mostro would look like this:

## Confirmation message

Mostro will send back a nip04 event as a confirmation message to the user like the following:
Mostro will send back a nip59 event as a confirmation message to the user like the following (unencrypted rumor's content example):

```json
{
Expand Down
Loading

0 comments on commit 9ed2628

Please sign in to comment.