Skip to content

Commit

Permalink
More documentation (#143)
Browse files Browse the repository at this point in the history
* Dispute docs
* Cancel docs
  • Loading branch information
grunch authored Nov 3, 2023
1 parent 5c5e6b9 commit 91d4cc3
Show file tree
Hide file tree
Showing 2 changed files with 148 additions and 0 deletions.
93 changes: 93 additions & 0 deletions docs/cancel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Cancel 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](https://github.com/nostr-protocol/nips/blob/master/04.md), the `content` field of the event should be a base64-encoded, aes-256-cbc encrypted 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)

## Cancel a pending order

A use can cancel an Order created by himself and with status `Pending` sending action `Cancel`, the message will look like this:

```json
{
"version": "0",
"order_id": "ede61c96-4c13-4519-bf3a-dcf7f1e9d842",
"pubkey": "npub1qqqt938cer4dvlslg04zwwf66ts8r3txp6mv79cx2498pyuqx8uq0c7qkj",
"action": "Cancel",
"content": null
}
```

## Mostro response

Mostro will send a message with action `Cancel` confirming the order was canceled, here an example of the message:

```json
{
"version": "0",
"order_id": "ede61c96-4c13-4519-bf3a-dcf7f1e9d842",
"pubkey": null,
"action": "Cancel",
"content": null
}
```

## Cancel cooperatively

A user can cancel an `Active` order, but will need the counterparty to agree, let's look at an example where the seller initiates a cooperative cancellation:

```json
{
"version": "0",
"order_id": "ede61c96-4c13-4519-bf3a-dcf7f1e9d842",
"pubkey": null,
"action": "Cancel",
"content": null
}
```

Mostro will send this message to the seller:

```json
{
"version": "0",
"order_id": "ede61c96-4c13-4519-bf3a-dcf7f1e9d842",
"pubkey": null,
"action": "CooperativeCancelInitiatedByYou",
"content": null
}
```

And this message to the buyer:

```json
{
"version": "0",
"order_id": "ede61c96-4c13-4519-bf3a-dcf7f1e9d842",
"pubkey": null,
"action": "CooperativeCancelInitiatedByPeer",
"content": null
}
```

The buyer can accept the cooperative cancellation sending this message:

```json
{
"version": "0",
"order_id": "ede61c96-4c13-4519-bf3a-dcf7f1e9d842",
"pubkey": null,
"action": "Cancel",
"content": null
}
```
55 changes: 55 additions & 0 deletions docs/dispute.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Disputes

## 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](https://github.com/nostr-protocol/nips/blob/master/04.md), the `content` field of the event should be a base64-encoded, aes-256-cbc encrypted 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)

## Start a dispute

A use can start a dispute in an order with status `Pending` or `FiatSent` sending action `Dispute`, here is an example where the seller initiates a dispute:

```json
{
"version": "0",
"order_id": "ede61c96-4c13-4519-bf3a-dcf7f1e9d842",
"pubkey": "npub1qqqt938cer4dvlslg04zwwf66ts8r3txp6mv79cx2498pyuqx8uq0c7qkj",
"action": "Dispute",
"content": null
}
```

## Mostro response

Mostro will send this message to the seller:

```json
{
"version": "0",
"order_id": "ede61c96-4c13-4519-bf3a-dcf7f1e9d842",
"pubkey": null,
"action": "DisputeInitiatedByYou,",
"content": null
}
```

And here is the message to the buyer:

```json
{
"version": "0",
"order_id": "ede61c96-4c13-4519-bf3a-dcf7f1e9d842",
"pubkey": null,
"action": "DisputeInitiatedByPeer",
"content": null
}
```

0 comments on commit 91d4cc3

Please sign in to comment.