<p>An address is a standardized encoding of an output script with a checksum. Because of this checksum, a blockchain explorer can (with a high probability) tell between a valid and an invalid address.</p>
<p>However, a valid address doesn't mean anyone has the private key(s) to be able to spend from it, or even that such a key exists. All the blockchain explorer can tell you is whether the address has ever received funds (which any valid address can) and spent funds (in which case the private key exists and someone has access to it, or at least had at some point).</p>
<p>As a side note, addresses don't actually appear in the blockchain, only output scripts, which the blockchain explorer then converts to addresses (provided that the script has a standard address encoding).</p>

CC BY-SA 4.0
2023-06-17T14:06:23.613Z
Thank you! I would like to dive more into the subject, could you point in which direction I should look to learn more about "encoding of an output script with a checksum" (a little bit more specifically) and how does blockchain explorer uses it to predict if the address is valid or invalid?

Also, you say "received funds (which any valid address can)". But what about 1CounterpartyXXXXXXXXXXXXXXXUWLpVr? It has 2000 BTC, but doesn't seem to be a valid (if we talk about checksum) address. Or doesn't it?
Alex
CC BY-SA 4.0
2023-06-17T14:09:29.100Z
@Alex see [how does the blockchain addresses relate to the blockchain WIF?](https://bitcoin.stackexchange.com/q/115203/13866) and answers to [questions tagged "address generation"](https://bitcoin.stackexchange.com/questions/tagged/address-generation)
RedGrittyBrick
CC BY-SA 4.0
2023-06-17T14:20:01.793Z
@Alex The 1Counterparty address *is* valid. It's just that almost certainly, nobody has the corresponding private key, so those 2000 BTC won't ever move. But there is no way for Bitcoin software to *know* that nobody has the private key for it, so sending to it is valid.
Pieter Wuille
CC BY-SA 4.0
2023-06-17T14:32:57.627Z
@Pieter Wuille, yeah, I understand this, but initially, I thought that you could actually send Bitcoins to any (even invalid) addresses. How do you determine that 1Counterparty is valid (valid in which sense, by the way)? Does the blockchain or Bitcoin software reject attempts to send transactions to invalid addresses?
Alex
CC BY-SA 4.0
2023-06-17T14:34:22.900Z
As explained, Bitcoin addresses have a checksum built-in. The address is valid if it has a valid checksum. Computing the checksum doesn't require access to the corresponding private key. The 1Counterparty address has a valid checksum (that's where the weird UWLpVr at the end comes from). The checksum only protects against typos in the address, it has nothing to do with whether a private key for it is known.
Pieter Wuille
CC BY-SA 4.0
2023-06-17T14:48:24.997Z
Also note that this checksum does not exist on-chain (just like the rest of the address). You can send to any *script*, in theory. Some scripts (and practically, all the ones that are used) have a convenient human-friendly encoding that includes a checksum, called the address. In practice, wallet software will only let you send to scripts if you enter the corresponding valid address. The block explorer computes the address, including the checksum, based on the on-chain data.
Pieter Wuille
CC BY-SA 4.0
2023-06-17T14:50:13.980Z
@PieterWuille Omg, so many thanks! You reminded me that I read somewhere, and now I realize that the last 4 bytes on the right side are the checksum (specifically: first 4 bytes of the SHA-256 hash for the initial SHA-256 hash) of the key. Thanks a lot, correct if I am wrong!
Alex
CC BY-SA 4.0
2023-06-17T11:59:44.120Z
2023-06-17T11:59:44.120Z
Vojtěch Strnad
<p>Bitcoin transactions on-chain do not have addresses. They have <em>scripts</em> as output. In theory, pretty much any script is legal on-chain (ignoring standardness rules), including many unspendable ones.</p>
<p>To make things more convenient to work with for humans, certain standard scripts (in particular, P2PKH, <a href="https://github.com/bitcoin/bips/blob/master/bip-0016.mediawiki" rel="nofollow noreferrer">P2SH</a>, <a href="https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki" rel="nofollow noreferrer">P2WPKH</a>, <a href="https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki" rel="nofollow noreferrer">P2WSH</a>, and <a href="https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki" rel="nofollow noreferrer">P2TR</a> ones) have a human-readable notation associated with them, known as addresses (in <a href="https://en.bitcoin.it/Base58Check_encoding" rel="nofollow noreferrer">base58</a>, <a href="https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki" rel="nofollow noreferrer">bech32</a>, or <a href="https://github.com/bitcoin/bips/blob/master/bip-0350.mediawiki" rel="nofollow noreferrer">bech32m</a> format). These addresses include a checksum to protect against typos; a truncated double-SHA256 one for base58, a BCH one for bech32(m). This checksum, like the address itself, does not exist on-chain.</p>
<p>Software that interacts with the blockchain will generate/show scripts in address form (which means adding the checksum), and typically only accept entering scripts in address form (which means verifying the checksum in it). That holds for:</p>
<ul>
<li>Wallets, when creating a new receive address.</li>
<li>Block explorers, when showing the scripts in transactions.</li>
<li>Wallets, when sending.</li>
</ul>
<p>So how does the block explorer know the address it shows is valid?</p>
<ul>
<li>If it's something you search for, it takes the address you input, parses it, verifies its checksum, converts it to a script, and searches its database for it. Even when nothing is found, the script is valid, so it can show that there are no results. If the checksum was invalid, it would instead tell you that the address is invalid.</li>
<li>If it's something found in a block or transaction, the explorer converts the scripts to their address form (including correct checksum), and shows you that.</li>
</ul>
<p>In neither case is it certain that anyone has the corresponding key, unless there are also spends of the funds received to the address in question. In particular, one can compute scripts that look like a given string in address form easily, if one does not care about finding the corresponding private key.</p>

