#include "crypter.h"
#include "sync.h"
#include <boost/signals2/signal.hpp>
+#include <boost/variant.hpp>
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<CNoDestination, CKeyID, CScriptID> CTxDestination;
+
/** A virtual base class for key stores */
class CKeyStore
{
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;
typedef std::map<CKeyID, std::pair<CSecret, bool> > KeyMap;
typedef std::map<CScriptID, CScript > ScriptMap;
+typedef std::set<CTxDestination> WatchOnlySet;
/** Basic key store, that keeps keys in an address->secret map */
class CBasicKeyStore : public CKeyStore
protected:
KeyMap mapKeys;
ScriptMap mapScripts;
+ WatchOnlySet setWatchOnly;
public:
bool AddKey(const CKey& key);
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<CKeyID, std::pair<CPubKey, std::vector<unsigned char> > > CryptedKeyMap;