| 437 | } |
| 438 | |
| 439 | bool CWallet::Unlock(const SecureString& strWalletPassphrase, bool stakingOnly) |
| 440 | { |
| 441 | SecureString strWalletPassphraseFinal; |
| 442 | |
| 443 | if (!IsLocked()) { |
| 444 | fWalletUnlockStakingOnly = stakingOnly; |
| 445 | return true; |
| 446 | } |
| 447 | |
| 448 | strWalletPassphraseFinal = strWalletPassphrase; |
| 449 | |
| 450 | |
| 451 | CCrypter crypter; |
| 452 | CKeyingMaterial _vMasterKey; |
| 453 | |
| 454 | { |
| 455 | LOCK(cs_wallet); |
| 456 | for (const MasterKeyMap::value_type& pMasterKey : mapMasterKeys) { |
| 457 | if (!crypter.SetKeyFromPassphrase(strWalletPassphraseFinal, pMasterKey.second.vchSalt, pMasterKey.second.nDeriveIterations, pMasterKey.second.nDerivationMethod)) |
| 458 | return false; |
| 459 | if (!crypter.Decrypt(pMasterKey.second.vchCryptedKey, _vMasterKey)) |
| 460 | continue; // try another master key |
| 461 | if (CCryptoKeyStore::Unlock(_vMasterKey)) { |
| 462 | fWalletUnlockStakingOnly = stakingOnly; |
| 463 | return true; |
| 464 | } |
| 465 | } |
| 466 | } |
| 467 | return false; |
| 468 | } |
| 469 | |
| 470 | bool CWallet::ChangeWalletPassphrase(const SecureString& strOldWalletPassphrase, const SecureString& strNewWalletPassphrase) |
| 471 | { |
no test coverage detected