pull down to refresh

Find the complete tutorial series of bitcoin technical concepts at https://bitcoindevs.xyz/decoding/roadmap

SegWit (Segregated Witness) addresses use Bech32 encoding (not the older Base58Check).
A typical Bech32 address might look like:
bc1qeaqk7vume5vmrdgx5eyveh5sch4ncg56jdmlkj

Decoding a Bech32 Address

Let’s decode this bech32 address to extract version, witness program and other data

Step 1: Extract the Version

After the bc1 prefix, the next character encodes the witness version.

Step 2: Extract the Witness Program

The remaining characters (after the version) form the witness program.

Step 3: Extract the Checksum

  1. The final part of the data includes the checksum.
  2. The checksum confirms the address has no typos or errors.

Step 4: Verify the Checksum

A valid checksum means the address is properly formatted.

Step 5: Convert the witness program (base32) into binary.

Final Step: Convert Binary to Witness Program**

Use the binary to derive the Public Key Hash (WPKH) or other script data.

Why Bech32?

  • Lower Fees: SegWit reduces the size of transactions, lowering fees.
  • Error Detection: The Bech32 format has built-in error correction.
  • Future Compatibility: Supports newer SegWit versions.

Feel free to share these illustrations and notes to help others understand how to decode and verify a SegWit (Bech32) address!
29 sats \ 1 reply \ @nichro 17 Feb
Nice summary. Appreciate the visuals.
Timely post for me as I've literally been writing a lean toolkit to be able to do all kinds of operations on xpubs, derive pubkeys/addresses, etc.
It's for personal usecases and at the same time to learn about the cryptography side of things more intimately, beyond just understanding the conceptual and letting wallet software or high level third party libraries do their magic.
Might have to rabbithole into your content now.
Have some sats, cheers
reply
Thanks, glad to hear that! We're actively improving the website with new resources and tools. If there's a tool you'd like to see or wish existed and want us to build, lmk
reply
What is a delimiter?
reply
219 sats \ 0 replies \ @nout 17 Feb
Separator, it's just a known character that separates the two sections. "1" is the separator (=delimiter) that goes between the prefix and the data part.
reply
Is the checksum enough to prevent people from sending bitcoin to invalid addresses?
reply
It generally help detect typos/errors in an address but does not verify whether the address is actually in use or belongs to anyone. If you generate a valid Bitcoin address but never use it, BTC sent to that address will be lost forever
reply
So maybe it is even safe to type bitcoin address by hand :)
reply
Very concise and informative for someone like me who isn't a cryptography expert. Thanks!
reply
glad to hear that thanks
reply