<p>See <a href="https://en.bitcoin.it/wiki/Script#Standard_Generation_Transaction_.28pay-to-pubkey.29" rel="nofollow">the wiki</a>. Basically you have to extract the 20 byte <em>pubKeyHash</em> (shown as <em>bytes to push</em>) from the <em>scriptPubKey</em> and convert it to Base58 (which is also described in <a href="https://en.bitcoin.it/wiki/Base58Check_encoding" rel="nofollow">the wiki</a>.  There is no need to be online to perform this operation.</p>

CC BY-SA 3.0
2013-11-23T10:28:56.300Z
Are you sure that after doing Base58Check on "bytes to push" I will get bitcoin address? I have found this https://en.bitcoin.it/wiki/Technical_background_of_Bitcoin_addresses and it looks like they do Base58Check on 25-byte binary bitcoin address to get bitcoin address. And bytes to push are only 20 bytes long. I'm missing something?
Adam
CC BY-SA 3.0
2013-11-24T00:17:18.433Z
On https://en.bitcoin.it/wiki/Technical_background_of_Bitcoin_addresses the 20 bytes number after step 3 is the pubKeyHash you will find in the blockchain.  You need to do steps 4 to 9 to get the address.
RentFree
CC BY-SA 3.0
2013-11-22T13:59:34.810Z
2013-11-22T13:59:34.810Z
RentFree
<p>We have example in the wiki:</p>

<pre><code>[...]
Output 1:
 40 4B 4C 00 00 00 00 00                           - 0.05 BTC (5000000)
 19                                                - pk_script is 25 bytes long

 76 A9 14 1A A0 CD 1C BE  A6 E7 45 8A 7A BA D5 12  - pk_script
 A9 D9 EA 1A FB 22 5E 88  AC
[...]
</code></pre>

<p>What is the pk_script? Is it possible to translate it to bitcoin address being offline (not synced with network)? How to do this?</p>

<p><strong>EDIT:</strong></p>

<p>OK, I understand more right now:</p>

<pre><code> pk_script
 76 (OP_DUP)
 A9 (OP_HASH160)
 14 (Bytes to push)
 1A A0 CD 1C BE  A6 E7 45 8A 7A BA D5 12 A9 D9 EA 1A FB 22 5E (Data to push)
 88 (OP_EQUALVERIFY)
 AC (OP_CHECKSIG)
</code></pre>

<p>A I understand I should use <code>b58encode_check</code> on "data to push" to get bitcoin address. I have found python library which implements b58encode_check (<a href="https://pypi.python.org/pypi/base58" rel="nofollow">https://pypi.python.org/pypi/base58</a>) and did try with it:</p>

<pre><code>for byte in (0x1A, 0xA0, 0xCD, 0x1C, 0xBE,  0xA6, 0xE7, 0x45, 0x8A, 0x7A, 0xBA, 0xD5, 0x12, 0xA9, 0xD9, 0xEA, 0x1A, 0xFB, 0x22, 0x5E):
    buffer += chr(byte)
print b58encode_check(buffer)
</code></pre>

<p>But I got <code>3RoCeq4K8ddPW6ugcheFoXK4GC2Ajo7ZF</code> which don't look like bitcoin address. What I'm doing wrong?</p>

CC BY-SA 3.0
2016-05-25T13:31:22.797Z
did you find any answer to translate the script to the address?
Erhard Dinhobl
<development><address><protocol>
How get address from pk_script?
Adam
# How get address from pk_script?

(Asked by: username_0 on 2013-11-22)

We have example in the wiki:
[...]
Output 1:
 40 4B 4C 00 00 00 00 00                           - 0.05 BTC (5000000)
 19                                                - pk_script is 25 bytes long

 76 A9 14 1A A0 CD 1C BE  A6 E7 45 8A 7A BA D5 12  - pk_script
 A9 D9 EA 1A FB 22 5E 88  AC
[...]

What is the pk_script? Is it possible to translate it to bitcoin address being offline (not synced with network)? How to do this?
EDIT:
OK, I understand more right now:
 pk_script
 76 (OP_DUP)
 A9 (OP_HASH160)
 14 (Bytes to push)
 1A A0 CD 1C BE  A6 E7 45 8A 7A BA D5 12 A9 D9 EA 1A FB 22 5E (Data to push)
 88 (OP_EQUALVERIFY)
 AC (OP_CHECKSIG)

A I understand I should use b58encode_check on "data to push" to get bitcoin address. I have found python library which implements b58encode_check (https://pypi.python.org/pypi/base58) and did try with it:
for byte in (0x1A, 0xA0, 0xCD, 0x1C, 0xBE,  0xA6, 0xE7, 0x45, 0x8A, 0x7A, 0xBA, 0xD5, 0x12, 0xA9, 0xD9, 0xEA, 0x1A, 0xFB, 0x22, 0x5E):
    buffer += chr(byte)
print b58encode_check(buffer)

But I got 3RoCeq4K8ddPW6ugcheFoXK4GC2Ajo7ZF which don't look like bitcoin address. What I'm doing wrong?

**Tags:** development, address, protocol

> **Comments:**
> **username_1**: did you find any answer to translate the script to the address?  

---

## 1 answers

### Answer by username_2 on 2013-11-22. Score: 2 | Accepted answer

See [the wiki](https://en.bitcoin.it/wiki/Script#Standard_Generation_Transaction_.28pay-to-pubkey.29). Basically you have to extract the 20 byte *pubKeyHash* (shown as *bytes to push*) from the *scriptPubKey* and convert it to Base58 (which is also described in [the wiki](https://en.bitcoin.it/wiki/Base58Check_encoding). There is no need to be online to perform this operation.

> **Comments:**
> **username_0**: Are you sure that after doing Base58Check on "bytes to push" I will get bitcoin address? I have found this https://en.bitcoin.it/wiki/Technical_background_of_Bitcoin_addresses and it looks like they do Base58Check on 25-byte binary bitcoin address to get bitcoin address. And bytes to push are only 20 bytes long. I'm missing something?  
> **username_2**: On https://en.bitcoin.it/wiki/Technical_background_of_Bitcoin_addresses the 20 bytes number after step 3 is the pubKeyHash you will find in the blockchain.  You need to do steps 4 to 9 to get the address.  

---

