<p>Check the <a href="https://en.bitcoin.it/wiki/Technical_background_of_Bitcoin_addresses" rel="noreferrer">Wiki</a>. I think what you are looking for is point 3:</p>

<blockquote>
  <p><strong>How to create Bitcoin Address</strong></p>
  
  <p>0 - Having a private ECDSA key</p>
  
  <p>18E14A7B6A307F426A94F8114701E7C8E774E7F9A47E2C2035DB29A206321725</p>
  
  <p>1 - Take the corresponding public key generated with it (65 bytes, 1
  byte 0x04, 32 bytes corresponding to X coordinate, 32 bytes
  corresponding to Y coordinate)</p>
  
  <p>0450863AD64A87AE8A2FE83C1AF1A8403CB53F53E486D8511DAD8A04887E5B23522CD470243453A299FA9E77237716103ABC11A1DF38855ED6F2EE187E9C582BA6</p>
  
  <p>2 - Perform SHA-256 hashing on the public key</p>
  
  <p>600FFE422B4E00731A59557A5CCA46CC183944191006324A447BDB2D98D4B408</p>
  
  <p>3 - Perform RIPEMD-160 hashing on the result of SHA-256</p>
  
  <p>010966776006953D5567439E5E39F86A0D273BEE</p>
  
  <p>4 - Add version byte in front of RIPEMD-160 hash (0x00 for Main
  Network)</p>
  
  <p>00010966776006953D5567439E5E39F86A0D273BEE</p>
  
  <p>5 - Perform SHA-256 hash on the extended RIPEMD-160 result</p>
  
  <p>445C7A8007A93D8733188288BB320A8FE2DEBD2AE1B47F0F50BC10BAE845C094</p>
  
  <p>6 - Perform SHA-256 hash on the result of the previous SHA-256 hash</p>
  
  <p>D61967F63C7DD183914A4AE452C9F6AD5D462CE3D277798075B107615C1A8A30</p>
  
  <p>7 - Take the first 4 bytes of the second SHA-256 hash. This is the
  address checksum</p>
  
  <p>D61967F6</p>
  
  <p>8 - Add the 4 checksum bytes from point 7 at the end of extended
  RIPEMD-160 hash from point 4. This is the 25-byte binary Bitcoin
  Address.</p>
  
  <p>00010966776006953D5567439E5E39F86A0D273BEED61967F6</p>
  
  <p>9 - Convert the result from a byte string into a base58 string using
  Base58Check encoding. This is the most commonly used Bitcoin Address
  format</p>
  
  <p>16UwLL9Risc3QfPqBUvKofHmBQ7wMtjvM</p>
</blockquote>

<p>You can check your calculations against <a href="http://gobittest.appspot.com" rel="noreferrer">my testing suite</a>.</p>

