Nostr_client_relay allows to build Nostr clients and Nostr relays. It includes a Nostr client, Nostro, and a Nostr relay, Vostro.
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 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
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 1This 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.
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
Vostro responds withe following EVENT, that was found in the database by comparing the --authors
field.