From f57d559dc08bf4b59ddefe9416f7569f751f75dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Calder=C3=B3n?= Date: Thu, 27 Jun 2024 11:31:34 -0300 Subject: [PATCH 1/5] Proposal of a very simple spec for p2p events --- xx.md | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 xx.md diff --git a/xx.md b/xx.md new file mode 100644 index 0000000..2ab8fc4 --- /dev/null +++ b/xx.md @@ -0,0 +1,77 @@ +# NIP-XX + +## Peer-to-peer messages + +`draft` `optional` + +## Abstract + +Peer-to-peer (P2P) platforms have seen an upturn in recent years, while having more and more options is positive, in the specific case of p2p, having several options contributes to the liquidity split, meaning sometimes there's not enough assets available for trading. If we combine all these individual solutions into one big pool of orders, it will make them much more competitive compared to centralized systems, where a single authority controls the liquidity. + +This NIP defines a simple standard for peer-to-peer messages, which enables the creation of a big liquidity pool for all p2p platforms participating. + +## The event + +Events are [Parameterized Replaceable Events](https://github.com/nostr-protocol/nips/blob/master/01.md#kinds) and use `38383` as event kind, a p2p event look like this: + +```json +[ + "EVENT", + "RAND", + { + "id": "84fad0d29cb3529d789faeff2033e88fe157a48e071c6a5d1619928289420e31", + "pubkey": "dbe0b1be7aafd3cfba92d7463edbd4e33b2969f61bd554d37ac56f032e13355a", + "created_at": 1702548701, + "kind": 38383, + "tags": [ + ["d", "ede61c96-4c13-4519-bf3a-dcf7f1e9d842"], + ["k", "sell"], + ["f", "VES"], + ["s", "pending"], + ["amt", "0"], + ["fa", "100"], + ["pm", "face to face"], + ["premium", "1"], + [ + "rating", + "{\"total_reviews\":1,\"total_rating\":3.0,\"last_rating\":3,\"max_rate\":5,\"min_rate\":1}" + ], + ["network", "lightning"], + ["expiration", "1719391096"], + ["y", "mostrop2p"], + ["z", "order"] + ], + "content": "", + "sig": "7e8fe1eb644f33ff51d8805c02a0e1a6d034e6234eac50ef7a7e0dac68a0414f7910366204fa8217086f90eddaa37ded71e61f736d1838e37c0b73f6a16c4af2" + } +] +``` + +## Tags + +- `d` Order ID: A unique identifier for the order. +- `k` Order type: `sell` or `buy`. +- `f` Currency: The asset being traded, using the [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) standard. +- `s` Status: `pending`, `canceled`, `in-progress`, `success`. +- `amt` Amount: The amount of Bitcoin to be traded, the amount is defined in satoshis, if `0` means that the amount of satoshis will be obtained from a public API after the taker accepts the order. +- `fa` Fiat amount: The fiat amount being traded, for range orders two values are expected, the minimum and maximum amount. +- `pm` Payment method: The payment method used for the trade. +- `premium` Premium: The percentage of the premium the maker is willing to pay. +- `rating` Rating: The rating of the maker, this document does not define how the rating is calculated, it's up to the platform to define it. +- `n` Network: The network used for the trade, it can be `lightning`, `liquid`, `onchain`, etc. +- `expiration` Expiration: The expiration date of the order ([NIP-40](https://github.com/nostr-protocol/nips/blob/master/40.md)). +- `y` Platform: The platform that created the order. +- `z` Order type: `order`. + +## Implementations + +Currently implemented on the following platforms: + +- [Mostro](https://github.com/MostroP2P/mostro) +- [@lnp2pBot](https://github.com/lnp2pBot/bot) + +## References + +- [Mostro messages specification](https://mostro.network/messages/) +- [Messages specification for peer 2 peer NIP proposal](https://github.com/nostr-protocol/nips/blob/8250274a22f4882f621510df0054fd6167c10c9e/31001.md) +- [n3xB](https://github.com/nobu-maeda/n3xb) From df977f3874a98783633968ddd9e783b81e3c0ec1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Calder=C3=B3n?= Date: Thu, 27 Jun 2024 11:40:56 -0300 Subject: [PATCH 2/5] Add source tag --- xx.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/xx.md b/xx.md index 2ab8fc4..16a0893 100644 --- a/xx.md +++ b/xx.md @@ -36,9 +36,10 @@ Events are [Parameterized Replaceable Events](https://github.com/nostr-protocol/ "rating", "{\"total_reviews\":1,\"total_rating\":3.0,\"last_rating\":3,\"max_rate\":5,\"min_rate\":1}" ], + ["source", "https://t.me/p2plightning/xxxxxxx"], ["network", "lightning"], ["expiration", "1719391096"], - ["y", "mostrop2p"], + ["y", "lnp2pbot"], ["z", "order"] ], "content": "", @@ -57,6 +58,7 @@ Events are [Parameterized Replaceable Events](https://github.com/nostr-protocol/ - `fa` Fiat amount: The fiat amount being traded, for range orders two values are expected, the minimum and maximum amount. - `pm` Payment method: The payment method used for the trade. - `premium` Premium: The percentage of the premium the maker is willing to pay. +- `source` Source: The source of the order, it can be a URL that redirects to the order. - `rating` Rating: The rating of the maker, this document does not define how the rating is calculated, it's up to the platform to define it. - `n` Network: The network used for the trade, it can be `lightning`, `liquid`, `onchain`, etc. - `expiration` Expiration: The expiration date of the order ([NIP-40](https://github.com/nostr-protocol/nips/blob/master/40.md)). From d546936073db03e2187e3a0d1eb68e563d82201a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Calder=C3=B3n?= Date: Thu, 4 Jul 2024 12:07:59 -0300 Subject: [PATCH 3/5] Add more optional tags and small fixes --- xx.md | 46 ++++++++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/xx.md b/xx.md index 16a0893..0543e68 100644 --- a/xx.md +++ b/xx.md @@ -1,6 +1,6 @@ # NIP-XX -## Peer-to-peer messages +## Peer-to-peer Order events `draft` `optional` @@ -8,7 +8,7 @@ Peer-to-peer (P2P) platforms have seen an upturn in recent years, while having more and more options is positive, in the specific case of p2p, having several options contributes to the liquidity split, meaning sometimes there's not enough assets available for trading. If we combine all these individual solutions into one big pool of orders, it will make them much more competitive compared to centralized systems, where a single authority controls the liquidity. -This NIP defines a simple standard for peer-to-peer messages, which enables the creation of a big liquidity pool for all p2p platforms participating. +This NIP defines a simple standard for peer-to-peer order events, which enables the creation of a big liquidity pool for all p2p platforms participating. ## The event @@ -30,14 +30,18 @@ Events are [Parameterized Replaceable Events](https://github.com/nostr-protocol/ ["s", "pending"], ["amt", "0"], ["fa", "100"], - ["pm", "face to face"], + ["pm", "face to face", "bank transfer"], ["premium", "1"], [ "rating", "{\"total_reviews\":1,\"total_rating\":3.0,\"last_rating\":3,\"max_rate\":5,\"min_rate\":1}" ], ["source", "https://t.me/p2plightning/xxxxxxx"], - ["network", "lightning"], + ["network", "mainnet"], + ["layer", "lightning"], + ["name", "Nakamoto"], + ["g", ""], + ["bond", "0"], ["expiration", "1719391096"], ["y", "lnp2pbot"], ["z", "order"] @@ -50,20 +54,26 @@ Events are [Parameterized Replaceable Events](https://github.com/nostr-protocol/ ## Tags -- `d` Order ID: A unique identifier for the order. -- `k` Order type: `sell` or `buy`. -- `f` Currency: The asset being traded, using the [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) standard. -- `s` Status: `pending`, `canceled`, `in-progress`, `success`. -- `amt` Amount: The amount of Bitcoin to be traded, the amount is defined in satoshis, if `0` means that the amount of satoshis will be obtained from a public API after the taker accepts the order. -- `fa` Fiat amount: The fiat amount being traded, for range orders two values are expected, the minimum and maximum amount. -- `pm` Payment method: The payment method used for the trade. -- `premium` Premium: The percentage of the premium the maker is willing to pay. -- `source` Source: The source of the order, it can be a URL that redirects to the order. -- `rating` Rating: The rating of the maker, this document does not define how the rating is calculated, it's up to the platform to define it. -- `n` Network: The network used for the trade, it can be `lightning`, `liquid`, `onchain`, etc. -- `expiration` Expiration: The expiration date of the order ([NIP-40](https://github.com/nostr-protocol/nips/blob/master/40.md)). -- `y` Platform: The platform that created the order. -- `z` Order type: `order`. +- `d` < Order ID >: A unique identifier for the order. +- `k` < Order type >: `sell` or `buy`. +- `f` < Currency >: The asset being traded, using the [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) standard. +- `s` < Status >: `pending`, `canceled`, `in-progress`, `success`. +- `amt` < Amount >: The amount of Bitcoin to be traded, the amount is defined in satoshis, if `0` means that the amount of satoshis will be obtained from a public API after the taker accepts the order. +- `fa` < Fiat amount >: The fiat amount being traded, for range orders two values are expected, the minimum and maximum amount. +- `pm` < Payment method >: The payment method used for the trade, if the order has multiple payment methods, they should be separated by a comma. +- `premium` < Premium >: The percentage of the premium the maker is willing to pay. +- `source` [Source]: The source of the order, it can be a URL that redirects to the order. +- `rating` [Rating]: The rating of the maker, this document does not define how the rating is calculated, it's up to the platform to define it. +- `network` < Network >: The network used for the trade, it can be `mainnet`, `testnet`, `signet`, etc. +- `layer` < Layer >: The layer used for the trade, it can be `onchain`, `lightning`, `liquid`, etc. +- `name` [Name]: The name of the maker. +- `g` [Geohash]: The geohash of the operation, it can be useful in a face to face trade. +- `bond` [Bond]: The bond amount, the bond is a security deposit that both parties must pay. +- `expiration` < Expiration\>: The expiration date of the order ([NIP-40](https://github.com/nostr-protocol/nips/blob/master/40.md)). +- `y` < Platform >: The platform that created the order. +- `z` < Document >: `order`. + +Mandatory tags are enclosed with ``, optional tags are enclosed with `[tag]`. ## Implementations From f72a2f69ed93cf442e83bf9e7e16f6c06da40384 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Calder=C3=B3n?= Date: Mon, 4 Nov 2024 11:27:17 -0300 Subject: [PATCH 4/5] Add NIP number and update README --- xx.md => 100.md | 71 +++++++++++++++++++++++-------------------------- README.md | 2 ++ 2 files changed, 36 insertions(+), 37 deletions(-) rename xx.md => 100.md (69%) diff --git a/xx.md b/100.md similarity index 69% rename from xx.md rename to 100.md index 0543e68..8a7aac5 100644 --- a/xx.md +++ b/100.md @@ -1,4 +1,4 @@ -# NIP-XX +# NIP-100 ## Peer-to-peer Order events @@ -12,44 +12,40 @@ This NIP defines a simple standard for peer-to-peer order events, which enables ## The event -Events are [Parameterized Replaceable Events](https://github.com/nostr-protocol/nips/blob/master/01.md#kinds) and use `38383` as event kind, a p2p event look like this: +Events are [addressable events](https://github.com/nostr-protocol/nips/blob/master/01.md#kinds) and use `38383` as event kind, a p2p event look like this: ```json -[ - "EVENT", - "RAND", - { - "id": "84fad0d29cb3529d789faeff2033e88fe157a48e071c6a5d1619928289420e31", - "pubkey": "dbe0b1be7aafd3cfba92d7463edbd4e33b2969f61bd554d37ac56f032e13355a", - "created_at": 1702548701, - "kind": 38383, - "tags": [ - ["d", "ede61c96-4c13-4519-bf3a-dcf7f1e9d842"], - ["k", "sell"], - ["f", "VES"], - ["s", "pending"], - ["amt", "0"], - ["fa", "100"], - ["pm", "face to face", "bank transfer"], - ["premium", "1"], - [ - "rating", - "{\"total_reviews\":1,\"total_rating\":3.0,\"last_rating\":3,\"max_rate\":5,\"min_rate\":1}" - ], - ["source", "https://t.me/p2plightning/xxxxxxx"], - ["network", "mainnet"], - ["layer", "lightning"], - ["name", "Nakamoto"], - ["g", ""], - ["bond", "0"], - ["expiration", "1719391096"], - ["y", "lnp2pbot"], - ["z", "order"] +{ + "id": "84fad0d29cb3529d789faeff2033e88fe157a48e071c6a5d1619928289420e31", + "pubkey": "dbe0b1be7aafd3cfba92d7463edbd4e33b2969f61bd554d37ac56f032e13355a", + "created_at": 1702548701, + "kind": 38383, + "tags": [ + ["d", "ede61c96-4c13-4519-bf3a-dcf7f1e9d842"], + ["k", "sell"], + ["f", "VES"], + ["s", "pending"], + ["amt", "0"], + ["fa", "100"], + ["pm", "face to face", "bank transfer"], + ["premium", "1"], + [ + "rating", + "{\"total_reviews\":1,\"total_rating\":3.0,\"last_rating\":3,\"max_rate\":5,\"min_rate\":1}" ], - "content": "", - "sig": "7e8fe1eb644f33ff51d8805c02a0e1a6d034e6234eac50ef7a7e0dac68a0414f7910366204fa8217086f90eddaa37ded71e61f736d1838e37c0b73f6a16c4af2" - } -] + ["source", "https://t.me/p2plightning/xxxxxxx"], + ["network", "mainnet"], + ["layer", "lightning"], + ["name", "Nakamoto"], + ["g", ""], + ["bond", "0"], + ["expiration", "1719391096"], + ["y", "lnp2pbot"], + ["z", "order"] + ], + "content": "", + "sig": "7e8fe1eb644f33ff51d8805c02a0e1a6d034e6234eac50ef7a7e0dac68a0414f7910366204fa8217086f90eddaa37ded71e61f736d1838e37c0b73f6a16c4af2" +} ``` ## Tags @@ -81,9 +77,10 @@ Currently implemented on the following platforms: - [Mostro](https://github.com/MostroP2P/mostro) - [@lnp2pBot](https://github.com/lnp2pBot/bot) +- [Robosats](https://github.com/RoboSats/robosats/pull/1362) ## References -- [Mostro messages specification](https://mostro.network/messages/) +- [Mostro protocol specification](https://mostro.network/protocol/) - [Messages specification for peer 2 peer NIP proposal](https://github.com/nostr-protocol/nips/blob/8250274a22f4882f621510df0054fd6167c10c9e/31001.md) - [n3xB](https://github.com/nobu-maeda/n3xb) diff --git a/README.md b/README.md index 02773a5..2d7f71f 100644 --- a/README.md +++ b/README.md @@ -86,6 +86,7 @@ They exist to document what may be implemented by [Nostr](https://github.com/nos - [NIP-96: HTTP File Storage Integration](96.md) - [NIP-98: HTTP Auth](98.md) - [NIP-99: Classified Listings](99.md) +- [NIP-100: Peer-to-peer Order events](100.md) ## Event Kinds | kind | description | NIP | @@ -193,6 +194,7 @@ They exist to document what may be implemented by [Nostr](https://github.com/nos | `34236` | Short-form Portrait Video Event | [71](71.md) | | `34237` | Video View Event | [71](71.md) | | `34550` | Community Definition | [72](72.md) | +| `38383` | Peer-to-peer Order events | [100](100.md) | | `39000-9` | Group metadata events | [29](29.md) | [NUD: Custom Feeds]: https://wikifreedia.xyz/cip-01/97c70a44366a6535c1 From bff61dd310828758651389940dbcebb7fb9ef0ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Calder=C3=B3n?= Date: Mon, 4 Nov 2024 16:38:09 -0300 Subject: [PATCH 5/5] Changes NIP number --- 100.md => 69.md | 2 +- README.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) rename 100.md => 69.md (99%) diff --git a/100.md b/69.md similarity index 99% rename from 100.md rename to 69.md index 8a7aac5..330d6e5 100644 --- a/100.md +++ b/69.md @@ -1,4 +1,4 @@ -# NIP-100 +# NIP-69 ## Peer-to-peer Order events diff --git a/README.md b/README.md index 7c19bd5..32fbd78 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,7 @@ They exist to document what may be implemented by [Nostr](https://github.com/nos - [NIP-61: Nutzaps](61.md) - [NIP-64: Chess (PGN)](64.md) - [NIP-65: Relay List Metadata](65.md) +- [NIP-69: Peer-to-peer Order events](69.md) - [NIP-70: Protected Events](70.md) - [NIP-71: Video Events](71.md) - [NIP-72: Moderated Communities](72.md) @@ -91,7 +92,6 @@ They exist to document what may be implemented by [Nostr](https://github.com/nos - [NIP-96: HTTP File Storage Integration](96.md) - [NIP-98: HTTP Auth](98.md) - [NIP-99: Classified Listings](99.md) -- [NIP-100: Peer-to-peer Order events](100.md) ## Event Kinds @@ -218,7 +218,7 @@ They exist to document what may be implemented by [Nostr](https://github.com/nos | `34236` | Short-form Portrait Video Event | [71](71.md) | | `34550` | Community Definition | [72](72.md) | | `37375` | Cashu Wallet Event | [60](60.md) | -| `38383` | Peer-to-peer Order events | [100](100.md) | +| `38383` | Peer-to-peer Order events | [69](69.md) | | `39000-9` | Group metadata events | [29](29.md) | [NUD: Custom Feeds]: https://wikifreedia.xyz/cip-01/