Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/crypter.h
Show First 20 Lines • Show All 135 Lines • ▼ Show 20 Lines | protected: | ||||
bool Unlock(const CKeyingMaterial &vMasterKeyIn); | bool Unlock(const CKeyingMaterial &vMasterKeyIn); | ||||
CryptedKeyMap mapCryptedKeys; | CryptedKeyMap mapCryptedKeys; | ||||
public: | public: | ||||
CCryptoKeyStore() | CCryptoKeyStore() | ||||
: fUseCrypto(false), fDecryptionThoroughlyChecked(false) {} | : fUseCrypto(false), fDecryptionThoroughlyChecked(false) {} | ||||
bool IsCrypted() const { return fUseCrypto; } | bool IsCrypted() const { return fUseCrypto; } | ||||
bool IsLocked() const; | |||||
bool IsLocked() const { | |||||
if (!IsCrypted()) return false; | |||||
bool result; | |||||
{ | |||||
LOCK(cs_KeyStore); | |||||
result = vMasterKey.empty(); | |||||
} | |||||
return result; | |||||
} | |||||
bool Lock(); | bool Lock(); | ||||
virtual bool AddCryptedKey(const CPubKey &vchPubKey, | virtual bool AddCryptedKey(const CPubKey &vchPubKey, | ||||
const std::vector<uint8_t> &vchCryptedSecret); | const std::vector<uint8_t> &vchCryptedSecret); | ||||
bool AddKeyPubKey(const CKey &key, const CPubKey &pubkey) override; | bool AddKeyPubKey(const CKey &key, const CPubKey &pubkey) override; | ||||
bool HaveKey(const CKeyID &address) const override { | bool HaveKey(const CKeyID &address) const override; | ||||
LOCK(cs_KeyStore); | |||||
if (!IsCrypted()) { | |||||
return CBasicKeyStore::HaveKey(address); | |||||
} | |||||
return mapCryptedKeys.count(address) > 0; | |||||
} | |||||
bool GetKey(const CKeyID &address, CKey &keyOut) const override; | bool GetKey(const CKeyID &address, CKey &keyOut) const override; | ||||
bool GetPubKey(const CKeyID &address, CPubKey &vchPubKeyOut) const override; | bool GetPubKey(const CKeyID &address, CPubKey &vchPubKeyOut) const override; | ||||
std::set<CKeyID> GetKeys() const override { | std::set<CKeyID> GetKeys() const override; | ||||
LOCK(cs_KeyStore); | |||||
if (!IsCrypted()) { | |||||
return CBasicKeyStore::GetKeys(); | |||||
} | |||||
std::set<CKeyID> set_address; | |||||
for (const auto &mi : mapCryptedKeys) { | |||||
set_address.insert(mi.first); | |||||
} | |||||
return set_address; | |||||
} | |||||
/** | /** | ||||
* Wallet status (encrypted, locked) changed. | * Wallet status (encrypted, locked) changed. | ||||
* Note: Called without locks held. | * Note: Called without locks held. | ||||
*/ | */ | ||||
boost::signals2::signal<void(CCryptoKeyStore *wallet)> NotifyStatusChanged; | boost::signals2::signal<void(CCryptoKeyStore *wallet)> NotifyStatusChanged; | ||||
}; | }; | ||||
#endif // BITCOIN_WALLET_CRYPTER_H | #endif // BITCOIN_WALLET_CRYPTER_H |