diff options
| author | Andrew Chow <[email protected]> | 2019-12-03 19:06:15 -0500 |
|---|---|---|
| committer | Andrew Chow <[email protected]> | 2020-01-30 14:44:22 -0500 |
| commit | d67055e00dd90f504384e5c3f229fc95306d5aac (patch) | |
| tree | 1b6ff06857f4c26191e4499f766a934e0f3efaa1 /src/wallet/walletdb.cpp | |
| parent | Set fDecryptionThoroughlyChecked based on whether crypted key checksums are v... (diff) | |
| download | discoin-d67055e00dd90f504384e5c3f229fc95306d5aac.tar.xz discoin-d67055e00dd90f504384e5c3f229fc95306d5aac.zip | |
Upgrade or rewrite encrypted key checksums
If fDecryptionThoroughlyChecked is false, after a key has been checked,
write (or rewrite) its checksum. This serves to upgrade wallets
and correct those which have the checksum corrupted but not the key.
Diffstat (limited to 'src/wallet/walletdb.cpp')
| -rw-r--r-- | src/wallet/walletdb.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index ab1ad1a64..6cb8c720f 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -114,7 +114,14 @@ bool WalletBatch::WriteCryptedKey(const CPubKey& vchPubKey, const auto key = std::make_pair(DBKeys::CRYPTED_KEY, vchPubKey); if (!WriteIC(key, std::make_pair(vchCryptedSecret, checksum), false)) { - return false; + // It may already exist, so try writing just the checksum + std::vector<unsigned char> val; + if (!m_batch.Read(key, val)) { + return false; + } + if (!WriteIC(key, std::make_pair(val, checksum), true)) { + return false; + } } EraseIC(std::make_pair(DBKeys::KEY, vchPubKey)); return true; |