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.
Check the Wiki. I think what you are looking for is point 3:
How to create Bitcoin Address
0 - Having a private ECDSA key
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)
2 - Perform SHA-256 hashing on the public key
3 - Perform RIPEMD-160 hashing on the result of SHA-256
4 - Add version byte in front of RIPEMD-160 hash (0x00 for Main Network)
5 - Perform SHA-256 hash on the extended RIPEMD-160 result
6 - Perform SHA-256 hash on the result of the previous SHA-256 hash
7 - Take the first 4 bytes of the second SHA-256 hash. This is the address checksum
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.
9 - Convert the result from a byte string into a base58 string using Base58Check encoding. This is the most commonly used Bitcoin Address format
You can check your calculations against my testing suite.
This wiki page 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 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.
You can use Casascius address utility to do various manipulations with keys, hashes and addresses.
protected by Murch♦ Apr 9 '14 at 22:24
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?