Encodings

Bech32m

BIP350 bech32m. Bech32 with a new checksum constant for SegWit v1 and later and Taproot
IDbech32m18 / 20bech32 · 32 characters
Encoding / Bech32

Bech32m

Bech32 with the length bug fixed.

Overhead
+62% on random bytes
Checksum
checked on decode
Standard
BIP350
Used by
Taproot
family 2 / 20

Sample

Out
hi1dpjkcmr0ypmk7unvvsssa376qt
Back
"hello world!" · prefix hi

Options

prefixstring
required
Human-readable part, such as bc or tb
limitnumber
default 90
Longest result allowed; BIP173 sets 90, Lightning invoices need more

Access

Importimport { bech32m } from "@agntn/encodings/bech32"
CLIencodings encode bech32m 'hello world!' --prefix hi
Tryplayground with the sample above
Kinbech32

Bech32 had one embarrassing flaw. End a string in p, add or drop q characters right before it, and the checksum still passed. BIP350 fixed it by changing one constant. That's bech32m.

ts
decode("bech32m", "bc1p0xlxvlhemja6c4dqv22uapctqupfhlxm9h8z3k2e72q4k9hcz7vqzk5jj0");
// bytes: 79be667e…16f81798, details: { prefix: "bc", witnessVersion: 1 }

Taproot addresses, bc1p…, are bech32m. Version 0 stays on bech32. Hand a v0 address to bech32m and it fails. Annoying? It's exactly the point.