How get address from pk_script?

0

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?

Adam

Posted 2013-11-22T13:33:18.393

Reputation: 175

did you find any answer to translate the script to the address?Erhard Dinhobl 2016-05-25T13:31:22.797

Answers

1

See the wiki. 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. There is no need to be online to perform this operation.

RentFree

Posted 2013-11-22T13:33:18.393

Reputation: 2 391

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 2013-11-23T10:28:56.300

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 2013-11-24T00:17:18.433