Bech32, the encoding of BIP-173, on both platforms.
A Bech32 text has a prefix that a person reads, the separator 1, and data in an alphabet of 32 characters. The last six characters of the data are a checksum. The names of Nostr are Bech32, as NIP-19 defines them.
The section Segwit address format of BIP-173 tells how eight bits of data go into characters of five bits. Bech32m, the checksum of BIP-350, isn't here.
Bech32, the encoding of BIP-173, on both platforms. A Bech32 text has a prefix that a person reads, the separator 1, and data in an alphabet of 32 characters. The last six characters of the data are a checksum. The names of Nostr are Bech32, as NIP-19 defines them. The section Segwit address format of BIP-173 tells how eight bits of data go into characters of five bits. Bech32m, the checksum of BIP-350, isn't here.
(decode s)(decode s opts)The prefix and the data of the Bech32 text s, read with opts, as a
map of :prefix and :bytes. It's nil for a text that isn't Bech32, that
has a wrong checksum, or whose data aren't whole bytes.
The prefix is in lower case. The :max-length of opts is the most
characters of the text, in place of max-length.
The prefix and the data of the Bech32 text `s`, read with `opts`, as a map of :prefix and :bytes. It's nil for a text that isn't Bech32, that has a wrong checksum, or whose data aren't whole bytes. The prefix is in lower case. The :max-length of `opts` is the most characters of the text, in place of max-length.
(decode-words s)(decode-words s opts)The prefix and the data of the Bech32 text s, read with opts, as a
map of :prefix and :words. It's nil for a text that isn't Bech32, or
that has a wrong checksum.
The data are numbers of five bits, one for each character, without the
checksum, and the prefix is in lower case. The :max-length of opts is
the most characters of the text, in place of max-length. The data of a
BOLT 11 invoice aren't whole bytes, so a reader of invoices takes the
numbers.
The prefix and the data of the Bech32 text `s`, read with `opts`, as a map of :prefix and :words. It's nil for a text that isn't Bech32, or that has a wrong checksum. The data are numbers of five bits, one for each character, without the checksum, and the prefix is in lower case. The :max-length of `opts` is the most characters of the text, in place of max-length. The data of a BOLT 11 invoice aren't whole bytes, so a reader of invoices takes the numbers.
(encode prefix b)The Bech32 text of the prefix prefix and the bytes b, in lower
case.
The Bech32 text of the prefix `prefix` and the bytes `b`, in lower case.
(encode-words prefix words)The Bech32 text of the prefix prefix and the numbers of five bits
words, in lower case, with its checksum.
The Bech32 text of the prefix `prefix` and the numbers of five bits `words`, in lower case, with its checksum.
The most characters of a text, the limit of BIP-173, unless the option :max-length gives another.
The most characters of a text, the limit of BIP-173, unless the option :max-length gives another.
(regroup xs from to pad?)The numbers xs of from bits each as numbers of to bits each, the
highest bit first, with the pad? below, as the function convertbits
of BIP-173 does it.
With pad?, the bits that are left over make one more number. Without
it, they must be fewer than from and all zero, or the result is nil.
So (regroup words 5 8 false) gives the whole bytes in data that BOLT 11
pads to numbers of five bits.
The numbers `xs` of `from` bits each as numbers of `to` bits each, the highest bit first, with the `pad?` below, as the function convertbits of BIP-173 does it. With `pad?`, the bits that are left over make one more number. Without it, they must be fewer than `from` and all zero, or the result is nil. So (regroup words 5 8 false) gives the whole bytes in data that BOLT 11 pads to numbers of five bits.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |