Changeset View
Changeset View
Standalone View
Standalone View
src/keystore.h
Show First 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | protected: | ||||
KeyMap mapKeys; | KeyMap mapKeys; | ||||
WatchKeyMap mapWatchKeys; | WatchKeyMap mapWatchKeys; | ||||
ScriptMap mapScripts; | ScriptMap mapScripts; | ||||
WatchOnlySet setWatchOnly; | WatchOnlySet setWatchOnly; | ||||
public: | public: | ||||
bool AddKeyPubKey(const CKey &key, const CPubKey &pubkey) override; | bool AddKeyPubKey(const CKey &key, const CPubKey &pubkey) override; | ||||
bool GetPubKey(const CKeyID &address, CPubKey &vchPubKeyOut) const override; | bool GetPubKey(const CKeyID &address, CPubKey &vchPubKeyOut) const override; | ||||
bool HaveKey(const CKeyID &address) const override { | bool HaveKey(const CKeyID &address) const override; | ||||
bool result; | std::set<CKeyID> GetKeys() const override; | ||||
{ | bool GetKey(const CKeyID &address, CKey &keyOut) const override; | ||||
LOCK(cs_KeyStore); | |||||
result = (mapKeys.count(address) > 0); | |||||
} | |||||
return result; | |||||
} | |||||
std::set<CKeyID> GetKeys() const override { | |||||
LOCK(cs_KeyStore); | |||||
std::set<CKeyID> set_address; | |||||
for (const auto &mi : mapKeys) { | |||||
set_address.insert(mi.first); | |||||
} | |||||
return set_address; | |||||
} | |||||
bool GetKey(const CKeyID &address, CKey &keyOut) const override { | |||||
{ | |||||
LOCK(cs_KeyStore); | |||||
KeyMap::const_iterator mi = mapKeys.find(address); | |||||
if (mi != mapKeys.end()) { | |||||
keyOut = mi->second; | |||||
return true; | |||||
} | |||||
} | |||||
return false; | |||||
} | |||||
virtual bool AddCScript(const CScript &redeemScript) override; | virtual bool AddCScript(const CScript &redeemScript) override; | ||||
virtual bool HaveCScript(const CScriptID &hash) const override; | virtual bool HaveCScript(const CScriptID &hash) const override; | ||||
virtual bool GetCScript(const CScriptID &hash, | virtual bool GetCScript(const CScriptID &hash, | ||||
CScript &redeemScriptOut) const override; | CScript &redeemScriptOut) const override; | ||||
virtual bool AddWatchOnly(const CScript &dest) override; | virtual bool AddWatchOnly(const CScript &dest) override; | ||||
virtual bool RemoveWatchOnly(const CScript &dest) override; | virtual bool RemoveWatchOnly(const CScript &dest) override; | ||||
virtual bool HaveWatchOnly(const CScript &dest) const override; | virtual bool HaveWatchOnly(const CScript &dest) const override; | ||||
virtual bool HaveWatchOnly() const override; | virtual bool HaveWatchOnly() const override; | ||||
}; | }; | ||||
typedef std::vector<uint8_t, secure_allocator<uint8_t>> CKeyingMaterial; | typedef std::vector<uint8_t, secure_allocator<uint8_t>> CKeyingMaterial; | ||||
typedef std::map<CKeyID, std::pair<CPubKey, std::vector<uint8_t>>> | typedef std::map<CKeyID, std::pair<CPubKey, std::vector<uint8_t>>> | ||||
CryptedKeyMap; | CryptedKeyMap; | ||||
#endif // BITCOIN_KEYSTORE_H | #endif // BITCOIN_KEYSTORE_H |