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,370 points
1,204 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,427 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,710 points
2,234 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,710 points
1,883 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,710 points
1,646 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,460 points
1,428 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,370 points
1,151 views
+1 vote
1 answer
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
1,923 views
+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
839 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