Changeset View
Changeset View
Standalone View
Standalone View
src/keystore.h
Show All 10 Lines | |||||
#include <script/script.h> | #include <script/script.h> | ||||
#include <script/standard.h> | #include <script/standard.h> | ||||
#include <sync.h> | #include <sync.h> | ||||
#include <boost/signals2/signal.hpp> | #include <boost/signals2/signal.hpp> | ||||
/** A virtual base class for key stores */ | /** A virtual base class for key stores */ | ||||
class CKeyStore { | class CKeyStore { | ||||
protected: | |||||
mutable CCriticalSection cs_KeyStore; | |||||
public: | public: | ||||
virtual ~CKeyStore() {} | virtual ~CKeyStore() {} | ||||
//! Add a key to the store. | //! Add a key to the store. | ||||
virtual bool AddKeyPubKey(const CKey &key, const CPubKey &pubkey) = 0; | virtual bool AddKeyPubKey(const CKey &key, const CPubKey &pubkey) = 0; | ||||
virtual bool AddKey(const CKey &key); | |||||
//! Check whether a key corresponding to a given address is present in the | //! Check whether a key corresponding to a given address is present in the | ||||
//! store. | //! store. | ||||
virtual bool HaveKey(const CKeyID &address) const = 0; | virtual bool HaveKey(const CKeyID &address) const = 0; | ||||
virtual bool GetKey(const CKeyID &address, CKey &keyOut) const = 0; | virtual bool GetKey(const CKeyID &address, CKey &keyOut) const = 0; | ||||
virtual std::set<CKeyID> GetKeys() const = 0; | virtual std::set<CKeyID> GetKeys() const = 0; | ||||
virtual bool GetPubKey(const CKeyID &address, | virtual bool GetPubKey(const CKeyID &address, | ||||
CPubKey &vchPubKeyOut) const = 0; | CPubKey &vchPubKeyOut) const = 0; | ||||
Show All 16 Lines | |||||
typedef std::map<CKeyID, CKey> KeyMap; | typedef std::map<CKeyID, CKey> KeyMap; | ||||
typedef std::map<CKeyID, CPubKey> WatchKeyMap; | typedef std::map<CKeyID, CPubKey> WatchKeyMap; | ||||
typedef std::map<CScriptID, CScript> ScriptMap; | typedef std::map<CScriptID, CScript> ScriptMap; | ||||
typedef std::set<CScript> WatchOnlySet; | typedef std::set<CScript> WatchOnlySet; | ||||
/** Basic key store, that keeps keys in an address->secret map */ | /** Basic key store, that keeps keys in an address->secret map */ | ||||
class CBasicKeyStore : public CKeyStore { | class CBasicKeyStore : public CKeyStore { | ||||
protected: | protected: | ||||
mutable CCriticalSection cs_KeyStore; | |||||
KeyMap mapKeys; | KeyMap mapKeys; | ||||
WatchKeyMap mapWatchKeys; | WatchKeyMap mapWatchKeys; | ||||
ScriptMap mapScripts; | ScriptMap mapScripts; | ||||
WatchOnlySet setWatchOnly; | WatchOnlySet setWatchOnly; | ||||
void ImplicitlyLearnRelatedKeyScripts(const CPubKey &pubkey); | void ImplicitlyLearnRelatedKeyScripts(const CPubKey &pubkey); | ||||
public: | public: | ||||
bool AddKeyPubKey(const CKey &key, const CPubKey &pubkey) override; | bool AddKeyPubKey(const CKey &key, const CPubKey &pubkey) override; | ||||
bool AddKey(const CKey &key) { return AddKeyPubKey(key, key.GetPubKey()); } | |||||
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; | ||||
std::set<CKeyID> GetKeys() const override; | std::set<CKeyID> GetKeys() const override; | ||||
bool GetKey(const CKeyID &address, CKey &keyOut) const override; | bool GetKey(const CKeyID &address, CKey &keyOut) const override; | ||||
bool AddCScript(const CScript &redeemScript) override; | bool AddCScript(const CScript &redeemScript) override; | ||||
bool HaveCScript(const CScriptID &hash) const override; | bool HaveCScript(const CScriptID &hash) const override; | ||||
std::set<CScriptID> GetCScripts() const override; | std::set<CScriptID> GetCScripts() const override; | ||||
bool GetCScript(const CScriptID &hash, | bool GetCScript(const CScriptID &hash, | ||||
Show All 18 Lines |