user20728: 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.

user2306: 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)


20728: <p>I'm currently working with a postgresql database I've downloaded <a href="http://dumps.webbtc.com/bitcoin/" rel="nofollow noreferrer">here</a> which has the following schema and has probably been parsed using Bitcoin-ABE (I added some indexes and redundant columns):
<img src="https://i.stack.imgur.com/KtNLV.png" alt="enter image description here"></p>

<p>Now I'm stuck trying to make a connection between a transaction input and the previous output. According to the <a href="http://webbtc.com/api/tx" rel="nofollow noreferrer">API</a> that belongs to the sql dump, the field <em>prev_out</em> references "the output that this input spends". My problem is, that I can't find any of the <em>txin.prev_out</em> values in <em>tx.hash</em>. Is this line of thinking correct, or am I connecting the wrong fields?</p>

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

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

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

print reverse_hash(hash)
</code></pre>
