| 392 | } |
| 393 | |
| 394 | bool LoadEncryptionKey(CWallet* pwallet, DataStream& ssKey, DataStream& ssValue, std::string& strErr) |
| 395 | { |
| 396 | LOCK(pwallet->cs_wallet); |
| 397 | try { |
| 398 | // Master encryption key is loaded into only the wallet and not any of the ScriptPubKeyMans. |
| 399 | unsigned int nID; |
| 400 | ssKey >> nID; |
| 401 | CMasterKey kMasterKey; |
| 402 | ssValue >> kMasterKey; |
| 403 | if(pwallet->mapMasterKeys.contains(nID)) |
| 404 | { |
| 405 | strErr = strprintf("Error reading wallet database: duplicate CMasterKey id %u", nID); |
| 406 | return false; |
| 407 | } |
| 408 | pwallet->mapMasterKeys[nID] = kMasterKey; |
| 409 | if (pwallet->nMasterKeyMaxID < nID) |
| 410 | pwallet->nMasterKeyMaxID = nID; |
| 411 | |
| 412 | } catch (const std::exception& e) { |
| 413 | if (strErr.empty()) { |
| 414 | strErr = e.what(); |
| 415 | } |
| 416 | return false; |
| 417 | } |
| 418 | return true; |
| 419 | } |
| 420 | |
| 421 | bool LoadHDChain(CWallet* pwallet, DataStream& ssValue, std::string& strErr) |
| 422 | { |
no test coverage detected