MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / CheckDecryptionKey

Method CheckDecryptionKey

src/wallet/scriptpubkeyman.cpp:215–253  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

213}
214
215bool 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
255std::unique_ptr<SigningProvider> LegacyDataSPKM::GetSolvingProvider(const CScript& script) const
256{

Callers 1

UnlockMethod · 0.45

Calls 6

DecryptKeyFunction · 0.85
WriteCryptedKeyMethod · 0.80
emptyMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
GetIDMethod · 0.45

Tested by

no test coverage detected