Does Bitcoin Choose the Chain With the Most Blocks?
Not necessarily. The phrase "longest chain" is often used informally, but Bitcoin's fork-choice rule selects the fully valid chain with the greatest accumulated proof of work, also called chainwork.
Different blocks can represent different amounts of work because difficulty targets can vary. Counting blocks alone is therefore not a complete measure of the proof of work behind a branch. A node must also validate consensus rules: a branch with enormous claimed work cannot become active if its blocks or transactions are invalid.
When two valid branches have equal accumulated work, nodes may temporarily disagree about their active tips based on the order in which blocks arrived and their local state. Later valid work can resolve the competition.
This distinction matters for wallets: block height alone does not prove that a transaction remains confirmed. A wallet should associate confirmation with the actual block hash and verify that the block belongs to the current active chain.
Primary references
Bitcoin whitepaper — Section 5: https://bitcoin.org/bitcoin.pdf
Bitcoin Developer Guide — Block Chain: https://developer.bitcoin.org/devguide/block_chain.html
