Bitcoin Forum
November 09, 2024, 02:47:24 AM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Blockchain.info unspent API  (Read 2459 times)
a63ntsm1th (OP)
Member
**
Offline Offline

Activity: 95
Merit: 11


View Profile
August 07, 2013, 07:41:01 PM
 #1

Blockchain.info's JSON api returns a transaction in a different encoding than the HTML version.

https://blockchain.info/unspent?active=1L1HUjdZjueR4mmcRNWkGp9rKLBCYWfkZn&format=html

The html formatted api returns a transaction id of: 7e5bdbc38649b967c415b4ab4d2d8a2096290f9ddec543c52ce780d0fe1b1002


https://blockchain.info/unspent?active=1L1HUjdZjueR4mmcRNWkGp9rKLBCYWfkZn&format=json

The json formatted response returns a transaction hash of: 02101bfed080e72cc543c5de9d0f2996208a2d4dabb415c467b94986c3db5b7e

What encoding is blockchain.info using in the HTML formatted list of unspent outputs?
What encoding is returned in the JSON formatted response?
What is the easiest way to convert between the two?

I would like to be able to convert the unspent hash returned by the JSON API into the same encoding used to search the blockchain.info HTML for a transaction.

Much thanks in advance to anyone who can help!

just my .02 btc
Jan
Legendary
*
Offline Offline

Activity: 1043
Merit: 1002



View Profile
August 08, 2013, 04:48:15 PM
 #2

One is the ASCII-HEX byte-wise reverse of the other.

Mycelium let's you hold your private keys private.
Jan
Legendary
*
Offline Offline

Activity: 1043
Merit: 1002



View Profile
August 08, 2013, 04:49:49 PM
 #3

One is the ASCII-HEX byte-wise reverse of the other.
That is, one starts with 7e, the other ends with 7e... Etc. 

Mycelium let's you hold your private keys private.
Amitabh S
Legendary
*
Offline Offline

Activity: 1001
Merit: 1005


View Profile
December 21, 2015, 08:22:10 PM
 #4

One is the ASCII-HEX byte-wise reverse of the other.

But why?

Coinsecure referral ID: https://coinsecure.in/signup/refamit (use this link to signup)
cetus
Newbie
*
Offline Offline

Activity: 22
Merit: 0


View Profile
December 21, 2015, 11:01:47 PM
 #5

One is the ASCII-HEX byte-wise reverse of the other.

But why?

That’s how transaction IDs appear in the Bitcoin protocol, where they are represented by byte-reversed transaction hashes.

I was curious and did some googling a while ago.  There have been discussions on this topic, but apparently, nobody knows why Satoshi chose it to be this way.

Here’s one possible explanation.  Internally, the SHA-256 algorithm works with 32-bit numbers rather than bytes.  Its specification says that when the hashing itself is done, the resulting numbers are converted to a byte sequence in big-endian byte order, and this byte sequence is the official SHA-256 hash.  Now, the Bitcoin protocol is little-endian.  So Satoshi may have decided to change this last step of SHA-256 to use little endian for consistency with the rest of the protocol.  (The order of words would have to change as well to preserve continuity.)  Also, because the most widely used processor architectures are little endian (x64, x86, ARM), Satoshi’s representation is simply a dump of the internal state of the hashing algorithm on these machines, without the additional byte swapping that would be required by the specification.
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!