Author

Topic: Blockchain.info unspent API (Read 2460 times)

newbie
Activity: 22
Merit: 0
December 21, 2015, 06: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.
legendary
Activity: 1001
Merit: 1005
December 21, 2015, 03:22:10 PM
#4
One is the ASCII-HEX byte-wise reverse of the other.

But why?
Jan
legendary
Activity: 1043
Merit: 1002
August 08, 2013, 11:49:49 AM
#3
One is the ASCII-HEX byte-wise reverse of the other.
That is, one starts with 7e, the other ends with 7e... Etc. 
Jan
legendary
Activity: 1043
Merit: 1002
August 08, 2013, 11:48:15 AM
#2
One is the ASCII-HEX byte-wise reverse of the other.
member
Activity: 95
Merit: 11
August 07, 2013, 02: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!
Jump to: