For example, https://blockchain.info/tx/278090c755aa016483ab3a9e6bffe1d2dfbf5b53edb7099b9946bc9dfe59f217. How does the network generate the underlined text? I searched Google but there is no answer - there was one in 2012. The explanation is way too complicated for me to understand.
I'm doing this on top of my head with a little help from the web, so may have some mistake, but these are the steps:
1. Transactions are encoded as (some data bytes):
- a 32 bit 'nVersion'
- a list of input transactions, vin
- a list of output transactions, vout
- a 32 bit 'nLockTime'
2. string all those together end to end (some data bytes as a string or block of text)
3. Taking the sha256 hash of this
4. Taking the sha256 hash of this (again)
You can combine step 3 and 4, sha256(sha256(input)). You do not have to know all the details of sha256 but you should learn the principles of hashing.
![Smiley](https://bitcointalk.org/Smileys/default/smiley.gif)
Then you have the transaction hash. Bitcoin uses the endian encoding, bytewise reversed.
Example with Genesis block:
Step 1)
inputs
count: 01
1st input:
prevout_hash: 0000000000000000000000000000000000000000000000000000000000000000
prevout_n: ffffffff
scriptSig: 4d:04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73
sequence: ffffffff
outputs
count: 01
1st output:
value: 00f2052a01000000 (hex(50*10^8) is 0000012a05f200, and bitcoin puts the bytes in reverse order)
scriptPubKey: 43:4104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac
nLockTime: 00000000
Step 2)
Step 3+4) (double sha256)
Have a look at pybitcoin tools https://github.com/vbuterin/pybitcointools, you can easily create transaction hashes with that.
So, these is the formula. I thought it was random number