CC BY-SA 3.0
2014-04-07T21:22:49.563Z
Please can you explain the steps for me and I appreciate help
kem
CC BY-SA 3.0
2014-04-08T08:33:17.307Z
@ThePiachu: The OP asked about the opposite process from what you described. You're describing how to go from the private key all the way to the address. He's asking how to get from the address to the pubkeyhash - that is, undoing step 9. Of course, I only know what he asked, not what he wants to know.
Meni Rosenfeld
CC BY-SA 3.0
2012-10-09T16:44:41.067Z
Thanks! Unfortunately, point 0 is where I get lost... Does calculating the hash require access to the private key? Can I sign a coinbase transaction using a bitcoin address bypassing the need to calculate the HASH160?
user789235
CC BY-SA 3.0
2012-10-09T18:19:39.370Z
@user789235 If you want to SPEND the transaction, you need a private key. If you want to specify the recipient of the transaction, you only need to put the address in and some ops. Read here for more info https://en.bitcoin.it/wiki/Script#Scripts
ThePiachu
CC BY-SA 3.0
2012-10-09T23:38:20.217Z
Thank you. I'm pretty sure I get it. So, I now want to create a signature of a testnet coinbase transaction. Is there an easier way to get the hash than starting with generating a public/private key pair from scratch?
user789235
CC BY-SA 3.0
2012-10-10T10:31:50.597Z
@user789235 If you just want to create a coinbase transaction that credits a given address their coins, you just specify the public key or address in the output script. If you want to create a transaction that spends the coinbase input, I have no idea how to do that.
ThePiachu
CC BY-SA 3.0
2012-10-10T20:07:40.370Z
Could you incorporate part of the info from the wiki in your answer so that the answer is not dependant on "point 3" on the wiki staying the same. Thanks!
D.H.
CC BY-SA 3.0
2012-10-11T07:17:45.383Z
@D.H. Thanks for the suggestion, edited accordingly.
ThePiachu
CC BY-SA 3.0
2012-10-09T16:39:23.490Z
2012-10-11T07:17:28.363Z
2012-10-11T07:17:28.363Z
ThePiachu
<p>This <a href="https://en.bitcoin.it/wiki/Base58Check_encoding#Creating_a_Base58Check_string" rel="nofollow">wiki page</a> is probably more helpful.  It describes how the bitcoin address is created from the 160 bit hash.  You need to run those steps backwards to get back to the 160 bit hash.</p>

<p>For example, if your address is 1HgiEYL6fsKrfh8wuMhAGfvSc6PY5ZXJdv, you first count and remove the 1's from the start.  There's only one '1' in most addresses.  Remember this for later.</p>

<p>With the rest of the address, use <a href="https://en.bitcoin.it/wiki/Base58Check_encoding#Base58_symbol_chart" rel="nofollow">this page</a> to convert each character into its base58 value:  'H' -> 16, 'g' -> 39, 'i' -> 41, ..., 'v' -> 53 etc.  So you have a list of values: [16, 39, 41, ..., 53].</p>

<p>Then combine all these values into a single large number:</p>

<pre><code>(([...](((16) * 58 + 39) * 58 + 41) ...) * 58 + 53) 
</code></pre>

<p>Convert the single large number into a sequence of bytes, prepend the same number of 00 bytes as the number of '1's you initially removed from the address, remove the last 4 bytes (that's the checksum), remove the first zero byte (that's the version byte), and there's your 160 bit hash.</p>

CC BY-SA 3.0
2012-10-10T17:14:26.053Z
Perfect! I'll start the calculation. As a lazy mathematician's way of getting what I'm looking for, I came up with this approach. I'm not sure it's valid, but I send 20btc on testnet to the address for which I wanted a HASH160. That transaction is [here](http://blockexplorer.com/testnet/rawblock/0000000086a635fea78ba25f59e13927b0199d4785430fe20e6941818469b41f) I *think* I can use the hash from this transaction. But I'll do the math to confirm....
user789235
CC BY-SA 3.0
2012-10-11T03:27:48.907Z
I don't think the testnet client will accept a regular bitcoin address as being valid.  Maybe I've misunderstood what you did.
Chris Moore
CC BY-SA 3.0
2012-10-10T14:08:48.850Z
2012-10-10T14:08:48.850Z
Chris Moore
<p>For regular addresses you can use the <a href="https://blockexplorer.com/q/addresstohash" rel="nofollow">addresstohash</a> <a href="https://blockexplorer.com/q" rel="nofollow">tool</a> in blockexplorer.</p>

<p>For testnet addresses you can open <code>https://blockexplorer.com/testnet/address/the address you want</code> and read the Hash160 field. This works for addresses which aren't in the block chain too.</p>

