Author

Topic: BlockChain.info unspent api (Read 655 times)

legendary
Activity: 2087
Merit: 1015
June 06, 2013, 03:17:33 AM
#4
Finally had time to sit down and implement this and wanted to both receive criticism for my code and to allow others to use it if they wish.

The code turned out to be extremely simple and works directly with the string representation itself so there is no decode/re-encode necessary

Code: (php)
function reverseHash($hash){
     $ret = "";
     for($i = 0; $i<63; $i+=2){
         $ret .= $hash[62-$i].$hash[63-$i];
     }
     return $ret;
 }
legendary
Activity: 2087
Merit: 1015
May 26, 2013, 05:03:02 PM
#3
Ok, cool I figured I was doing something wrong

Thank piuk for the info and great service.
hero member
Activity: 910
Merit: 1005
May 26, 2013, 03:55:18 PM
#2
The hashes are reversed. So in order to get the correct hash - decode the hex, reverse the bytes and re-encode as hex.

legendary
Activity: 2087
Merit: 1015
May 26, 2013, 01:09:53 PM
#1
Am I reading this wrong or do these return different results?

http://blockchain.info/unspent?active=1BLockgUZ45M3NDWmCfbptLRnmiFnHpF2b&format=html
http://blockchain.info/unspent?active=1BLockgUZ45M3NDWmCfbptLRnmiFnHpF2b


The format=html version appears to match the general address page https://blockchain.info/address/1BLockgUZ45M3NDWmCfbptLRnmiFnHpF2b However the json response appears to have incorrect tx_hashes.

Searching for the tx_hashes returns "Sorry we could not find any blocks or transactions matching this hash" http://blockchain.info/search?search=b9dca2e74e326ce89cf64934b06fe677826d47ed6b4510df0dc1e4d3b42e5af3

Am I reading something wrong here or is the api indeed returning incorrect results?
Jump to: