bitcoin/bitcoin — pull request #2603 by sipa (2013-05-01 17:37:51+00:00)
Title: Bugfix: if no bestblock record is present, do a -rescan

It is possible to have a wallet.dat file without any bestblock record at all (if created offline, for example), which - when loaded into a client with a up-to-date chain - does no rescan and shows no transactions.

Also make sure to write the current best block after a rescan, so it isn't necessary twice.