Home

Awesome

Denostr

<p align="center"> <img alt="denostr logo" height="256px" width="256px" src="https://user-images.githubusercontent.com/8678079/233816217-27504e7e-b429-4388-ac69-592122fa922b.png" /> </p> <p align="center"> <a href="https://github.com/denostr-lab/denostr/releases"> <img alt="GitHub release" src="https://img.shields.io/github/v/release/denostr-lab/denostr"> </a> <a href="https://github.com/denostr-lab/denostr/issues"> <img alt="GitHub issues" src="https://img.shields.io/github/issues/denostr-lab/denostr?style=plastic" /> </a> <a href="https://github.com/denostr-lab/denostr/stargazers"> <img alt="GitHub stars" src="https://img.shields.io/github/stars/denostr-lab/denostr" /> </a> <img alt="GitHub top language" src="https://img.shields.io/github/languages/top/denostr-lab/denostr"> <a href="https://github.com/denostr-lab/denostr/network"> <img alt="GitHub forks" src="https://img.shields.io/github/forks/denostr-lab/denostr" /> </a> <a href="https://github.com/denostr-lab/denostr/blob/main/LICENSE"> <img alt="GitHub license" src="https://img.shields.io/github/license/denostr-lab/denostr" /> </a> <a href='https://coveralls.io/github/denostr-lab/denostr?branch=main'> <img alt='Coverage Status' src='https://coveralls.io/repos/github/denostr-lab/denostr/badge.svg?branch=main' /> </a> <a href='https://github.com/denostr-lab/denostr/actions'> <img alt='Build status' src='https://github.com/denostr-lab/denostr/actions/workflows/checks.yml/badge.svg?branch=main&event=push' /> </a> </p>

💪🏻 Deno-based, cloud-native Nostr relay forked from nostream.

This is a nostr relay, written in Typescript.

This implementation is production-ready. See below for supported features.

The project main repository is available on GitHub.

Features

NIPs with a relay-specific implementation are listed here.

Architecture

Todo

Requirements

kubernetes setups

Full Guide

NOTE: If the payment is enabled, it is recommended to start another instance with WORKER_TYPE=maintenance following the "Quick Start" guide.

Accepting payments

  1. Before you begin

    • Complete one of the Quick Start guides in this document
    • Create a .env file
    • On .nostr/settings.yaml file make the following changes:
      • Set payments.enabled to true
      • Set payments.feeSchedules.admission.enabled to true
      • Set limits.event.pubkey.minBalance to the minimum balance in msats required to accept events (i.e. 1000000 to require a balance of 1000 sats)
    • Choose one of the following payment processors: lnbits, lnurl, zebedee
  2. LNbits

    • Complete the step "Before you begin"

    • Create a new wallet on you public LNbits instance

      • Demo server must not be used for production
      • Your instance must be accessible from the internet and have a valid SSL/TLS certificate
    • Get wallet "Invoice/read key" (in Api docs section of your wallet)

    • set LNBITS_API_KEY environment variable with the "Invoice/read key" Key above on your .env file

      LNBITS_API_KEY={YOUR_LNBITS_API_KEY_HERE}
      
    • On your .nostr/settings.yaml file make the following changes:

      • Set payments.processor to lnbits
      • set lnbits.baseURL to your LNbits instance URL (e.g. https://{YOUR_LNBITS_DOMAIN_HERE}/)
      • Set paymentsProcessors.lnbits.callbackBaseURL to match your callbcak URL (e.g. https://{YOUR_DOMAIN_HERE}/callbacks/lnbits)
    • Restart Denostr

  3. Alby or any LNURL Provider with LNURL-verify support

    • Complete the step "Before you begin"
    • Create a new account if you don't have an LNURL
    • On your .nostr/settings.yaml file make the following changes:
      • Set payments.processor to lnurl
      • Set lnurl.invoiceURL to your LNURL (e.g. https://getalby.com/lnurlp/your-username)
    • Restart Denostr
  4. ZEBEDEE

    ZEBEDEE_API_KEY={YOUR_ZEBEDEE_API_KEY_HERE}
    
    • Follow the required steps for all payments processors
    • On .nostr/settings.yaml file make the following changes:
      • payments.processor to zebedee
      • paymentsProcessors.zebedee.callbackBaseURL to match your callback URL (e.g. https://{YOUR_DOMAIN_HERE}/callbacks/zebedee)
    • Restart Denostr
  5. Ensure payments are required for your public key

    • Visit https://{YOUR-DOMAIN}/
    • You should be presented with a form requesting an admission fee to be paid
    • Fill out the form and take the necessary steps to pay the invoice
    • Wait until the screen indicates that payment was received
    • Add your relay URL to your favorite Nostr client (wss://{YOUR-DOMAIN}) and wait for it to connect
    • Send a couple notes to test
    • Go to https://websocketking.com/ and connect to your relay (wss://{YOUR_DOMAIN})
    • Convert your npub to hexadecimal using a Key Converter
    • Send the following JSON message: ["REQ", "payment-test", {"authors":["your-pubkey-in-hexadecimal"]}]
    • You should get back the few notes you sent earlier

Quick Start (Standalone)

Clone repository and enter directory:

git clone https://github.com/denostr-lab/denostr.git --depth 1 && cd denostr

Create .env file inside denostr project folder

Set the following environment variables:

WORKER_TYPE=worker
MONGO_URI=mongodb://user:pass@host:port/db?replicaSet=rs0&authSource=admin

Generate a long random secret and set SECRET:

You may want to use openssl rand -hex 128 to generate a secret.

SECRET=aaabbbccc...dddeeefff
# Secret shortened for brevity

In addition, if using API Key for payments, You must also use the API key of each payment service to set the.

Create .nostr folder inside denostr project folder and copy over the settings file:

mkdir .nostr
cp resources/default-settings.yaml .nostr/settings.yaml

To start in development mode:

deno task dev

Or, start in production mode:

deno task start

Apply for kubernetes

Please refer to this document

Tests

Unit tests

Run unit tests with:

deno task test:unit

Integration tests

Run integration tests with:

deno task test:integration

Configuration

You can change the default folder by setting the NOSTR_CONFIG_DIR environment variable to a different path.

Run denostr using one of the quick-start guides at least once and denostr/.nostr/settings.json will be created. Any changes made to the settings file will be read on the next start.

Default settings can be found under resources/default-settings.yaml. Feel free to copy it to denostr/.nostr/settings.yaml if you would like to have a settings file before running the relay first.

See CONFIGURATION.md for a detailed explanation of each environment variable and setting.

Dev Channel

For development discussions, please use the Nostr Typescript Relay Dev Group.

For discussions about the protocol, please feel free to use the Nostr Telegram Group.

License

This project is MIT licensed.