How to get the addr from this transaction

0

https://www.blockchain.com/btc/tx/2ccc3f59d28c709770a8bc478b112e10feda4bf55197c2e48deaa0eb6bca0311?show_adv=true

The SCRIPT in the transaction is:

DUP HASH160 PUSHDATA(20)[482f0027662731277fdfa3b7f639c976a3bab11e] EQUALVERIFY CHECKSIG

What is 482f0027662731277fdfa3b7f639c976a3bab11e ?

It is not a pubKey. RIPEMD160(SHA256(482f0027662731277fdfa3b7f639c976a3bab11e)=146sN8tLxV2xueQXQgMJkMZi2hFazEuV8F.

The result is not the address(17afxUJouat3fkaaQ9tZrDThxdkXGL4WrM) in the blockchain.info either.

How we convert the 482f0027662731277fdfa3b7f639c976a3bab11e to it's addr?

Carpemer

Posted 2018-09-06T14:31:18.327

Reputation: 117

Answers

2

482f0027662731277fdfa3b7f639c976a3bab11e is HASH160 (RIPEMD160(SHA256())) of the public key. The hash is the most important part of addresses (addres: network byte + hash + checksum).

You can look at how P2PKH script works step-by-step here.

MCCCS

Posted 2018-09-06T14:31:18.327

Reputation: 5 827

what you mean "It"? The address 17afxUJouat3fkaaQ9tZrDThxdkXGL4WrM?Carpemer 2018-09-06T14:51:55.840

@Capemer I have edited it.MCCCS 2018-09-06T15:23:09.420

0

I gusses the command decoderawtransacton can help you

老板鱼丸粗面

Posted 2018-09-06T14:31:18.327

Reputation: 31

Hi @老板鱼丸粗面, can you provide some more context, maybe some documentation, an example output and how to run the command? Short answers often don't provide enough context to be helpful.JBaczuk 2018-09-07T16:54:57.633

The question here is how to convert 482f0027662731277fdfa3b7f639c976a3bab11e to it's address 146sN8tLxV2xueQXQgMJkMZi2hFazEuV8FCarpemer 2018-09-08T00:17:39.850

0

Thanks for the answer here, the final code for the question is:

import hashlib
import base58 

def gen_addr(hash_code):
  key_hash = '00' + hash_code
  # Obtain signature:
  sha = hashlib.sha256()
  sha.update( bytearray.fromhex(key_hash) )
  checksum = sha.digest()
  sha = hashlib.sha256()
  sha.update(checksum)
  checksum = sha.hexdigest()[0:8]
  address = (base58.b58encode( bytes(bytearray.fromhex(key_hash + checksum)))).decode('utf-8')
  return address, key_hash, checksum

gen_addr('482f0027662731277fdfa3b7f639c976a3bab11e')='17afxUJouat3fkaaQ9tZrDThxdkXGL4WrM'

Carpemer

Posted 2018-09-06T14:31:18.327

Reputation: 117