View Source Nostr.Event.Id (Nostr v0.1.3)
Event id conversion functions
Link to this section Summary
Functions
Converts a bech32 event id into its binary format
Converts a bech32 event id into its binary format
Converts an event binary id into a bech32 format
Converts any type of event id into a hex format
Converts a bech32 event id into a hex string format
Link to this section Functions
Converts a bech32 event id into its binary format
examples
Examples
iex> "note19e93faw4ffqepsqsrwrnstd3ee00nmzakwwuyfjm43dankgummfqms4p6q"
...> |> Nostr.Event.Id.from_bech32
{:ok, "note", <<0x2e4b14f5d54a4190c0101b87382db1ce5ef9ec5db39dc2265bac5bd9d91cded2::256>>}
@spec from_bech32!(binary()) :: <<_::256>>
Converts a bech32 event id into its binary format
examples
Examples
iex> "note19e93faw4ffqepsqsrwrnstd3ee00nmzakwwuyfjm43dankgummfqms4p6q"
...> |> Nostr.Event.Id.from_bech32!
<<0x2e4b14f5d54a4190c0101b87382db1ce5ef9ec5db39dc2265bac5bd9d91cded2::256>>
Converts an event binary id into a bech32 format
examples
Examples
iex> <<0x2e4b14f5d54a4190c0101b87382db1ce5ef9ec5db39dc2265bac5bd9d91cded2::256>>
...> |> Nostr.Event.Id.to_bech32("note")
"note19e93faw4ffqepsqsrwrnstd3ee00nmzakwwuyfjm43dankgummfqms4p6q"
iex> "2e4b14f5d54a4190c0101b87382db1ce5ef9ec5db39dc2265bac5bd9d91cded2"
...> |> Nostr.Event.Id.to_bech32("note")
"note19e93faw4ffqepsqsrwrnstd3ee00nmzakwwuyfjm43dankgummfqms4p6q"
Converts any type of event id into a hex format
examples
Examples
iex> <<0x2e4b14f5d54a4190c0101b87382db1ce5ef9ec5db39dc2265bac5bd9d91cded2::256>>
...> |> Nostr.Event.Id.to_hex()
{:ok, nil, "2e4b14f5d54a4190c0101b87382db1ce5ef9ec5db39dc2265bac5bd9d91cded2"}
iex> "note19e93faw4ffqepsqsrwrnstd3ee00nmzakwwuyfjm43dankgummfqms4p6q"
...> |> Nostr.Event.Id.to_hex
{:ok, "note", "2e4b14f5d54a4190c0101b87382db1ce5ef9ec5db39dc2265bac5bd9d91cded2"}
@spec to_hex!(binary()) :: <<_::512>>
Converts a bech32 event id into a hex string format
examples
Examples
iex> "note19e93faw4ffqepsqsrwrnstd3ee00nmzakwwuyfjm43dankgummfqms4p6q"
...> |> Nostr.Event.Id.to_hex!
"2e4b14f5d54a4190c0101b87382db1ce5ef9ec5db39dc2265bac5bd9d91cded2"