Keys & Addresses Published Updated

What Is a Bitcoin Address and How Does It Work?

#bip39#bitcoin#wallet#private key#recovery
What Is a Bitcoin Address and How Does It Work?

A Bitcoin address is a short string, such as bc1q… or 1…, that tells the sender’s wallet how to lock the coins it sends: to the hash of a public key, to the hash of a script or, for Taproot, to a public key itself. The address holds no coins and is not an account. The blockchain records outputs locked to the script the address stands for, and only whoever has the matching private key, or meets the script’s conditions, can spend them. Wallets calculate addresses from keys in one direction only, so you can share an address freely while the key stays secret.

Address Types at a Glance

Starts withTypeLocks coins toEncodingLengthSince
1Legacy, P2PKHHash of one public keyBase58CheckUp to 34 characters2009
3P2SH: multisig or nested SegWitHash of a scriptBase58Check34 characters2012
bc1qNative SegWit, P2WPKHHash of one public keyBech3242 characters2017
bc1qNative SegWit, P2WSHHash of a scriptBech3262 characters2017
bc1pTaproot, P2TRA tweaked public keyBech32m62 characters2021

On testnet the same types start with m or n, 2, tb1q and tb1p.

What Does an Address Encode?

The Bitcoin protocol keeps no accounts or balances. It records unspent transaction outputs (UTXOs), and each output carries a locking script, which the Bitcoin developer guide calls the pubkey script. For the original address type, pay to public key hash (P2PKH), the script is OP_DUP OP_HASH160 <pubkey hash> OP_EQUALVERIFY OP_CHECKSIG: it pays whoever later shows a public key with that hash and a valid signature made with the matching private key. As the guide notes, the pubkey hash is almost always handed over encoded as a Bitcoin address. An address, then, is a compact, typo-checked way of writing the locking script the sender’s wallet should use.

What a wallet shows as your balance is the sum of the outputs locked to its addresses. A payment spends whole outputs and creates new ones, usually including change to a fresh address of your own; outputs too small to be worth spending are covered in dust transactions.

What is a Bitcoin address — types and formats explained

What Do 1, 3, bc1q and bc1p Mean?

  • 1: legacy (P2PKH). The original format: a 20-byte hash of one public key, written in Base58Check. Every wallet can pay to it, but spending from it costs the most in fees.
  • 3: pay to script hash (P2SH). Defined in BIP 13, whose version byte 5 makes every such address start with 3. It holds the hash of a script, so the address alone does not reveal whether it belongs to a multisig wallet such as a 2-of-3 or to a single key wrapped as nested SegWit (P2SH-P2WPKH), the form wallets used while software caught up with SegWit.
  • bc1q: native SegWit. BIP 141 defines version 0 witness programs: 20 bytes for the hash of one key (P2WPKH, 42-character addresses) and 32 bytes for the hash of a script (P2WSH, 62 characters). BIP 173 writes them in Bech32 after the prefix bc.
  • bc1p: Taproot. BIP 341 defines a Taproot output as a SegWit version 1 output with a 32-byte witness program: a public key that can also commit to alternative scripts, which stay hidden unless one is used. The addresses are written in Bech32m (BIP 350), and Taproot script paths are also where Bitcoin Ordinals inscriptions keep their data.

Two output types have no address. Pay to public key (P2PK), used in Bitcoin’s earliest blocks, locks coins to a full public key and has no address format of its own. An OP_RETURN output carries data and can never be spent, so any coins assigned to it are destroyed.

BIP 173 gives bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4 (P2WPKH) and bc1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3qccfmv3 (P2WSH) as examples, and BIP 350’s test vectors include the Taproot address bc1p0xlxvlhemja6c4dqv22uapctqupfhlxm9h8z3k2e72q4k9hcz7vqzk5jj0. Treat them as format samples, not as places to send coins.

How Is an Address Made From a Private Key?

Every step runs one way: a private key gives an address, but an address never gives back the key. For a single-key address:

  1. Private key to public key. The wallet multiplies the 256-bit private key by the generator point of the secp256k1 curve and writes the result as a 33-byte compressed public key (Bitcoin private key formats).
  2. Public key to hash. It hashes the public key with SHA-256 and then RIPEMD-160, which gives the 20-byte HASH160.
  3. Hash to address. For a legacy address it puts the version byte 0x00 in front, appends the first 4 bytes of a double SHA-256 of the result as a checksum and encodes it all in Base58, the steps listed under Address Conversion in the developer reference. For native SegWit it writes the same 20 bytes as a version 0 witness program in Bech32. Taproot skips the hash: the public key is tweaked with a hash of itself, Q = P + int(hashTapTweak(bytes(P)))G in BIP 341’s notation, and the 32-byte x-coordinate of Q goes into a Bech32m address.

One key can therefore stand behind several addresses, each with its own balance. Here is the public key of the first BIP84 test vector, which comes from the public test phrase (abandon eleven times, then about), so never send coins to these addresses:

