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: 01000000010000000000000000000000000000000000000000000000000000000000000000FFFFFFFF4D04FFFF001D0104455468652054696D65732030332F4A616E2F32303039204368616E63656C6C6F72206F6E206272696E6B206F66207365636F6E64206261696C6F757420666F722062616E6B73FFFFFFFF0100F2052A01000000434104678AFDB0FE5548271967F1A67130B7105CD6A828E03909A67962E0EA1F61DEB649F6BC3F4CEF38C4F35504E51EC112DE5C384DF7BA0B8D578A4C702B6BF11D5FAC00000000 And if double hashed correctly, it would give the following hash: 4A5E1E4BAAB89F3A32518A88C31BC87F618F76673E2CC77AB2127B7AFDEDA33B |
|||
|
|
|
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. |
|||
|
|