CC BY-SA 4.0
2023-06-19T15:28:21.550Z
Thank you for the detailed explanation! Would you mind If I ask you to add the details on this part: "it takes the address you input, parses it, verifies its checksum, converts it to a script"? It would be greatly appreciated if you could provide either the exact algorithm or offer a slightly more elaborate description of the steps involved, with any examples.
Alex
CC BY-SA 4.0
2023-06-19T15:33:45.990Z
@Alex For the modern address formats (bech32 and bech32m), see the linked BIPs 173 and 350, which include test vectors, pseudocode, and links to reference code. For P2PKH and P2SH addresses with Base58 encoding, see https://en.bitcoin.it/Base58Check_encoding
Pieter Wuille
CC BY-SA 4.0
2023-06-17T15:23:31.917Z
2023-06-19T15:34:39.603Z
2023-06-19T15:34:39.603Z
Pieter Wuille
<p>I am studying how the Bitcoin addresses generation works.</p>
<p>As far as I learned, a Bitcoin address appears in the blockchain only after it has been involved in its first transaction. If an address has never been used in any transactions, it will not have a presence in the blockchain.</p>
<p>For this reason, Initially, I believed that without knowledge of the private key, there would be no way to verify if a given address is a correct hash generated from real key, or simply a random/made-up combination of characters of the same length (like some of those &quot;vanity-addresses&quot;).</p>
<p>However, today I discovered that when I enter a genuinely generated BTC address that has never been used before (for sure) into the search field on blockchain.com, the latest displays a message indicating that the address is found but has no transactions.</p>
<p><a href="https://i.sstatic.net/NfgGR.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/NfgGR.png" alt="screenshot1_real" /></a></p>
<p><a href="https://i.sstatic.net/dl2kP.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/dl2kP.png" alt="screenshot2_real_no_transactions" /></a>
<em>To generate addresses, I used bitaddress.org and <a href="https://github.com/fortesp/bitcoinaddress" rel="nofollow noreferrer">this python lib</a>, I tried multiple times, using both, but the results always generally look like ones above.</em></p>
<p>On the other hand, when I change a single character in such an address or enter random digits and letters that visually resemble a BTC address (including length) but were not generated using the mentioned lib/service, blockchain.com states that &quot;Nothing found.&quot;</p>
<p><a href="https://i.sstatic.net/ihYkH.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/ihYkH.png" alt="screenshot3_madeup" /></a></p>
<p>How do the service distinguishes between real and made-up addresses, in this case?</p>

<address><address-generation><blockchain-explorer><checksum>
How do blockchain explorers know if the address is really generated?
Alex
# How do blockchain explorers know if the address is really generated?

(Asked by: username_0 on 2023-06-17)

I am studying how the Bitcoin addresses generation works.

As far as I learned, a Bitcoin address appears in the blockchain only after it has been involved in its first transaction. If an address has never been used in any transactions, it will not have a presence in the blockchain.

For this reason, Initially, I believed that without knowledge of the private key, there would be no way to verify if a given address is a correct hash generated from real key, or simply a random/made-up combination of characters of the same length (like some of those "vanity-addresses").

However, today I discovered that when I enter a genuinely generated BTC address that has never been used before (for sure) into the search field on blockchain.com, the latest displays a message indicating that the address is found but has no transactions.