CC BY-SA 3.0
2012-10-25T22:46:12.600Z
Thanks. This was the easy answer I need for my one off test!
user789235
CC BY-SA 3.0
2012-10-11T21:28:06.070Z
2012-10-11T21:28:06.070Z
user1729061
<p>You can use <a href="http://www.google.co.il/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=1&amp;cad=rja&amp;uact=8&amp;ved=0CCkQFjAA&amp;url=http://casascius.wordpress.com/2013/01/26/bitcoin-address-utility/&amp;ei=irRDU8utOuGGywPLuYCgCA&amp;usg=AFQjCNE0eJMElanpEKLxdsOgYuD-BbNnIA&amp;sig2=4N3cUwwb_t89pZlNkVetrw&amp;bvm=bv.64367178,d.bGE" rel="nofollow">Casascius address utility</a> to do various manipulations with keys, hashes and addresses.</p>

CC BY-SA 3.0
2014-04-08T08:35:02.380Z
2014-04-08T08:35:02.380Z
Meni Rosenfeld
<p>I'm trying to sign a coinbase transaction. I know I need to use <code>76 A9 14 (HASH160) 88 AC</code> but I don't understand how to create the HASH160 (20 byte) from a bitcoin address.</p>

<script><coinbase.com>
How do you get the OP_HASH160 value from a bitcoin address?
user789235
# How do you get the OP_HASH160 value from a bitcoin address?

(Asked by: username_0 on 2012-10-09)

I'm trying to sign a coinbase transaction. I know I need to use `76 A9 14 (HASH160) 88 AC` but I don't understand how to create the HASH160 (20 byte) from a bitcoin address.

**Tags:** script, coinbase.com


---

## 4 answers

### Answer by username_1 on 2012-10-09. Score: 6

