3

Can you break down what data is encoded into a bech32 address?

e.g. bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4

How do bech32 addresses on testnet, regtest, signet compare?

6

Bech32 addresses are defined in BIP 173.

This slide is taken from Pieter Wuille's presentation on bech32 at SF Bitcoin Devs in March 2017.

bech32 structure slide

Different prefixes

A list of address prefixes on the Bitcoin wiki is here.

  • bc is representing Bitcoin (mainnet)
  • Testnet bech32 addresses start tb
  • Signet (both default Signet and custom Signets) bech32 addresses also start tb (although an earlier iteration of Signet used sb).
  • Regtest bech32 addresses start with bcrt. This is defined in chainparams.cpp here. Discussion on why regtest addresses don't have the same prefix as testnet and signet is here.

Remaining data

  • 1 is just a separator and doesn't represent any particular data
  • q is the witness version. This represents zero as the first SegWit witness version introduced was SegWit v0. Taproot introduces SegWit v1 with p representing one (v1).
  • w508d6qejxtdg4y5r3zarvary0c5xw7k is the hash of the witness program.
  • v8f3t4 is the checksum

As the slide says, mainnet P2WPKH addresses are 42 characters and mainnet P2WSH addresses are 62 characters under SegWit v0. Future witness versions can be up to 74 characters although SegWit v1 addresses (Taproot) will be the same length as v0 P2WSH addresses (62 characters). Witness programs as defined under SegWit v1 are 32 bytes.

There is a bech32 demo decoder site here.

Please note that SegWit v1 (Taproot) addresses will use bech32m encoding rather than bech32.

6
  • 2
    Segwit v1 addresses would be the same length as v0 P2WSH, as they also have a 32-byte witness program. Dec 11 '20 at 17:47
  • Thanks, will add Dec 11 '20 at 18:27
  • 1
    Good post, would upvote again.-- You could perhaps split off the section explaining the prefixes from the rest of the address since it discusses mutliple exclusive options for that part of the address, whereas the other items each explain the meaning of a specific section
    – Murch
    Jun 17 at 17:51
  • Thanks for the suggestion @Murch. Done. Jun 21 at 12:51
  • @MichaelFolkson: The part in a bech32 address before the separator is generally called the "human readable part", but the way it's phrased right now it reads as if it were a moniker that only applies to the mainnet prefix.
    – Murch
    Jun 21 at 13:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.