[![screenshot1_real](https://i.sstatic.net/NfgGR.png)](https://i.sstatic.net/NfgGR.png)

[![screenshot2_real_no_transactions](https://i.sstatic.net/dl2kP.png)](https://i.sstatic.net/dl2kP.png)
*To generate addresses, I used bitaddress.org and [this python lib](https://github.com/fortesp/bitcoinaddress), I tried multiple times, using both, but the results always generally look like ones above.*

On the other hand, when I change a single character in such an address or enter random digits and letters that visually resemble a BTC address (including length) but were not generated using the mentioned lib/service, blockchain.com states that "Nothing found."

[![screenshot3_madeup](https://i.sstatic.net/ihYkH.png)](https://i.sstatic.net/ihYkH.png)

How do the service distinguishes between real and made-up addresses, in this case?

**Tags:** address, address-generation, blockchain-explorer, checksum


---

## 2 answers

### Answer by username_3 on 2023-06-17. Score: 7 | Accepted answer

Bitcoin transactions on-chain do not have addresses. They have *scripts* as output. In theory, pretty much any script is legal on-chain (ignoring standardness rules), including many unspendable ones.

To make things more convenient to work with for humans, certain standard scripts (in particular, P2PKH, [P2SH](https://github.com/bitcoin/bips/blob/master/bip-0016.mediawiki), [P2WPKH](https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki), [P2WSH](https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki), and [P2TR](https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki) ones) have a human-readable notation associated with them, known as addresses (in [base58](https://en.bitcoin.it/Base58Check_encoding), [bech32](https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki), or [bech32m](https://github.com/bitcoin/bips/blob/master/bip-0350.mediawiki) format). These addresses include a checksum to protect against typos; a truncated double-SHA256 one for base58, a BCH one for bech32(m). This checksum, like the address itself, does not exist on-chain.

Software that interacts with the blockchain will generate/show scripts in address form (which means adding the checksum), and typically only accept entering scripts in address form (which means verifying the checksum in it). That holds for:

* Wallets, when creating a new receive address.
* Block explorers, when showing the scripts in transactions.
* Wallets, when sending.

So how does the block explorer know the address it shows is valid?

* If it's something you search for, it takes the address you input, parses it, verifies its checksum, converts it to a script, and searches its database for it. Even when nothing is found, the script is valid, so it can show that there are no results. If the checksum was invalid, it would instead tell you that the address is invalid.
* If it's something found in a block or transaction, the explorer converts the scripts to their address form (including correct checksum), and shows you that.

In neither case is it certain that anyone has the corresponding key, unless there are also spends of the funds received to the address in question. In particular, one can compute scripts that look like a given string in address form easily, if one does not care about finding the corresponding private key.

> **Comments:**
> **username_0**: Thank you for the detailed explanation! Would you mind If I ask you to add the details on this part: "it takes the address you input, parses it, verifies its checksum, converts it to a script"? It would be greatly appreciated if you could provide either the exact algorithm or offer a slightly more elaborate description of the steps involved, with any examples.  
> **username_3**: @username_0 For the modern address formats (bech32 and bech32m), see the linked BIPs 173 and 350, which include test vectors, pseudocode, and links to reference code. For P2PKH and P2SH addresses with Base58 encoding, see https://en.bitcoin.it/Base58Check_encoding  

---

### Answer by username_1 on 2023-06-17. Score: 5

An address is a standardized encoding of an output script with a checksum. Because of this checksum, a blockchain explorer can (with a high probability) tell between a valid and an invalid address.

However, a valid address doesn't mean anyone has the private key(s) to be able to spend from it, or even that such a key exists. All the blockchain explorer can tell you is whether the address has ever received funds (which any valid address can) and spent funds (in which case the private key exists and someone has access to it, or at least had at some point).

As a side note, addresses don't actually appear in the blockchain, only output scripts, which the blockchain explorer then converts to addresses (provided that the script has a standard address encoding).

> **Comments:**
> **username_0**: Thank you! I would like to dive more into the subject, could you point in which direction I should look to learn more about "encoding of an output script with a checksum" (a little bit more specifically) and how does blockchain explorer uses it to predict if the address is valid or invalid?  Also, you say "received funds (which any valid address can)". But what about 1CounterpartyXXXXXXXXXXXXXXXUWLpVr? It has 2000 BTC, but doesn't seem to be a valid (if we talk about checksum) address. Or doesn't it?  
> **username_2**: @username_0 see [how does the blockchain addresses relate to the blockchain WIF?](https://bitcoin.stackexchange.com/q/115203/13866) and answers to [questions tagged "address generation"](https://bitcoin.stackexchange.com/questions/tagged/address-generation)  
> **username_3**: @username_0 The 1Counterparty address *is* valid. It's just that almost certainly, nobody has the corresponding private key, so those 2000 BTC won't ever move. But there is no way for Bitcoin software to *know* that nobody has the private key for it, so sending to it is valid.  
> **username_0**: @username_3, yeah, I understand this, but initially, I thought that you could actually send Bitcoins to any (even invalid) addresses. How do you determine that 1Counterparty is valid (valid in which sense, by the way)? Does the blockchain or Bitcoin software reject attempts to send transactions to invalid addresses?  
> **username_3**: As explained, Bitcoin addresses have a checksum built-in. The address is valid if it has a valid checksum. Computing the checksum doesn't require access to the corresponding private key. The 1Counterparty address has a valid checksum (that's where the weird UWLpVr at the end comes from). The checksum only protects against typos in the address, it has nothing to do with whether a private key for it is known.  
> **username_3**: Also note that this checksum does not exist on-chain (just like the rest of the address). You can send to any *script*, in theory. Some scripts (and practically, all the ones that are used) have a convenient human-friendly encoding that includes a checksum, called the address. In practice, wallet software will only let you send to scripts if you enter the corresponding valid address. The block explorer computes the address, including the checksum, based on the on-chain data.  
> **username_0**: @username_3 Omg, so many thanks! You reminded me that I read somewhere, and now I realize that the last 4 bytes on the right side are the checksum (specifically: first 4 bytes of the SHA-256 hash for the initial SHA-256 hash) of the key. Thanks a lot, correct if I am wrong!  

---

