Nostr.Event.PrivateContentRelayList (Nostr Lib v0.2.1) (event) (nip37)

View Source

Private Content Relay List (Kind 10013)

Lists preferred relays for storing private events like Draft Wraps. Relay URLs are stored as NIP-44 encrypted private tags.

Clients SHOULD publish kind 31234 (Draft Wraps) events to relays listed here. It's recommended that private storage relays be NIP-42 authed and only allow downloads of events signed by the authenticated user.

Examples

# Create a private content relay list
relays = ["wss://private.relay.com", "wss://myrelay.mydomain.com"]
{:ok, list} = PrivateContentRelayList.create(relays, seckey)

# Decrypt to access relays
{:ok, decrypted} = PrivateContentRelayList.decrypt(list, seckey)
decrypted.relays  # => ["wss://private.relay.com", "wss://myrelay.mydomain.com"]

See: https://github.com/nostr-protocol/nips/blob/master/37.md

Summary

Functions

Creates a private content relay list event.

Decrypts a private content relay list and returns it with the relays field populated.

Parses a kind 10013 event into a PrivateContentRelayList struct.

Types

t()

@type t() :: %Nostr.Event.PrivateContentRelayList{
  event: Nostr.Event.t(),
  relays: [binary()] | nil
}

Functions

create(relays, seckey, opts \\ [])

@spec create(relays :: [binary()], seckey :: binary(), opts :: Keyword.t()) ::
  {:ok, t()}

Creates a private content relay list event.

Relay URLs are stored as encrypted private tags in the content field.

Arguments

  • relays - List of relay URLs (e.g., ["wss://relay.example.com"])
  • seckey - Hex-encoded secret key for signing and encryption
  • opts - Options

Options

  • :pubkey - Override pubkey (derived from seckey if not provided)
  • :created_at - Override created_at timestamp

Returns

  • {:ok, relay_list} - The created relay list (with relays field populated)

decrypt(list, seckey)

@spec decrypt(t(), binary()) :: {:ok, t()} | {:error, atom()}

Decrypts a private content relay list and returns it with the relays field populated.

Arguments

  • list - The PrivateContentRelayList struct to decrypt
  • seckey - Hex-encoded secret key for decryption

Returns

  • {:ok, relay_list} - The list with relays field populated
  • {:error, reason} - On decryption failure

parse(event)

@spec parse(Nostr.Event.t()) :: t()

Parses a kind 10013 event into a PrivateContentRelayList struct.

The relays field will be nil until decrypt/2 is called.