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?

3 Answers 3

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.

2
  • what you mean "It"? The address 17afxUJouat3fkaaQ9tZrDThxdkXGL4WrM?
    – Carpemer
    Sep 6, 2018 at 14:51
  • @Capemer I have edited it.
    – MCCCS
    Sep 6, 2018 at 15:23
0

I gusses the command decoderawtransacton can help you

2
  • 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
    Sep 7, 2018 at 16:54
  • The question here is how to convert 482f0027662731277fdfa3b7f639c976a3bab11e to it's address 146sN8tLxV2xueQXQgMJkMZi2hFazEuV8F
    – Carpemer
    Sep 8, 2018 at 0:17
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'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.