Bitcoin Forum
September 10, 2024, 09:18:14 PM *
News: Latest Bitcoin Core release: 27.1 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: BlockChain.info unspent api  (Read 650 times)
bitspill (OP)
Legendary
*
Offline Offline

Activity: 2087
Merit: 1015



View Profile
May 26, 2013, 05: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?

{ BitSpill }
piuk
Hero Member
*****
Offline Offline

Activity: 910
Merit: 1005



View Profile WWW
May 26, 2013, 07: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.


bitspill (OP)
Legendary
*
Offline Offline

Activity: 2087
Merit: 1015



View Profile
May 26, 2013, 09:03:02 PM
 #3

Ok, cool I figured I was doing something wrong

Thank piuk for the info and great service.

{ BitSpill }
bitspill (OP)
Legendary
*
Offline Offline

Activity: 2087
Merit: 1015



View Profile
June 06, 2013, 07: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;
 }

{ BitSpill }
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!