THAMER
Sovereign Bitcoin Wallet

WALLET AI BITCOIN

Your Bitcoin Wallet. Your Keys. Your Engine.

Self-hosted Bitcoin software built for developers, applications, and AI agents.

CREATE WALLET

Bitcoin Base58Check Addresses: Version Bytes, Checksums, and Legacy Formats

permalink THAMER
#address-encoding#base58check#bitcoin#p2pkh#p2sh

Bitcoin's original human-readable address formats use Base58Check, an encoding that combines a version prefix, a payload, and an error-detection checksum. It was designed to make addresses easier to copy than raw binary data while reducing certain transcription mistakes. It does not authenticate the person presenting an address.

From payload bytes to characters

For a conventional pay-to-public-key-hash (P2PKH) address, the payload is a 20-byte HASH160 digest of a public key. A version byte precedes that payload: on Bitcoin mainnet, 0x00 denotes P2PKH, producing familiar addresses beginning with 1. Mainnet pay-to-script-hash (P2SH) uses version 0x05, generally yielding addresses beginning with 3. Test-network version values differ, so the same payload encoded for different networks produces different strings.

Base58Check computes SHA256(SHA256(version || payload)) and appends the first four bytes of that double-SHA256 result. The complete byte sequence is interpreted as a big-endian integer and encoded using an alphabet that excludes visually confusing characters such as 0, O, I, and l. Leading zero bytes are represented by leading 1 characters. An implementation must preserve these leading zeros when decoding.

Validation sequence

A decoder first rejects characters outside the Base58 alphabet, reconstructs the byte sequence, and separates its four-byte checksum. It recomputes the checksum and compares it before interpreting the version and payload length. For ordinary P2PKH and P2SH addresses, the expected payload is 20 bytes. A valid checksum on an unknown version is not sufficient to identify a supported Bitcoin destination.

A decoder should also distinguish an address from a Wallet Import Format private key or an extended key. Those can use related Base58Check framing, but they are different data types with different prefixes and lengths. Never accept a generic Base58Check string as a payment address without checking its type.

Limits of the checksum

Four checksum bytes provide accidental-error detection, not cryptographic authentication. An attacker can generate a different address with its own correct checksum. Malware that replaces a clipboard address will normally supply a perfectly valid replacement. Confirm the full destination with a trusted display or independent channel when the payment is important.

Base58Check is still necessary for compatibility with legacy outputs, but it is not used for native SegWit v0 or Taproot addresses. Those employ Bech32 or Bech32m with explicit witness versions and human-readable network prefixes.

Primary references

Bitcoin Wiki — Base58Check encoding: https://en.bitcoin.it/wiki/Base58Check_encoding

BIP13 — Address Format for pay-to-script-hash: https://github.com/bitcoin/bips/blob/master/bip-0013.mediawiki

Questions & Answers

Explore all questions →

Latest from the Lab

THAMER illustrated developer portrait and signature

ABOUT THE DEVELOPER

Independent Software Developer specializing in Bitcoin Script, Golang, and AI Agents.

Software engineering · Independent research · Open-source projects