diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2013-07-26 01:06:01 +0200 |
---|---|---|
committer | JaSK <temp@temp.temp> | 2014-07-02 15:48:37 +0200 |
commit | c8988460a2865b99ee96da6799d37ac6ccb79d4d (patch) | |
tree | 359da0335ecd969209daa6f2ef3ddadc157b77f8 /src/keystore.h | |
parent | dd49e92fb0cae0dcdf0b2ea303da99c7814db473 (diff) |
Add support for watch-only addresses
Changes:
* Add Add/Have WatchOnly methods to CKeyStore, and implementations
in CBasicKeyStore.
* Add similar methods to CWallet, and support entries for it in
CWalletDB.
* Make IsMine in script/wallet return a new enum 'isminetype',
rather than a boolean. This allows distinguishing between
spendable and unspendable coins.
* Add a field fSpendable to COutput (GetAvailableCoins' return type).
* Mark watchonly coins in listunspent as 'watchonly': true.
* Add 'watchonly' to validateaddress, suppressing script/pubkey/...
in this case.
Based on a patch by Eric Lombrozo.
Conflicts:
src/qt/walletmodel.cpp
src/rpcserver.cpp
src/wallet.cpp
Diffstat (limited to 'src/keystore.h')
-rw-r--r-- | src/keystore.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/keystore.h b/src/keystore.h index 79d8661aca..90fc3a4c7b 100644 --- a/src/keystore.h +++ b/src/keystore.h @@ -8,11 +8,21 @@ #include "key.h" #include "sync.h" +#include "script.h" // for CNoDestination #include <boost/signals2/signal.hpp> +#include <boost/variant.hpp> class CScript; +/** 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 { @@ -36,10 +46,15 @@ public: virtual bool AddCScript(const CScript& redeemScript) =0; 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; }; typedef std::map<CKeyID, CKey> 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 @@ -47,6 +62,7 @@ class CBasicKeyStore : public CKeyStore protected: KeyMap mapKeys; ScriptMap mapScripts; + WatchOnlySet setWatchOnly; public: bool AddKeyPubKey(const CKey& key, const CPubKey &pubkey); @@ -88,6 +104,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::vector<unsigned char, secure_allocator<unsigned char> > CKeyingMaterial; |