How does one calculate the hash of a Tx? Which fields need to be double SHA hashed and in what order?
As explained by Gavin Andersen on the forum - in order to calculate the ID hash of the Tx that is used in the Merkle Tree, one needs to SHA hash the whole Tx message as defined in the Protocol Specification wiki page twice.
For example, for the only Tx from the Genesis Block one would double hash the following array of bytes:
And if double hashed correctly, it would give the following hash:
There's a diagram explaining the process of hashing a transaction when creating or verifying the signature of a bitcoin transaction on the forum, and a higher resolution version of the same image on dropbox.