2

I've seen lots of tables on which bytes to use as the prefix for types of addresses. For example 0x00 for legacy addresses starting with a 1. But what's the prefix for native segwit 'bc1q'? I've tried using the base58 table with no success. Thanks

1 Answer 1

4

Native segwit addresses are not encoded using base58, but using a different encoding system called bech32. The details can be found in BIP 173. For the segwit v1+ addresses that will be used for Taproot, see the amended bech32m encoding in BIP 350.

In short, the addresses consist of:

  • A human readable part, which is bc for Bitcoin mainnet segwit addresses.
  • A separator (1)
  • A payload (storing the actual script data), consisting of:
    • A character for the witness version (q for witness v0, p for witness v1, ...). See the BIPs for details on the character set.
    • A variable number of characters storing the witness program (32 characters for 20-byte witness programs like P2WPKH has; 52 characters for 32-byte witness programs like P2WSH or P2TR have). The 8-bit data is converted to 5-bit groups, and encoded using the bech32 character set.
  • 6 characters checksum, using the checksum algorithm specified in BIP173 or BIP350.
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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