<p>OP_1 [pubkey] OP_1 OP_CHECKMULTISIG</p>

CC BY-SA 3.0
2016-11-02T06:29:59.860Z
2016-11-02T06:29:59.860Z
amaclin
<p>Technically, <code>pay-to-pubkey</code> doesn't have an address type. You can derive an address as if it were a <code>pay-to-pubkeyhash</code> scriptPubKey, but there is a subtle difference. </p>

<p>The other type you are forgetting is a <code>pay-to-scripthash</code> type. It's of the format </p>

<p><code>OP_HASH160 &lt;Hash160(redeemScript)&gt; OP_EQUAL</code></p>

<p>Then, you get a p2sh adddress by prepending the version byte and appending the checksum to <code>&lt;Hash160(redeemScript)&gt;</code></p>

CC BY-SA 3.0
2016-11-01T17:16:38.407Z
2016-11-01T17:16:38.407Z
Chris Stewart
<p>I'm trying to get the addresses from the <code>ScriptPubKey</code>s in each transaction (where possible). So far, I know of two patterns of <code>ScriptPubKey</code> where an address can be found:</p>

<p><strong>1. Pay-To-Pubkey</strong></p>

<pre><code>04e70a02f5af48a1989bf630d92523c9d14c45c75f7d1b998e962bff6ff9995fc5bdb44f1793b37495d80324acba7c8f537caaf8432b8d47987313060cc82d8a93 OP_CHECKSIG
</code></pre>

<p>In this locking script, the code before <code>OP_CHECKSIG</code> is a public key, so that can be converted in to an address.</p>

<p><strong>2. Pay-To-Pubkey-Hash</strong></p>

<pre><code>OP_DUP OP_HASH160 3d37cde30fdfcf29b2996a7ceefd220ba32c9f4b OP_EQUALVERIFY OP_CHECKSIG
</code></pre>

<p>In this one, the code after <code>OP_HASH160</code> (and before the next <code>OP</code> code) is the hash160 of a public key, so that can be converted to an address also.</p>

<p><strong>Question:</strong></p>

<p>Are there any other patterns of <code>ScriptPubKey</code> where addresses can be found?</p>

<p>Or in other words, will I be able to capture every address by working on all non-opcodes <em>before</em> <code>OP_CHECKSIG</code>, and all non-opcodes <em>after</em> <code>OP_HASH160</code>?</p>

<address><script>
Types of ScriptPubKey that can contain addresses
inersha
# Types of ScriptPubKey that can contain addresses

(Asked by: username_0 on 2016-11-01)

I'm trying to get the addresses from the `ScriptPubKey`s in each transaction (where possible). So far, I know of two patterns of `ScriptPubKey` where an address can be found:

**1. Pay-To-Pubkey**

```
04e70a02f5af48a1989bf630d92523c9d14c45c75f7d1b998e962bff6ff9995fc5bdb44f1793b37495d80324acba7c8f537caaf8432b8d47987313060cc82d8a93 OP_CHECKSIG

```

In this locking script, the code before `OP_CHECKSIG` is a public key, so that can be converted in to an address.

**2. Pay-To-Pubkey-Hash**

```
OP_DUP OP_HASH160 3d37cde30fdfcf29b2996a7ceefd220ba32c9f4b OP_EQUALVERIFY OP_CHECKSIG

```

In this one, the code after `OP_HASH160` (and before the next `OP` code) is the hash160 of a public key, so that can be converted to an address also.

**Question:**

Are there any other patterns of `ScriptPubKey` where addresses can be found?

Or in other words, will I be able to capture every address by working on all non-opcodes *before* `OP_CHECKSIG`, and all non-opcodes *after* `OP_HASH160`?

**Tags:** address, script


---

## 2 answers

### Answer by username_1 on 2016-11-02. Score: 1

OP\_1 [pubkey] OP\_1 OP\_CHECKMULTISIG


---

### Answer by username_2 on 2016-11-01. Score: 1

Technically, `pay-to-pubkey` doesn't have an address type. You can derive an address as if it were a `pay-to-pubkeyhash` scriptPubKey, but there is a subtle difference.

The other type you are forgetting is a `pay-to-scripthash` type. It's of the format

`OP_HASH160 <Hash160(redeemScript)> OP_EQUAL`

Then, you get a p2sh adddress by prepending the version byte and appending the checksum to `<Hash160(redeemScript)>`


---

