thanks looking in to it, and what about hash160 to btc address.,
where does the last 4 bytes we stripped off comes from ? while doinng hash 160 to btc address, i mean if we reverse the process.
Theose are the first 4 bytes of a double sha256 hash of the hash160 with the added first network byte. So the first network byte (mainnet is zero) and 160 bit number is 168 bits. You hash that with sha256 and the result hash again with sha256, then just take the first 4 bytes.
You can find more information here https://en.bitcoin.it/wiki/Technical_background_of_Bitcoin_addresses
okie., so far i have managed to do
bitcoin address to hash160
for p2pkh
for p2sh
hash160 to btc address
for p2pkh only
how to make it work with p2sh ?
thanks
why p2sh 's hash160 gives p2pkh address upon conversion through hash160 to bitcoin address and not the p2sh addresss ?
i mean
https://blockchain.info/address/39ZPyRrVR4jYoRG1f3MeMm9jES9SPZyMCB
has hash160 as 565015b43956dd69623061d66039ff854c0690ba
but if i go for
https://blockchain.info/address/565015b43956dd69623061d66039ff854c0690ba
i get Address 18sP3tN3sARAiFZaXwh3w8no5uriuM8Yyz
so if i again g o to
https://blockchain.info/address/18sP3tN3sARAiFZaXwh3w8no5uriuM8Yyz
i fuckin get Hash 160 565015b43956dd69623061d66039ff854c0690ba
so in short
https://blockchain.info/address/39ZPyRrVR4jYoRG1f3MeMm9jES9SPZyMCB
and
https://blockchain.info/address/18sP3tN3sARAiFZaXwh3w8no5uriuM8Yyz
both have same hash160 , how is that possible ?
something is not right., or its the way it is ?
my code is also giving same outputs as blockchain.info . so
![Huh](https://bitcointalk.org/Smileys/default/huh.gif)
![Huh](https://bitcointalk.org/Smileys/default/huh.gif)
![Huh](https://bitcointalk.org/Smileys/default/huh.gif)
![Huh](https://bitcointalk.org/Smileys/default/huh.gif)
thanks
This is because they are encoded differently. It seems that the only difference is that the version byte is 5 in P2SH instead of 0.
https://github.com/bitcoin/bips/blob/master/bip-0013.mediawiki
for p2pkh only
how to make it work with p2sh ?
why p2sh 's hash160 gives p2pkh address upon conversion through hash160 to bitcoin address and not the p2sh addresss ?
PS. don't create multiple threads for the same question, it'll fragment/split the answers and make things more confusing. Suggest you pick one thread and lock the other.
OP is just asking of getting hash 160 of a bitcoin address and vice versa, whether or not he understands what an address even is or what that hash 160 is of is a whole other story.