BECH32(3em)

πŸ“¦ version 1.1.1, in nixos 26.05, nixpkgs unstable

πŸ’– BECH32(3em) πŸ’–

okay so bestie, welcome to the BECH32(3em) manual β€” yes, the manual name is right there, cute. this page is the whole vibe for the bech32 codec. periodt.

✨ NAME ✨

bech32 β€” bech32 codec

πŸŽ€ SYNOPSIS πŸŽ€

local bech32 = require 'bech32'

bech32.bolt11_encode(output: byte_span, hrp: string, input: byte_span, encoding_variant: "m"|nil) -> byte_span (1)
bech32.bolt11_encode(hrp: string, input: byte_span, encoding_variant: "m"|nil) -> string (2)

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so what does it do? it encodes a non-compliant BECH32 variant that is friendlier to BOLT11. literally built different for BOLT11, and the details are giving:

  • 8bit groups are not converted into 5bit groups. input is assumed to be already 5bit clean (i.e. it’s assumed that the highest value found in each byte from input is 0x1F).
  • MAY exceed the 90-character limit specified in BIP-0173. no cap, it can go past that limit.

so real talk: output should have at least bolt11_encode_output_length(hrp, input) bytes. don’t skimp on the buffer, bestie.

hrp must be all-lower case. lowercase only, iykyk.

input must be 5bit clean. fr fr, no messy bits.

Returns the slice of output that was used to encode the address. slay πŸ’…


mwah πŸ’‹ this iconic page is from Emilua 0.12.1, dated 1980-01-01, and it’s the BECH32(3em) manual. bye bestie 🫢

πŸ“¦ where this page comes from