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,350 points
971 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,740 points

Related Questions In Blockchain

+1 vote
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,100 points
1,242 views
+1 vote
0 answers

How to check a Bitcoin wallet balance from first generated address (m/44'/0'/0'/0/0)

Is there a way to check a ...READ MORE

Mar 4, 2022 in Blockchain by Soham
• 9,700 points
1,953 views
+1 vote
0 answers

How to check a Bitcoin wallet balance from first generated address (m/44'/0'/0'/0/0)

Is there a way to check a ...READ MORE

Mar 9, 2022 in Blockchain by Soham
• 9,700 points
1,332 views
+1 vote
0 answers

How to generate bitcoin address from XPUB

How to generate bitcoin addresses from XPUB ...READ MORE

Mar 9, 2022 in Blockchain by Soham
• 9,700 points
1,450 views
+1 vote
1 answer

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

yes all are over TCP/IP connections secured ...READ MORE

answered Aug 6, 2018 in Blockchain by aryya
• 7,450 points
1,143 views
+1 vote
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,350 points
843 views
+1 vote
1 answer
+1 vote
1 answer
+1 vote
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,740 points
587 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP