To prevent the possibility of using the same coin multiple times, the network implements what Satoshi Nakamoto describes as a peer-to-peer timestamp server, which assigns sequential identifiers to each of the transactions which are then enforced against attempts to change using the idea of a proof-of-work chain.
Every time a transaction is made, it starts in the unconfirmed state. It will become confirmed only when verified through a collectively managed timestamp list of all known transactions, the blockchain. Specifically, each generator node collects all unconfirmed transactions it knows into a candidate block, a file that, among other things, contains a cryptographic hash of the previous good block known to that node.
It then tries to reproduce a hash of that block with certain characteristics, an effort that on average requires a definable amount of tests to be performed. When a node finds such a solution, it announces it to the rest of the network, the peers receiving the block check its validity before accepting it and then adding it to the chain.
When a transaction is first admitted in a block, it receives a confirmation. Whenever other child blocks connected to it are created above that block, it receives another confirmation. When the block containing the transaction reaches six confirmations, i.e.
six blocks are created attached to it, the Bitcoin client changes the state of the transaction from unconfirmed to confirmed. The rationale behind this procedure is that with each confirmation of the transaction, with each new block that is created above the block with the transaction itself, it becomes increasingly difficult and expensive to cancel the transaction.
A hypothetical attacker, to cancel a transaction with a certain number of confirmations, would have to generate a parallel chain without the transaction he wishes to cancel and composed of a number of blocks equal to or greater than the confirmations received from the transaction.
It follows that the block chain contains the history of all the movements of all the bitcoins generated starting from the address of their creator up to the current owner. Therefore, if a user tries to reuse a coin that he has already spent, the network will reject the transaction as the amount will already be spent.
Nakamoto designed the system so that, although the database grows in size over time, it is possible to have a reduced version that covers only a few transactions in detail, but which remains completely independently verifiable.
For example, for a private user it might be interesting to have the blockchain with only the transactions that concern him. Or, it might be desirable to purge the database of all transactions whose output money has already been used in other transactions, greatly decreasing their size.