| 213 | } |
| 214 | |
| 215 | bool LegacyDataSPKM::CheckDecryptionKey(const CKeyingMaterial& master_key) |
| 216 | { |
| 217 | { |
| 218 | LOCK(cs_KeyStore); |
| 219 | assert(mapKeys.empty()); |
| 220 | |
| 221 | bool keyPass = mapCryptedKeys.empty(); // Always pass when there are no encrypted keys |
| 222 | bool keyFail = false; |
| 223 | CryptedKeyMap::const_iterator mi = mapCryptedKeys.begin(); |
| 224 | WalletBatch batch(m_storage.GetDatabase()); |
| 225 | for (; mi != mapCryptedKeys.end(); ++mi) |
| 226 | { |
| 227 | const CPubKey &vchPubKey = (*mi).second.first; |
| 228 | const std::vector<unsigned char> &vchCryptedSecret = (*mi).second.second; |
| 229 | CKey key; |
| 230 | if (!DecryptKey(master_key, vchCryptedSecret, vchPubKey, key)) |
| 231 | { |
| 232 | keyFail = true; |
| 233 | break; |
| 234 | } |
| 235 | keyPass = true; |
| 236 | if (fDecryptionThoroughlyChecked) |
| 237 | break; |
| 238 | else { |
| 239 | // Rewrite these encrypted keys with checksums |
| 240 | batch.WriteCryptedKey(vchPubKey, vchCryptedSecret, mapKeyMetadata[vchPubKey.GetID()]); |
| 241 | } |
| 242 | } |
| 243 | if (keyPass && keyFail) |
| 244 | { |
| 245 | LogWarning("The wallet is probably corrupted: Some keys decrypt but not all."); |
| 246 | throw std::runtime_error("Error unlocking wallet: some keys decrypt but not all. Your wallet file may be corrupt."); |
| 247 | } |
| 248 | if (keyFail || !keyPass) |
| 249 | return false; |
| 250 | fDecryptionThoroughlyChecked = true; |
| 251 | } |
| 252 | return true; |
| 253 | } |
| 254 | |
| 255 | std::unique_ptr<SigningProvider> LegacyDataSPKM::GetSolvingProvider(const CScript& script) const |
| 256 | { |
no test coverage detected