I'm working on my bitcoin parser and I'm running across some cases where I cannot decode the public key in an output script.
Here is an example:
See the coinbase transaction in block #199,975
https://blockchain.info/tx/870f2daaf1e6bf44fd23c98b152f5f5b45beeb7066eb135840809cb528579e87You will note that the output address that blockchain.info shows is:
1DgaASdtGgUavpNUE8ESBq3gmPbHh2ALnC
The hex address for this is:
0x00, 0x8b, 0x1d, 0x6a, 0x31, 0xb0, 0x19, 0xe2, 0xda, 0x16, 0xde, 0x77, 0xf6, 0x0c, 0x62, 0x3b, 0x14, 0x42, 0xd5, 0xec, 0x2e, 0x24, 0x3a, 0x00, 0x61
Normally I find the public key in the output script, but in this case I cannot figure out how/where blockchain.info came up with "1DgaASdtGgUavpNUE8ESBq3gmPbHh2ALnC" for the output script containing:
"021471c3e2c33f1a5255a514cbf9dbd322f82b957834e590ab99ff002630ebb7ee OP_CHECKSIG"
Any help/advice on what I'm missing to extract the public key from this output script would be most appreciated.
Thanks,
John
This transaction appears to use the obsolete "pay-to-pubkey" script instead of the more commonly used "pay-to-pubkey-hash".
Therefore, the value given in the script
IS the public key.
To see this public key represented as a bitcoin address, you need to follow the steps as described here:
https://en.bitcoin.it/wiki/Technical_background_of_Bitcoin_addressesSince you already have the public key, you are at the end of "step 1".
Step 2:
Perform SHA-256 hashing on the public key
A579A1CEDA2894FDDB360E9D2941907835A290C72BFEC0443E1EFF64AAA61EAA
Step 3:
Perform RIPEMD-160 hashing on the result of SHA-256
8B1D6A31B019E2DA16DE77F60C623B1442D5EC2E
Step 4:
Add version byte in front of RIPEMD-160 hash (0x00 for Main Network)
008B1D6A31B019E2DA16DE77F60C623B1442D5EC2E
Step 5:
Perform SHA-256 hash on the extended RIPEMD-160 result
F83469929812FE7835C4650BBC6E32DB092B545F0D546B597C8BFBA0C7C26BD8
Step 6:
Perform SHA-256 hash on the result of the previous SHA-256 hash
243A00619F100F1A1D84D418198875C023F45290574D5BAC64FEA8B7897B1852
Step 7:
Take the first 4 bytes of the second SHA-256 hash. This is the address checksum
243A0061
Step 8:
Add the 4 checksum bytes from stage 7 at the end of extended RIPEMD-160 hash from stage 4. This is the 25-byte binary Bitcoin Address
008B1D6A31B019E2DA16DE77F60C623B1442D5EC2E243A0061
Step 9:
Convert the result from a byte string into a base58 string using Base58Check encoding. This is the most commonly used Bitcoin Address format
1DgaASdtGgUavpNUE8ESBq3gmPbHh2ALnC