Query Blockchain: Reference previous transaction in "txin" I'm currently working with a postgresql database I've downloaded here which has the following schema and has probably been parsed using Bitcoin-ABE (I added some indexes and redundant columns):


Now I'm stuck trying to make a connection between a transaction input and the previous output. According to the API that belongs to the sql dump, the field prev_out references "the output that this input spends". My problem is, that I can't find any of the txin.prev_out values in tx.hash. Is this line of thinking correct, or am I connecting the wrong fields?

FYI: As you can see both fields are of the type bytea. I was able to use the function encode(hash, 'hex') to get the actual transaction hash and find it at blockchain.info. For the field txin.prev_out however, the hash cannot be found at blockchain.info.
txin.prev_out contains the txid in internal byte order. This is the opposite of tx.hash

You need to reverse the bytes. Here's a short python program that will do that:

import binascii
hash = '32d7724fb0d244f50281a500f505818bb655bc029158fd59d477f4445a6ed64a'
def reverse_hash(hash):
    hash = binascii.unhexlify(hash)
    hash = hash[::-1]
    return binascii.hexlify(hash)

print reverse_hash(hash)