Nostr clients and Nostr relays

Nostr_client_relay allows to build Nostr clients and Nostr relays. It includes a Nostr client, Nostro, and a Nostr relay, Vostro.

Nostro

Nostro is a Nostr command line client. Usage is:

./nostro [OPTIONS]
[OPTIONS]:
  --uri <wss URI> Wss URI to send
  --req message is a request (REQ). EVENT parameters are ignored
REQ OPTIONS: These are for the REQ filter, per NIP-01
  --authors <string> a list of pubkeys or prefixes
EVENT OPTIONS: These are to publish an EVENT, per NIP-01
  --content <string> the content of the note
  --kind <number> set kind
  --sec <hex seckey> set the secret key for signing, otherwise one will be randomly generated

Vostro

Vostro is a Nostr relay. At the momment it uses a plain text JSON database (for development purposes). A database is a JSON array of events read and saved to filesystem in JSON format. Vostro is a command line application. To start Vostro, open a shell and do (the output is from the Vostro log output, Vostro is a WebSockects server):

./vostro
vostro:04:23:00 Listening on port: 8080

Examples

This example shows 2 Nostro calls: publishing an EVENT and doing a REQ on the relay database. The parameter --uri specifies the URI of a relay to publish. If no --uri parameter is set, then Nostro publishes to a Nostr relay listening in localhost. In this example, we use Vostro listening in localhost. To publish an event signed with your private key, with the content 'hello world', we use

./nostro --sec <hex seckey> --content 'hello world' --kind 1
This call generated the following entry on the Vostro JSON database. To note that the key 'pubkey' is the Nostr public key associated with the private key used by Nostro to sign the event. ```json [ { "content": "hello world", "created_at": 1688794190, "id": "c3a4a0a20712db7249aa4d07598d5f88e31d77f95a4cc8e7bb41bd64348011f8", "kind": 1, "pubkey": "4ea843d54a8fdab39aa45f61f19f3ff79cc19385370f6a272dda81fade0a052b", "sig": "4337b5361f11decd00b96bc37a87324f707f370687a7cab066c4e001145d5ee3312a3f1c1cfa6f3638e3461c8dec77468fcf35b465a16c6358ef313fca748730", "tags": [] } ] ```

To query for the event we just inserted in the datbase, we do

./nostro  --req --authors 4ea843d54a8fdab39aa45f61f19f3ff79cc19385370f6a272dda81fade0a052b

where the --authors paramenter is the public key corresponding to the private key used to sign the event. (The public key in the databse entry). This call generates the following message to send

```json [ "REQ", "5FBD876B-EA8C-454C-9E6F-590A8A5B6DC0", { "authors": [ "4ea843d54a8fdab39aa45f61f19f3ff79cc19385370f6a272dda81fade0a052b" ], "kinds": [ 1 ], "limit": 0 } ] ```

Vostro responds withe following EVENT, that was found in the database by comparing the --authors field.

```json [ "EVENT", "031007A3-FC06-452F-8727-8160F4B9A17A", { "content": "hello world", "created_at": 1688794190, "id": "c3a4a0a20712db7249aa4d07598d5f88e31d77f95a4cc8e7bb41bd64348011f8", "kind": 1, "pubkey": "4ea843d54a8fdab39aa45f61f19f3ff79cc19385370f6a272dda81fade0a052b", "sig": "4337b5361f11decd00b96bc37a87324f707f370687a7cab066c4e001145d5ee3312a3f1c1cfa6f3638e3461c8dec77468fcf35b465a16c6358ef313fca748730", "tags": [] } ] ```

Last modified:
Home