After commit ccd85b57af60d7034db372b9501d059fbc5941e4 I can no longer open my wallet without warnings.

![Screenshot from 2020-05-22 10-45-35](https://user-images.githubusercontent.com/6399679/82679920-9704a180-9c19-11ea-8f55-4c935ced8fe2.png)

```
Warning: Error reading /home/marco/.bitcoin/regtest/wallet.dat! All keys read correctly, but transaction data or address book entries might be missing or incorrect.

m_batch.Read(DBKeys::VERSION, last_client);
    int wallet_version = pwallet->GetVersion();
    pwallet->WalletLogPrintf("Wallet File Version = %d\n", wallet_version > 0 ? wallet_version : last_client);
    pwallet->WalletLogPrintf("Keys: %u plaintext, %u encrypted, %u w/ metadata, %u total. Unknown wallet records: %u\n",
           wss.nKeys, wss.nCKeys, wss.nKeyMeta, wss.nKeys + wss.nCKeys, wss.m_unknown_records);
    
    if (pwallet->IsLegacy() && (wss.nKeys + wss.nCKeys + wss.nWatchKeys) != wss.nKeyMeta) {
        auto spk_man = pwallet->GetOrCreateLegacyScriptPubKeyMan();
        if (spk_man) {
            LOCK(spk_man->cs_KeyStore);
            spk_man->UpdateTimeFirstKey(1);
        }
    }
    for (const uint256& hash : wss.vWalletUpgrade)
        WriteTx(pwallet->mapWallet.at(hash));
    
    if (wss.fIsEncrypted && (last_client == 40000 || last_client == 50000))
        return DBErrors::NEED_REWRITE;
    if (last_client < CLIENT_VERSION) 
        m_batch.Write(DBKeys::VERSION, CLIENT_VERSION);
    if (wss.fAnyUnordered)
        result = pwallet->ReorderTransactions();
    
    
    try {
        pwallet->UpgradeKeyMetadata();
    } catch (...) {
        result = DBErrors::CORRUPT;
    }