Getting Bitcoin address from pubkey_hash

0 votes

I want to get Bitcoin address from pubkey_hash. I am using the following code:

import util

hash = '62E907B15CBF27D5425399EBF6F0FB50EBB88F18'

print util.hash_to_address("00", hash)

Expected result:

1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa

Current result:

6GEZdxx5UiTk3U3LaLfsWwRaFAvXEpPNS5R4mqsJDXVJcTNNngTyB5i9S76MLTq

Need help.

Aug 22, 2018 in Blockchain by slayer
• 29,050 points
88 views

1 answer to this question.

0 votes

The unexpected result is due to encoding.

For Python 2

import util

hash = '62e907b15cbf27d5425399ebf6f0fb50ebb88f18'

print util.hash_to_address("00".decode('hex'), hash.decode('hex'))

For Python 3

import util

import binascii

hash = '62e907b15cbf27d5425399ebf6f0fb50ebb88f18'

print util.hash_to_address(binascii.unhexlify("00"), binascii.unhexlify(hash))

This will work.

answered Aug 22, 2018 by digger
• 26,550 points

Related Questions In Blockchain

0 votes
1 answer

Is there a way to send funds from a specific bitcoin address in a wallet?

I'll answer my own question, It was unbelievably ...READ MORE

answered Sep 3, 2018 in Blockchain by Perry
• 17,020 points
68 views
0 votes
1 answer

How can I retrieve to and from address in transaction directly from blockchain?

The spending conditions, i.e., who is able ...READ MORE

answered Jul 11, 2018 in Blockchain by Shashank
• 10,350 points
69 views
0 votes
1 answer

How are unique public address generated in bitcoin?

In brief, the public addresses are generated ...READ MORE

answered Jul 16, 2018 in Blockchain by slayer
• 29,050 points
46 views
0 votes
1 answer

Protocols used in a distributed/dlt system for the nodes to establish communication

yes all are over TCP/IP connections secured by TLS encryption in hashgraph architecture-hashgraph, ...READ MORE

answered Aug 6, 2018 in Blockchain by ariaholic
• 7,340 points
76 views
0 votes
1 answer

How to generate Bitcoin address?

Convert the hex string back to bytes ...READ MORE

answered Aug 20, 2018 in Blockchain by slayer
• 29,050 points
69 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

What is blockchain apart from bitcoin?

Blockchain is a decentralized database where the ...READ MORE

answered Jul 9, 2018 in Blockchain by digger
• 26,550 points
22 views