Take the 2-minute tour ×
Bitcoin Stack Exchange is a question and answer site for Bitcoin crypto-currency enthusiasts. It's 100% free, no registration required.

have been mining on pools and blindly going a long for the ride of

> generating a block

Can somebody walk through the process in simple terms of the steps involved in creating a block on the blockchain ?

What determines what transactions get included on the block we are mining ?

share|improve this question

1 Answer 1

up vote 6 down vote accepted

When miners try to compute a block, they pick all transactions that they want to be added in the block, plus one coinbase (generation) transaction to their address. They may include any transaction they want to form a tree of transactions later hashed into the merkle root and referenced into the block's header.

It is to note that for a block to be accepted by the network it needs to contain only valid transactions: inputs that are not yet spent, inputs that have the valid ammount, signature that verifies ok and etc...

After having a valid merkle root they build the block's header:

  • Version (4 bytes)
  • Hash of the previous block, thus making a chain of block (32 bytes)
  • Merkle root, the tree of transactions' reference (32 bytes)
  • Timestamp, number of seconds since 1970-01-01 00:00 (4 bytes)
  • Bits, a representation of the networks current difficulty (4 bytes)
  • Nonce, incremented when mining (4 bytes)

See more here to learn more on how to build the header.

Then this where your miner enters the game. It starts with the nonce at 0, hash (sha-256 2x) the block's header and then check if the hash in under the current target (if you are on a pool the share target). If not it increments the nonce and hash again. If the hash is under the current target YOU FOUND A BLOCK, you then transfer your block's header and the associated transactions' tree and the network accepts it. Because you had a coinbase transaction in your block paying to your bitcoin address those bitcoin then becomes yours.

It is to says that finding a block is rare so your miner will eventually run out of nonce to use you can then change parameter in your block header (more likely the timestamp) or add a extra nonce field in your transactions tree thus changing the merkle root.

As for which transactions are chosen to be part of a block, it is mostly the miners choice to include one or other transaction. But normally they would include transaction with a miners fee in it to gain more bitcoin, a miner could also choose not to include any transaction and only get the coinbase one. The propagation of ones transaction through the network also influence which transactions a miner do include.

share|improve this answer
    
How do they select which transactions ?? Is there some tool liek a block chain viewer ?? –  BitCoin New Guy Jan 28 '13 at 8:44
    
Yes there is one blockexplorer.com, but actually all nodes on the network are there to relay transaction, miner will include (normally) all transaction they received. All nodes (bitcoin standard client) also has the full blockchain. –  Gopoi Jan 28 '13 at 8:56

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.