<p>The second output you are showing is using the <code>pay to pubkey</code> output script. Pay to pubkey (P2PK) eponymously locks funds to a public key. The corresponding input script only needs to provide a signature by the corresponding private key to spend the funds. The P2PK fell out of disuse for everything except mining outputs early on, and there never was a standard for encoding P2PK output scripts as addresses. The best way to track these is probably via the paid public key.</p>

CC BY-SA 4.0
2020-08-28T22:08:55.637Z
So for the second transaction here is what I see on blockchain explorer: (https://www.blockchain.com/btc/tx/dbaf14e1c476e76ea05a8b71921a46d6b06f0a950f17c5f9f1a03b8fae467f10)
It shows the address `1MdYC22Gmjp2ejVPCxyYjFyWbQCYTGhGq8`
You say there is no way to get this address directly from scriptPubKey ?
When you say paid public key does it mean I have to check this output as the VIN of another transaction? (if so JSON RPC doesn't show addresses for VIN)
Thank you very much !
Daniel
CC BY-SA 4.0
2020-08-29T00:07:31.393Z
@Daniel See my answer, it's not that the address can't be computed from the scriptPubKey, it's that depending on interpretation, that script doesn't *have* an address.
Pieter Wuille
CC BY-SA 4.0
2020-08-27T18:53:58.897Z
2020-08-27T18:53:58.897Z
Murch
<p>Answering this question requires first defining what an address means.</p>
<ol>
<li><p>Historically (before BIP16 activated in 2012) an address was a synonym with a &quot;public key identifier&quot;, as there were no addresses for multisig constructions or anything like that. Under this interpretation, pay-to-pubkey or pay-to-pubkey-hash outputs would be seen as having the same address - after all, the key is the same. This is problematic, because sending to the &quot;address&quot; corresponding to a pay-to-pubkey script would not actually send to that script, but to its corresponding pay-to-pubkey-hash script. Sufficiently old software, and some newer software (including some block explorers) use this interpretation, leading to confusion.</p>
</li>
<li><p>Most software now treats an address to be a human-readable notation for encoding specific scripts (corresponding to the script that would be constructed if a wallet were to be instructed to pay to said address). Under this interpretation, pay-to-pubkey outputs simply don't have an address (as there is no way to make wallet produce such outputs), and certainly not the same address as for the pay-to-pubkey-hash output with the same key.</p>
</li>
</ol>
<p>The software you're using follows interpretation (2), so the question makes little sense. It is showing you all addresses observed, but in this case, there just isn't any address involved. Transaction outputs in Bitcoin are freeform scripts, and only some of those have a corresponding address notation. Others are just scripts.</p>

CC BY-SA 4.0
2020-08-28T22:19:01.027Z
2020-08-29T00:37:27.183Z
2020-08-29T00:37:27.183Z
Pieter Wuille
<p>I am trying to get all existing addresses on the bitcoin blockchain with bitcoin-cli.
It seems that I can get addresses from vout that are of type &quot;pubkeyhash&quot;.
If the type of vout is &quot;pubkey&quot; there are no addresses.</p>
<p>pubkeyhash type:</p>
<pre><code>  &quot;vout&quot;: [
    {
      &quot;value&quot;: 0.00000001,
      &quot;n&quot;: 0,
      &quot;scriptPubKey&quot;: {
        &quot;asm&quot;: &quot;OP_DUP OP_HASH160 b04e3fb6f6c96ba23233c809e42d8e6a0e0e31ca OP_EQUALVERIFY OP_CHECKSIG&quot;,
        &quot;hex&quot;: &quot;76a914b04e3fb6f6c96ba23233c809e42d8e6a0e0e31ca88ac&quot;,
        &quot;reqSigs&quot;: 1,
        &quot;type&quot;: &quot;pubkeyhash&quot;,
        &quot;addresses&quot;: [
          &quot;1H5DfbDtCnKUdke9xH9svwwxqga41Z5xbz&quot;
        ]
      }
    }
</code></pre>
<p>pubkey type:</p>
<pre><code>  &quot;vout&quot;: [
    {
      &quot;value&quot;: 50.63517500,
      &quot;n&quot;: 0,
      &quot;scriptPubKey&quot;: {
        &quot;asm&quot;: &quot;04b0bd634234abbb1ba1e986e884185c61cf43e001f9137f23c2c409273eb16e6537a576782eba668a7ef8bd3b3cfb1edb7117ab65129b8a2e681f3c1e0908ef7b OP_CHECKSIG&quot;,
        &quot;hex&quot;: &quot;4104b0bd634234abbb1ba1e986e884185c61cf43e001f9137f23c2c409273eb16e6537a576782eba668a7ef8bd3b3cfb1edb7117ab65129b8a2e681f3c1e0908ef7bac&quot;,
        &quot;type&quot;: &quot;pubkey&quot;
      }
    }
</code></pre>
<p>Is there an easy way to get ALL the addresses on the blockchain?</p>

<address><bitcoin-cli><p2pk>
How to extract all the bitcoin addresses with bitcoin-cli?
Daniel
# How to extract all the bitcoin addresses with bitcoin-cli?

(Asked by: username_0 on 2020-08-27)

I am trying to get all existing addresses on the bitcoin blockchain with bitcoin-cli.
It seems that I can get addresses from vout that are of type "pubkeyhash".
If the type of vout is "pubkey" there are no addresses.

pubkeyhash type:

```
  "vout": [
    {
      "value": 0.00000001,
      "n": 0,
      "scriptPubKey": {
        "asm": "OP_DUP OP_HASH160 b04e3fb6f6c96ba23233c809e42d8e6a0e0e31ca OP_EQUALVERIFY OP_CHECKSIG",
        "hex": "76a914b04e3fb6f6c96ba23233c809e42d8e6a0e0e31ca88ac",
        "reqSigs": 1,
        "type": "pubkeyhash",
        "addresses": [
          "1H5DfbDtCnKUdke9xH9svwwxqga41Z5xbz"
        ]
      }
    }

```

pubkey type:

```
  "vout": [
    {
      "value": 50.63517500,
      "n": 0,
      "scriptPubKey": {
        "asm": "04b0bd634234abbb1ba1e986e884185c61cf43e001f9137f23c2c409273eb16e6537a576782eba668a7ef8bd3b3cfb1edb7117ab65129b8a2e681f3c1e0908ef7b OP_CHECKSIG",
        "hex": "4104b0bd634234abbb1ba1e986e884185c61cf43e001f9137f23c2c409273eb16e6537a576782eba668a7ef8bd3b3cfb1edb7117ab65129b8a2e681f3c1e0908ef7bac",
        "type": "pubkey"
      }
    }

```

Is there an easy way to get ALL the addresses on the blockchain?

**Tags:** address, bitcoin-cli, p2pk


---

## 2 answers

### Answer by username_2 on 2020-08-28. Score: 5 | Accepted answer

Answering this question requires first defining what an address means.

1. Historically (before BIP16 activated in 2012) an address was a synonym with a "public key identifier", as there were no addresses for multisig constructions or anything like that. Under this interpretation, pay-to-pubkey or pay-to-pubkey-hash outputs would be seen as having the same address - after all, the key is the same. This is problematic, because sending to the "address" corresponding to a pay-to-pubkey script would not actually send to that script, but to its corresponding pay-to-pubkey-hash script. Sufficiently old software, and some newer software (including some block explorers) use this interpretation, leading to confusion.
2. Most software now treats an address to be a human-readable notation for encoding specific scripts (corresponding to the script that would be constructed if a wallet were to be instructed to pay to said address). Under this interpretation, pay-to-pubkey outputs simply don't have an address (as there is no way to make wallet produce such outputs), and certainly not the same address as for the pay-to-pubkey-hash output with the same key.

The software you're using follows interpretation (2), so the question makes little sense. It is showing you all addresses observed, but in this case, there just isn't any address involved. Transaction outputs in Bitcoin are freeform scripts, and only some of those have a corresponding address notation. Others are just scripts.


---

### Answer by username_1 on 2020-08-27. Score: 2

The second output you are showing is using the `pay to pubkey` output script. Pay to pubkey (P2PK) eponymously locks funds to a public key. The corresponding input script only needs to provide a signature by the corresponding private key to spend the funds. The P2PK fell out of disuse for everything except mining outputs early on, and there never was a standard for encoding P2PK output scripts as addresses. The best way to track these is probably via the paid public key.

> **Comments:**
> **username_0**: So for the second transaction here is what I see on blockchain explorer: (https://www.blockchain.com/btc/tx/dbaf14e1c476e76ea05a8b71921a46d6b06f0a950f17c5f9f1a03b8fae467f10) It shows the address `1MdYC22Gmjp2ejVPCxyYjFyWbQCYTGhGq8` You say there is no way to get this address directly from scriptPubKey ? When you say paid public key does it mean I have to check this output as the VIN of another transaction? (if so JSON RPC doesn't show addresses for VIN) Thank you very much !  
> **username_2**: @username_0 See my answer, it's not that the address can't be computed from the scriptPubKey, it's that depending on interpretation, that script doesn't *have* an address.  

---

