| 176 | } |
| 177 | |
| 178 | bool CCryptoKeyStore::Unlock(const CKeyingMaterial& vMasterKeyIn) |
| 179 | { |
| 180 | { |
| 181 | LOCK(cs_KeyStore); |
| 182 | if (!SetCrypted()) |
| 183 | return false; |
| 184 | |
| 185 | bool keyPass = false; |
| 186 | bool keyFail = false; |
| 187 | CryptedKeyMap::const_iterator mi = mapCryptedKeys.begin(); |
| 188 | for (; mi != mapCryptedKeys.end(); ++mi) |
| 189 | { |
| 190 | const CPubKey &vchPubKey = (*mi).second.first; |
| 191 | const std::vector<unsigned char> &vchCryptedSecret = (*mi).second.second; |
| 192 | CKey key; |
| 193 | if (!DecryptKey(vMasterKeyIn, vchCryptedSecret, vchPubKey, key)) |
| 194 | { |
| 195 | keyFail = true; |
| 196 | break; |
| 197 | } |
| 198 | keyPass = true; |
| 199 | if (fDecryptionThoroughlyChecked) |
| 200 | break; |
| 201 | } |
| 202 | if (keyPass && keyFail) |
| 203 | { |
| 204 | LogPrintf("The wallet is probably corrupted: Some keys decrypt but not all.\n"); |
| 205 | assert(false); |
| 206 | } |
| 207 | if (keyFail || !keyPass) |
| 208 | return false; |
| 209 | vMasterKey = vMasterKeyIn; |
| 210 | fDecryptionThoroughlyChecked = true; |
| 211 | } |
| 212 | NotifyStatusChanged(this); |
| 213 | return true; |
| 214 | } |
| 215 | |
| 216 | bool CCryptoKeyStore::AddKeyPubKey(const CKey& key, const CPubKey &pubkey) |
| 217 | { |
nothing calls this directly
no test coverage detected