NostrElixir.Nip19.Address (nostr_elixir v0.3.0)

View Source

NIP-19 TLV encoding and decoding for naddr, nevent, and nprofile.

Backed by the rust-nostr NIF (same crate as the rest of NostrElixir).

Summary

Types

naddr()

@type naddr() :: %{
  kind: integer(),
  pubkey: String.t(),
  identifier: String.t(),
  relays: [String.t()]
}

nevent()

@type nevent() :: %{
  event_id: String.t(),
  author: String.t() | nil,
  kind: integer() | nil,
  relays: [String.t()]
}

nprofile()

@type nprofile() :: %{pubkey: String.t(), relays: [String.t()]}

Functions

decode(encoded)

@spec decode(String.t()) :: {:ok, atom(), map()} | {:error, term()}

encode_naddr(kind, pubkey_hex, identifier, relays \\ [])

@spec encode_naddr(integer(), String.t(), String.t(), [String.t()]) ::
  {:ok, String.t()} | {:error, term()}

encode_nevent(event_id_hex, author_hex \\ nil, relays \\ [])

@spec encode_nevent(String.t(), String.t() | nil, [String.t()]) ::
  {:ok, String.t()} | {:error, term()}

encode_nprofile(pubkey_hex, relays \\ [])

@spec encode_nprofile(String.t(), [String.t()]) ::
  {:ok, String.t()} | {:error, term()}

nip19_decode_address_nif(encoded)

See NostrElixir.nip19_decode_address_nif/1.

nip19_encode_naddr_nif(kind, pubkey, identifier, relays)

See NostrElixir.nip19_encode_naddr_nif/4.

nip19_encode_nevent_nif(event_id, author, relays)

See NostrElixir.nip19_encode_nevent_nif/3.

nip19_encode_nprofile_nif(pubkey, relays)

See NostrElixir.nip19_encode_nprofile_nif/2.