Removes vchDefaultKey which was only used for first run detection. Improves wallet first run detection by checking to see if any keys were read from the database.
This also fixes a (rather contrived) case where an encrypted non-HD wallet has corruption such that the default key is no longer valid and is loaded into a Core version that supports HD wallets. This causes a runtime exception since a new hd master key is generated as the software believes the wallet file is newly created but cannot add the generated key to the wallet since it is encrypted. I was only able to replicate this error by creating a non-hd wallet, encrypting it, then editing the wallet using db_dump
and db_load
before loading the wallet with hd enabled. This problem has been reported by two users so it is something that can happen, although that raises the question of “what corrupted the default key”.
P.S. I don’t know what’s up with the whitespace changes. I think my text editor is doing something stupid but I don’t think those are important enough to attempt undoing them. Undid those