Step or address typeValue
Public key0330d54fd0dd420a6e5f8d3624f5f3482cae350f79d5f0753bf5beef9c2d91af3c
HASH160c0cebcd6c3d3ca8c75dc5ec62ebe55330ef910e2
Legacy (P2PKH)1JaUQDVNRdhfNsVncGkXedaPSM5Gc54Hso
Nested SegWit (P2SH-P2WPKH)3GtVZYzsKF6Feikdjd4bDyPdAiyeHANY9b
Native SegWit (P2WPKH)bc1qcr8te4kr609gcawutmrza0j4xv80jy8z306fyu
Taproot (P2TR, key path only)bc1p8knh0enfv47gmpuf66528zd4jtkgjq4sv5w5l2gqwgk8exu2ynns9g8c9m

The native SegWit address is the one BIP84 publishes; we computed the other three with the @scure/btc-signer library. Our private key generator shows these four address types for a random key. An HD wallet, though, gives each type its own keys: the derivation path differs (m/44' for legacy, m/49' for nested SegWit, m/84' for native SegWit and m/86' for Taproot under BIP 86), so a standard wallet does not produce all four addresses above from one key.

How Does the Checksum Catch Typos?

Every address format carries a checksum, so a wallet refuses a mistyped address instead of sending coins to it:

  • Base58Check (1 and 3). The 4-byte double SHA-256 checksum lets a random typo through about once in 4.3 billion tries (1 in 2^32). The Base58 alphabet also leaves out 0, O, I and l, which look alike in many fonts.
  • Bech32 (bc1q). BIP 173’s BCH code guarantees detection of any error affecting up to four characters and misses larger errors with a chance below one in a billion. Its 32-character alphabet leaves out 1, b, i and o, decoders must reject mixed case, and QR codes should use the uppercase form.
  • Bech32m (bc1p). BIP 350 describes a weakness of Bech32: when an address ends in p, inserting or deleting q characters right before it does not break the checksum. Bech32m changes one constant to fix this and is used for witness versions 1 to 16, Taproot included; version 0 addresses keep Bech32.

A checksum proves only that the string is well formed. A valid address that belongs to someone else passes every check, which is what clipboard malware and look-alike addresses rely on. Compare the whole address before you send, on a hardware wallet’s screen if you use one (address poisoning and other phishing tricks).

Which Address Type Should You Use?

For a new single-key wallet, native SegWit (bc1q) or Taproot (bc1p), because of fees. Fees are paid per virtual byte, and BIP 141 defines weight as base size × 3 + total size, so the witness data that holds SegWit and Taproot signatures counts a quarter as much as the rest of the transaction. We calculated typical sizes for spends with one signature from the field sizes listed in Bitcoin Optech’s transaction size calculator, adding for nested SegWit the 23-byte script that wraps its witness program:

Address typeSpending one coin (input)Receiving one coin (output)
Legacy (1…)148 vbytes34 vbytes
Nested SegWit (3…)91 vbytes32 vbytes
Native SegWit (bc1q…)68 vbytes31 vbytes
Taproot (bc1p…, key path)57.5 vbytes43 vbytes

At the same fee rate, spending a coin held on a legacy address costs more than twice as much as spending one on a bc1q address. Taproot inputs are the smallest, but its outputs are 12 bytes larger, so for simple single-key payments the two SegWit types end up close; Taproot’s bigger gains are privacy and cheaper complex spending conditions. Bitcoin Core’s dust rule rests on the same sizes: in its policy code, an output is dust below 546 satoshis for a legacy address and 294 satoshis for a native SegWit one at the default dust fee rate of 3 sat/vB, and transactions that create dust are generally not relayed.

The type a wallet keeps its own coins on does not limit whom it can pay; what matters is whether it understands the recipient’s format. Support for paying bc1p addresses arrived years after bc1q, so if a service rejects your Taproot address, give it a native SegWit one.

Why Do Wallets Show a New Address Each Time?

For privacy. Anyone who has paid you, or who links an address to you, can follow every payment to it on the public blockchain. The developer guide’s section on avoiding key reuse asks applications to avoid public key reuse and to use new addresses for payments and change. Spending from a legacy or native SegWit address also reveals the full public key behind it, because the spender has to show it for the hash check.

Fresh addresses cost nothing in an HD wallet: under BIP32 one seed phrase derives billions of keys, and an account’s extended public key lets a watch-only wallet or a payment server create new receiving addresses without any private key (xpub, ypub and zpub). Old addresses stay valid; the wallet just stops offering them. If a restored wallet shows an empty balance, the usual cause is a different address type or derivation path, which our guide to restoring a wallet from a seed phrase walks through.

Frequently Asked Questions

Is a Bitcoin address the same as a public key?

No. Legacy and native SegWit addresses contain a hash of the public key, and P2SH and P2WSH addresses the hash of a script; the key itself appears on the blockchain only when the coins are spent. Taproot is the exception: a bc1p address contains a tweaked public key.

Are Bitcoin addresses case sensitive?

Base58 addresses, starting with 1 or 3, are: changing the case of one letter gives a different string, which the checksum almost certainly rejects. Bech32 and Bech32m addresses are not, but they must be written entirely in lowercase or entirely in uppercase.

Can I send bitcoin from one address type to another?

Yes. The sender’s wallet turns the recipient’s address into a locking script, so a wallet holding coins on legacy addresses can pay a bc1q address and the other way round, as long as it understands the recipient’s format.

Does a Bitcoin address expire?

No. Coins sent to an address stay spendable with its key for as long as the key exists. Exchanges and payment services may rotate the deposit addresses they show you, so copy the current one each time rather than reusing an old one.