Check the [Wiki](https://en.bitcoin.it/wiki/Technical_background_of_Bitcoin_addresses). I think what you are looking for is point 3:

> **How to create Bitcoin Address**
>
> 0 - Having a private ECDSA key
>
> 18E14A7B6A307F426A94F8114701E7C8E774E7F9A47E2C2035DB29A206321725
>
> 1 - Take the corresponding public key generated with it (65 bytes, 1
> byte 0x04, 32 bytes corresponding to X coordinate, 32 bytes
> corresponding to Y coordinate)
>
> 0450863AD64A87AE8A2FE83C1AF1A8403CB53F53E486D8511DAD8A04887E5B23522CD470243453A299FA9E77237716103ABC11A1DF38855ED6F2EE187E9C582BA6
>
> 2 - Perform SHA-256 hashing on the public key
>
> 600FFE422B4E00731A59557A5CCA46CC183944191006324A447BDB2D98D4B408
>
> 3 - Perform RIPEMD-160 hashing on the result of SHA-256
>
> 010966776006953D5567439E5E39F86A0D273BEE
>
> 4 - Add version byte in front of RIPEMD-160 hash (0x00 for Main
> Network)
>
> 00010966776006953D5567439E5E39F86A0D273BEE
>
> 5 - Perform SHA-256 hash on the extended RIPEMD-160 result
>
> 445C7A8007A93D8733188288BB320A8FE2DEBD2AE1B47F0F50BC10BAE845C094
>
> 6 - Perform SHA-256 hash on the result of the previous SHA-256 hash
>
> D61967F63C7DD183914A4AE452C9F6AD5D462CE3D277798075B107615C1A8A30
>
> 7 - Take the first 4 bytes of the second SHA-256 hash. This is the
> address checksum
>
> D61967F6
>
> 8 - Add the 4 checksum bytes from point 7 at the end of extended
> RIPEMD-160 hash from point 4. This is the 25-byte binary Bitcoin
> Address.
>
> 00010966776006953D5567439E5E39F86A0D273BEED61967F6
>
> 9 - Convert the result from a byte string into a base58 string using
> Base58Check encoding. This is the most commonly used Bitcoin Address
> format
>
> 16UwLL9Risc3QfPqBUvKofHmBQ7wMtjvM

You can check your calculations against [my testing suite](http://gobittest.appspot.com).

> **Comments:**
> **username_0**: Thanks! Unfortunately, point 0 is where I get lost... Does calculating the hash require access to the private key? Can I sign a coinbase transaction using a bitcoin address bypassing the need to calculate the HASH160?  
> **username_1**: @username_0 If you want to SPEND the transaction, you need a private key. If you want to specify the recipient of the transaction, you only need to put the address in and some ops. Read here for more info https://en.bitcoin.it/wiki/Script#Scripts  
> **username_0**: Thank you. I'm pretty sure I get it. So, I now want to create a signature of a testnet coinbase transaction. Is there an easier way to get the hash than starting with generating a public/private key pair from scratch?  
> **username_1**: @username_0 If you just want to create a coinbase transaction that credits a given address their coins, you just specify the public key or address in the output script. If you want to create a transaction that spends the coinbase input, I have no idea how to do that.  
> **username_4**: Could you incorporate part of the info from the wiki in your answer so that the answer is not dependant on "point 3" on the wiki staying the same. Thanks!  
> **username_1**: @D.H. Thanks for the suggestion, edited accordingly.  
> **username_2**: Please can you explain the steps for me and I appreciate help  
> **username_3**: @username_1: The OP asked about the opposite process from what you described. You're describing how to go from the private key all the way to the address. He's asking how to get from the address to the pubkeyhash - that is, undoing step 9. Of course, I only know what he asked, not what he wants to know.  

---

### Answer by username_5 on 2012-10-10. Score: 2

This [wiki page](https://en.bitcoin.it/wiki/Base58Check_encoding#Creating_a_Base58Check_string) is probably more helpful. It describes how the bitcoin address is created from the 160 bit hash. You need to run those steps backwards to get back to the 160 bit hash.

For example, if your address is 1HgiEYL6fsKrfh8wuMhAGfvSc6PY5ZXJdv, you first count and remove the 1's from the start. There's only one '1' in most addresses. Remember this for later.

With the rest of the address, use [this page](https://en.bitcoin.it/wiki/Base58Check_encoding#Base58_symbol_chart) to convert each character into its base58 value: 'H' -> 16, 'g' -> 39, 'i' -> 41, ..., 'v' -> 53 etc. So you have a list of values: [16, 39, 41, ..., 53].

Then combine all these values into a single large number:

```
(([...](((16) * 58 + 39) * 58 + 41) ...) * 58 + 53) 

```

Convert the single large number into a sequence of bytes, prepend the same number of 00 bytes as the number of '1's you initially removed from the address, remove the last 4 bytes (that's the checksum), remove the first zero byte (that's the version byte), and there's your 160 bit hash.

> **Comments:**
> **username_0**: Perfect! I'll start the calculation. As a lazy mathematician's way of getting what I'm looking for, I came up with this approach. I'm not sure it's valid, but I send 20btc on testnet to the address for which I wanted a HASH160. That transaction is [here](http://blockexplorer.com/testnet/rawblock/0000000086a635fea78ba25f59e13927b0199d4785430fe20e6941818469b41f) I *think* I can use the hash from this transaction. But I'll do the math to confirm....  
> **username_5**: I don't think the testnet client will accept a regular bitcoin address as being valid.  Maybe I've misunderstood what you did.  

---

### Answer by username_6 on 2012-10-11. Score: 1

For regular addresses you can use the [addresstohash](https://blockexplorer.com/q/addresstohash) [tool](https://blockexplorer.com/q) in blockexplorer.

For testnet addresses you can open `https://blockexplorer.com/testnet/address/the address you want` and read the Hash160 field. This works for addresses which aren't in the block chain too.

> **Comments:**
> **username_0**: Thanks. This was the easy answer I need for my one off test!  

---

### Answer by username_3 on 2014-04-08. Score: 0

You can use [Casascius address utility](http://www.google.co.il/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0CCkQFjAA&url=http://casascius.wordpress.com/2013/01/26/bitcoin-address-utility/&ei=irRDU8utOuGGywPLuYCgCA&usg=AFQjCNE0eJMElanpEKLxdsOgYuD-BbNnIA&sig2=4N3cUwwb_t89pZlNkVetrw&bvm=bv.64367178,d.bGE) to do various manipulations with keys, hashes and addresses.


---

