What is preventing the bitcoin client from switching to a fake block chain that would be longer that current official chain? The faked chain would contain fictional transactions, but within the faked chain the transaction would be valid (e.g. like no double spends etc.).
2 Answers
Bitcoin clients always accept the longest valid chain. On one hand, clients check the received blocks for validity, on the other hand length is defined by another metric than many assume. The length of the blockchain is the sum of the difficulty of all its blocks, not the number of blocks. So, in order to create a fake chain, the attacker would have to actually create a valid chain at the same difficulty. This is either possible for very short chains (double spend attack) or requires a major share of the network's power (51% attack).
Full blockchain nodes actually check not only the block headers, but also every transaction in the block body before accepting that block. If any transaction in the block doesn't "add up" (i.e. its inputs do not match the current accepted balance of those addresses, signatures, etc) then the block will not be accepted as valid.
This is where "light" bitcoin clients (the ones that do not download the full blockchain) have to trust a full-mode node to tell them the "truth" about previous transactions. If the full-mode node is malicious it can certainly trick these light client peers that are connected to it.