Chains

Bitcoin

Legacy, Bech32 and Bech32m addresses. SegWit is checked to the letter of BIP-173 and BIP-350, legacy down to its Base58Check checksum.
create
create("bitcoin")
family
UTXO · utxo
symbol
BTC · 8 decimals
bip44
0
caip2
bip122:000000000019d6689c085ae165831e93
explorer
blockstream.info

Address format

Three forms, two checks.

Legacy 1… and 3… addresses decode to 25 Base58Check bytes under version 0x00 or 0x05, and the last four have to match a double SHA-256 of the other 21. One character off fails, the same as on the SegWit branch.

SegWit bc1… addresses get the full BIP-173 and BIP-350 treatment: Bech32 for witness version 0, Bech32m for versions 1 through 16, a program of 20 or 32 bytes for v0 and 2 to 40 bytes otherwise, zero padding, and the checksum. One character off fails. Both all lowercase and all uppercase pass, mixed case doesn't. A checksum can't rescue an invalid witness program.

Testnet is out on both branches: m…, n…, 2… and tb1… are rejected. So is a Litecoin L… address, its version byte is 0x30.

import { getChain } from "@agntn/chains";

const chain = getChain("btc");
chain.assertAddress("bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4"); // returned unchanged
chain.type; // "utxo"
chain.caip2; // "bip122:000000000019d6689c085ae165831e93"

Spellings

bitcoin, btc, Bitcoin. The key is bitcoin, the rest resolve through getChain.

@agntn/chains·MIT license· A format check, not proof an address exists. Nothing on this site talks to a chain.