Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

up #5

Merged
merged 41 commits into from
Oct 7, 2024
Merged

up #5

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
70f1be5
Polls On Nostr
abhay-raizada Jun 25, 2024
f6b0842
Clarify what happens when a duplicate subscription is sent, remove CL…
Jun 28, 2024
21587e2
Finalize Draft
abhay-raizada Jul 5, 2024
c258875
Remove settings, fine tuning
abhay-raizada Jul 16, 2024
24e97c2
Merge pull request #1333 from coracle-social/clarify-nip01
staab Aug 31, 2024
1002104
nip44: clarify ecdh hashing
paulmillr Aug 31, 2024
be17e5d
Clarify function name in libsecp256k1
paulmillr Sep 1, 2024
d9eb17c
NIP-65: add links to outbox model articles
AsaiToshiya Sep 2, 2024
14ec14d
Missing events added to README, including NKBIP-01 and NKBIP-02 (#1464)
SilberWitch Sep 3, 2024
b4a2561
style: fix header styles in same format
kehiy Sep 2, 2024
a928d11
Merge pull request #1466 from paulmillr/patch-2
vitorpamplona Sep 3, 2024
378dfaa
nip54: remove markdown leftovers.
fiatjaf Sep 3, 2024
e655247
format(all): json formatting
kehiy Sep 3, 2024
c8dc1ea
Update 96.md
kehiy Sep 3, 2024
c02b161
Merge pull request #1477 from kehiy/jsonc
staab Sep 3, 2024
7edd3d2
README: update kinds table
AsaiToshiya Sep 9, 2024
e7eb776
Revert example code update
Sep 9, 2024
c343175
Update 10.md
ZigBalthazar Sep 10, 2024
97a4244
Merge pull request #1487 from ZigBalthazar/patch-1
staab Sep 10, 2024
d8ab984
make *.md linguist detectable.
kehiy Sep 11, 2024
8a427ea
Merge pull request #1488 from kehiy/md
staab Sep 11, 2024
37a02e8
custom emojis in reactions (#1492)
ZigBalthazar Sep 12, 2024
efcc869
remove this annoying file.
fiatjaf Sep 13, 2024
4bf0c01
Merge pull request #1346 from abhay-raizada/nostr-polls
fiatjaf Sep 17, 2024
d534bad
renumber polls NIP to 88.
fiatjaf Sep 17, 2024
3d8bf68
NIP-88: make poll response a parameterized replaceable event
alexgleason Sep 17, 2024
2baf7c8
Merge pull request #1501 from alexgleason/polls-replaceable
alexgleason Sep 17, 2024
6cd598d
remove NIP-88 polls temporarily.
fiatjaf Sep 17, 2024
ff39a11
Merge pull request #1469 from AsaiToshiya/AsaiToshiya-patch-27
AsaiToshiya Sep 18, 2024
79786bb
Expand External Content IDs
MerryOscar Sep 20, 2024
ea36ec9
Add `subject` and `t` tags to git issues (#1446)
dluvian Sep 20, 2024
d82f68a
update link to blossom on README.
fiatjaf Sep 21, 2024
4e73e94
fix typo on nip96 (#1511)
Spl0itable Sep 22, 2024
4438b89
Merge pull request #1508 from MerryOscar/expand-external-content-ids
staab Sep 25, 2024
a736e62
complete renaming to "addressable" events.
fiatjaf Sep 28, 2024
ce2234e
Clarify tag filters
Sep 30, 2024
e830a73
Merge pull request #1523 from coracle-social/clarify-filters
staab Sep 30, 2024
7bb8997
fix some info of nip55 to be same as other nips
haorendashu Jul 2, 2024
db13d12
Add Corny Chat Slide Set and Link Set kinds (#1152)
vicariousdrama Oct 7, 2024
10c112d
NIP-23, NIP-99: remove NIP-12 mention
AsaiToshiya Oct 7, 2024
23ef4aa
Merge pull request #1527 from AsaiToshiya/remove-nip12-mention
staab Oct 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions 01.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ This NIP defines 3 standard tags that can be used across all event kinds with th

- The `e` tag, used to refer to an event: `["e", <32-bytes lowercase hex of the id of another event>, <recommended relay URL, optional>]`
- The `p` tag, used to refer to another user: `["p", <32-bytes lowercase hex of a pubkey>, <recommended relay URL, optional>]`
- The `a` tag, used to refer to a (maybe parameterized) replaceable event
- The `a` tag, used to refer to an addressable or replaceable event
- for an addressable event: `["a", <kind integer>:<32-bytes lowercase hex of a pubkey>:<d tag value>, <recommended relay URL, optional>]`
- for a normal replaceable event: `["a", <kind integer>:<32-bytes lowercase hex of a pubkey>:, <recommended relay URL, optional>]`

As a convention, all single-letter (only english alphabet letters: a-z, A-Z) key tags are expected to be indexed by relays, such that it is possible, for example, to query or subscribe to events that reference the event `"5c83da77af1dec6d7289834998ad7aafbd9e2191396d75ec3cc27f5a77226f36"` by using the `{"#e": ["5c83da77af1dec6d7289834998ad7aafbd9e2191396d75ec3cc27f5a77226f36"]}` filter.
As a convention, all single-letter (only english alphabet letters: a-z, A-Z) key tags are expected to be indexed by relays, such that it is possible, for example, to query or subscribe to events that reference the event `"5c83da77af1dec6d7289834998ad7aafbd9e2191396d75ec3cc27f5a77226f36"` by using the `{"#e": ["5c83da77af1dec6d7289834998ad7aafbd9e2191396d75ec3cc27f5a77226f36"]}` filter. Only the first value in any given tag is indexed.

### Kinds

Expand All @@ -95,7 +95,7 @@ And also a convention for kind ranges that allow for easier experimentation and
- for kind `n` such that `1000 <= n < 10000 || 4 <= n < 45 || n == 1 || n == 2`, events are **regular**, which means they're all expected to be stored by relays.
- for kind `n` such that `10000 <= n < 20000 || n == 0 || n == 3`, events are **replaceable**, which means that, for each combination of `pubkey` and `kind`, only the latest event MUST be stored by relays, older versions MAY be discarded.
- for kind `n` such that `20000 <= n < 30000`, events are **ephemeral**, which means they are not expected to be stored by relays.
- for kind `n` such that `30000 <= n < 40000`, events are **parameterized replaceable**, which means that, for each combination of `pubkey`, `kind` and the `d` tag's first value, only the latest event MUST be stored by relays, older versions MAY be discarded.
- for kind `n` such that `30000 <= n < 40000`, events are **addressable** by their `kind`, `pubkey` and `d` tag value -- which means that, for each combination of `kind`, `pubkey` and the `d` tag value, only the latest event MUST be stored by relays, older versions MAY be discarded.

In case of replaceable events with the same timestamp, the event with the lowest id (first in lexical order) should be retained, and the other discarded.

Expand Down Expand Up @@ -131,7 +131,7 @@ Clients can send 3 types of messages, which must be JSON arrays, according to th
}
```

Upon receiving a `REQ` message, the relay SHOULD query its internal database and return events that match the filter, then store that filter and send again all future events it receives to that same websocket until the websocket is closed. The `CLOSE` event is received with the same `<subscription_id>` or a new `REQ` is sent using the same `<subscription_id>`, in which case relay MUST overwrite the previous subscription.
Upon receiving a `REQ` message, the relay SHOULD return events that match the filter. Any new events it receives SHOULD be sent to that same websocket until the connection is closed, a `CLOSE` event is received with the same `<subscription_id>`, or a new `REQ` is sent using the same `<subscription_id>` (in which case a new subscription is created, replacing the old one).

Filter attributes containing lists (`ids`, `authors`, `kinds` and tag filters like `#e`) are JSON arrays with one or more values. At least one of the arrays' values must match the relevant field in an event for the condition to be considered a match. For scalar event attributes such as `authors` and `kind`, the attribute from the event must be contained in the filter list. In the case of tag attributes such as `#e`, for which an event may have multiple values, the event and filter condition values must have at least one item in common.

Expand Down Expand Up @@ -169,7 +169,6 @@ This NIP defines no rules for how `NOTICE` messages should be sent or treated.
* `["OK", "b1a649ebe8...", false, "pow: difficulty 26 is less than 30"]`
* `["OK", "b1a649ebe8...", false, "error: could not connect to the database"]`
- `CLOSED` messages MUST be sent in response to a `REQ` when the relay refuses to fulfill it. It can also be sent when a relay decides to kill a subscription on its side before a client has disconnected or sent a `CLOSE`. This message uses the same pattern of `OK` messages with the machine-readable prefix and human-readable message. Some examples:
* `["CLOSED", "sub1", "duplicate: sub1 already opened"]`
* `["CLOSED", "sub1", "unsupported: filter contains unknown elements"]`
* `["CLOSED", "sub1", "error: could not connect to the database"]`
* `["CLOSED", "sub1", "error: shutting down idle subscription"]`
Expand Down
4 changes: 2 additions & 2 deletions 02.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The `.content` is not used.

For example:

```json
```jsonc
{
"kind": 3,
"tags": [
Expand All @@ -23,7 +23,7 @@ For example:
["p", "612ae..e610f", "ws://carolrelay.com/ws", "carol"]
],
"content": "",
...other fields
// other fields...
}
```

Expand Down
4 changes: 2 additions & 2 deletions 05.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ The result should be a JSON document object with a key `"names"` that should the

If a client sees an event like this:

```json
```jsonc
{
"pubkey": "b0635d6a9851d3aed0cd6c495b282167acf761729078d975fc341b22650b07b9",
"kind": 0,
"content": "{\"name\": \"bob\", \"nip05\": \"bob@example.com\"}"
...
// other fields...
}
```

Expand Down
6 changes: 3 additions & 3 deletions 09.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ NIP-09
======

Event Deletion Request
--------------
----------------------

`draft` `optional`

Expand All @@ -12,7 +12,7 @@ The event's `content` field MAY contain a text note describing the reason for th

For example:

```
```jsonc
{
"kind": 5,
"pubkey": <32-bytes hex-encoded public key of the event creator>,
Expand All @@ -24,7 +24,7 @@ For example:
["k", "30023"]
],
"content": "these posts were published by accident",
...other fields
// other fields...
}
```

Expand Down
6 changes: 3 additions & 3 deletions 10.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ NIP-10
======


On "e" and "p" tags in Text Events (kind 1).
--------------------------------------------
On "e" and "p" tags in Text Events (kind 1)
-------------------------------------------

`draft` `optional`

Expand Down Expand Up @@ -43,7 +43,7 @@ They are citing from this event. `root-id` and `reply-id` are as above.
Where:

* `<event-id>` is the id of the event being referenced.
* `<relay-url>` is the URL of a recommended relay associated with the reference. Clients SHOULD add a valid `<relay-URL>` field, but may instead leave it as `""`.
* `<relay-url>` is the URL of a recommended relay associated with the reference. Clients SHOULD add a valid `<relay-url>` field, but may instead leave it as `""`.
* `<marker>` is optional and if present is one of `"reply"`, `"root"`, or `"mention"`.
* `<pubkey>` is optional, SHOULD be the pubkey of the author of the referenced event

Expand Down
32 changes: 18 additions & 14 deletions 11.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ NIP-11
======

Relay Information Document
---------------------------
--------------------------

`draft` `optional`

Expand Down Expand Up @@ -66,7 +66,7 @@ These are limitations imposed by the relay on clients. Your client
should expect that requests which exceed these *practical* limitations
are rejected or fail immediately.

```json
```jsonc
{
"limitation": {
"max_message_length": 16384,
Expand All @@ -83,7 +83,7 @@ are rejected or fail immediately.
"created_at_lower_limit": 31536000,
"created_at_upper_limit": 3
},
...
// other fields...
}
```

Expand Down Expand Up @@ -146,14 +146,15 @@ Retention times are given in seconds, with `null` indicating infinity.
If zero is provided, this means the event will not be stored at
all, and preferably an error will be provided when those are received.

```json
```jsonc
{
"retention": [
{"kinds": [0, 1, [5, 7], [40, 49]], "time": 3600},
{"kinds": [[40000, 49999]], "time": 100},
{"kinds": [[30000, 39999]], "count": 1000},
{"time": 3600, "count": 10000}
]
],
// other fields...
}
```

Expand All @@ -172,7 +173,7 @@ There is no need to specify retention times for _ephemeral events_ since they ar
### Content Limitations

Some relays may be governed by the arbitrary laws of a nation state. This
may limit what content can be stored in cleartext on those relays. All
may limit what content can be stored in clear-text on those relays. All
clients are encouraged to use encryption to work around this limitation.

It is not possible to describe the limitations of each country's laws
Expand All @@ -183,13 +184,13 @@ countries' laws might end up being enforced on them, and then
indirectly on their users' content.

Users should be able to avoid relays in countries they don't like,
and/or select relays in more favourable zones. Exposing this
and/or select relays in more favorable zones. Exposing this
flexibility is up to the client software.

```json
```jsonc
{
"relay_countries": [ "CA", "US" ],
...
// other fields...
}
```

Expand All @@ -208,12 +209,12 @@ local community. This would encourage users to follow the global
feed on that relay, in addition to their usual individual follows.
To support this goal, relays MAY specify some of the following values.

```json
```jsonc
{
"language_tags": ["en", "en-419"],
"tags": ["sfw-only", "bitcoin-only", "anime"],
"posting_policy": "https://example.com/posting-policy.html",
...
// other fields...
}
```

Expand Down Expand Up @@ -260,20 +261,22 @@ Relays that require payments may want to expose their fee schedules.

A URL pointing to an image to be used as an icon for the relay. Recommended to be squared in shape.

```json
```jsonc
{
"icon": "https://nostr.build/i/53866b44135a27d624e99c6165cabd76ac8f72797209700acb189fce75021f47.jpg",
...
// other fields...
}
```

### Examples

As of 2 May 2023 the following command provided these results:

```bash
$ curl -H "Accept: application/nostr+json" https://eden.nostr.land | jq
```
~> curl -H "Accept: application/nostr+json" https://eden.nostr.land | jq

```json
{
"description": "nostr.land family of relays (us-or-01)",
"name": "nostr.land",
Expand Down Expand Up @@ -312,3 +315,4 @@ As of 2 May 2023 the following command provided these results:
]
},
}
```
47 changes: 20 additions & 27 deletions 13.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,37 +48,30 @@ Validating
Here is some reference C code for calculating the difficulty (aka number of leading zero bits) in a nostr event id:

```c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int countLeadingZeroes(const char *hex) {
int count = 0;

for (int i = 0; i < strlen(hex); i++) {
int nibble = (int)strtol((char[]){hex[i], '\0'}, NULL, 16);
if (nibble == 0) {
count += 4;
} else {
count += __builtin_clz(nibble) - 28;
break;
}
}
int zero_bits(unsigned char b)
{
int n = 0;

return count;
}
if (b == 0)
return 8;

int main(int argc, char *argv[]) {
if (argc != 2) {
fprintf(stderr, "Usage: %s <hex_string>\n", argv[0]);
return 1;
}
while (b >>= 1)
n++;

const char *hex_string = argv[1];
int result = countLeadingZeroes(hex_string);
printf("Leading zeroes in hex string %s: %d\n", hex_string, result);
return 7-n;
}

return 0;
/* find the number of leading zero bits in a hash */
int count_leading_zero_bits(unsigned char *hash)
{
int bits, total, i;
for (i = 0, total = 0; i < 32; i++) {
bits = zero_bits(hash[i]);
total += bits;
if (bits != 8)
break;
}
return total;
}
```

Expand Down
19 changes: 10 additions & 9 deletions 15.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ Fields that are not self-explanatory:

**Event Tags**

```json
```jsonc
{
"tags": [["d", <string, id of stall]],
...
// other fields...
}
```
- the `d` tag is required, its value MUST be the same as the stall `id`.
Expand Down Expand Up @@ -124,12 +124,12 @@ Fields that are not self-explanatory:

**Event Tags**

```json
```jsonc
"tags": [
["d", <string, id of product],
["t", <string (optional), product category],
["t", <string (optional), product category],
...
// other fields...
],
...
```
Expand Down Expand Up @@ -158,7 +158,7 @@ The below JSON goes in content of [NIP-04](04.md).
"type": 0,
"name": <string (optional), ???>,
"address": <string (optional), for physical goods an address should be provided>,
"message": "<string (optional), message for merchant>,
"message": <string (optional), message for merchant>,
"contact": {
"nostr": <32-bytes hex of a pubkey>,
"phone": <string (optional), if the customer wants to be contacted by phone>,
Expand Down Expand Up @@ -237,7 +237,7 @@ Create a customized user experience using the `naddr` from [NIP-19](19.md#sharea

**Event Content**

```json
```jsonc
{
"name": <string (optional), market name>,
"about": <string (optional), market description>,
Expand All @@ -248,7 +248,7 @@ Create a customized user experience using the `naddr` from [NIP-19](19.md#sharea
"darkMode": <bool, true/false>
},
"merchants": [array of pubkeys (optional)],
...
// other fields...
}
```

Expand Down Expand Up @@ -290,10 +290,11 @@ This event leverages naddr to enable comprehensive customization and sharing of

### Event `1021`: Bid

```json
```jsonc
{
"content": <int, amount of sats>,
"tags": [["e", <event ID of the auction to bid on>]],
// other fields...
}
```

Expand Down Expand Up @@ -335,4 +336,4 @@ Customer support is handled over whatever communication method was specified. If

## Additional

Standard data models can be found <a href="https://raw.githubusercontent.com/lnbits/nostrmarket/main/models.py">here</a>
Standard data models can be found [here](https://raw.githubusercontent.com/lnbits/nostrmarket/main/models.py)
Loading