X-Git-Url: https://git.novaco.in/?p=novacoin.git;a=blobdiff_plain;f=src%2Fkeystore.h;h=9e5674faecf74667592c141fc7d59102537b92a5;hp=ab369bbf47347959e89e46ec96c94b8f5fa3a15d;hb=580fa137c61abe24c56b440e62fa21657227e9a2;hpb=077c5c26ae20ff3f4caa3dcc79e9e0ba5da9e87e diff --git a/src/keystore.h b/src/keystore.h index ab369bb..9e5674f 100644 --- a/src/keystore.h +++ b/src/keystore.h @@ -8,9 +8,25 @@ #include "crypter.h" #include "sync.h" #include +#include class CScript; +class CNoDestination { +public: + friend bool operator==(const CNoDestination &a, const CNoDestination &b) { return true; } + friend bool operator<(const CNoDestination &a, const CNoDestination &b) { return true; } +}; + +/** A txout script template with a specific destination. It is either: + * CNoDestination: no destination set + * CKeyID: TX_PUBKEYHASH destination + * CScriptID: TX_SCRIPTHASH destination + * + * A CTxDestination is the internal data type encoded in a CBitcoinAddress. + */ +typedef boost::variant CTxDestination; + /** A virtual base class for key stores */ class CKeyStore { @@ -34,6 +50,10 @@ public: virtual bool HaveCScript(const CScriptID &hash) const =0; virtual bool GetCScript(const CScriptID &hash, CScript& redeemScriptOut) const =0; + // Support for Watch-only addresses + virtual bool AddWatchOnly(const CTxDestination &dest) =0; + virtual bool HaveWatchOnly(const CTxDestination &dest) const =0; + virtual bool GetSecret(const CKeyID &address, CSecret& vchSecret, bool &fCompressed) const { CKey key; @@ -46,6 +66,7 @@ public: typedef std::map > KeyMap; typedef std::map ScriptMap; +typedef std::set WatchOnlySet; /** Basic key store, that keeps keys in an address->secret map */ class CBasicKeyStore : public CKeyStore @@ -53,6 +74,7 @@ class CBasicKeyStore : public CKeyStore protected: KeyMap mapKeys; ScriptMap mapScripts; + WatchOnlySet setWatchOnly; public: bool AddKey(const CKey& key); @@ -95,6 +117,9 @@ public: virtual bool AddCScript(const CScript& redeemScript); virtual bool HaveCScript(const CScriptID &hash) const; virtual bool GetCScript(const CScriptID &hash, CScript& redeemScriptOut) const; + + virtual bool AddWatchOnly(const CTxDestination &dest); + virtual bool HaveWatchOnly(const CTxDestination &dest) const; }; typedef std::map > > CryptedKeyMap;