Skip to content

Commit f748ff7

Browse files
committed
Merge pull request #4045
a3e192a replaced MINE_ with ISMINE_ (JaSK) 53a2148 fixed bug where validateaddress doesn't display information (JaSK) f28707a fixed bug in ListReceived() (JaSK) 519dd1c Added MINE_ALL = (spendable|watchonly) (JaSK) 23b0506 Fixed some stuff in TransactionDesc (JaSK) 80dda36 removed default argument values for ismine filter (JaSK) d5087d1 Use script matching rather than destination matching for watch-only. (Pieter Wuille) 0fa2f88 added includedWatchonly argument to listreceivedbyaddress/...account (JaSK) f87ba3d added includeWatchonly argument to 'gettransaction' because it affects balance calculation (JaSK) a5c6c5d fixed tiny glitch and improved readability like laanwj suggested (JaSK) d7d5d23 Added argument to listtransactions and listsinceblock to include watchonly addresses (JaSK) 952877e Showing 'involvesWatchonly' property for transactions returned by 'listtransactions' and 'listsinceblock'. It is only appended when the transaction involves a watchonly address. (JaSK) 83f3543 Added argument to listaccounts to include watchonly addresses (JaSK) d4640d7 Added argument to getbalance to include watchonly addresses and fixed errors in balance calculation. (JaSK) d2692f6 Watchonly transactions are marked in transaction history (JaSK) ffd40da Watchonly balances are shown separately in gui. (JaSK) 2935b21 qt: Hide unspendable outputs in coin control (Wladimir J. van der Laan) c898846 Add support for watch-only addresses (Pieter Wuille)
2 parents afe380e + a3e192a commit f748ff7

27 files changed

+994
-356
lines changed

src/keystore.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,15 @@ bool CBasicKeyStore::GetCScript(const CScriptID &hash, CScript& redeemScriptOut)
5959
return false;
6060
}
6161

62+
bool CBasicKeyStore::AddWatchOnly(const CScript &dest)
63+
{
64+
LOCK(cs_KeyStore);
65+
setWatchOnly.insert(dest);
66+
return true;
67+
}
68+
69+
bool CBasicKeyStore::HaveWatchOnly(const CScript &dest) const
70+
{
71+
LOCK(cs_KeyStore);
72+
return setWatchOnly.count(dest) > 0;
73+
}

src/keystore.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,21 @@
88

99
#include "key.h"
1010
#include "sync.h"
11+
#include "script.h" // for CNoDestination
1112

1213
#include <boost/signals2/signal.hpp>
14+
#include <boost/variant.hpp>
1315

1416
class CScript;
1517

18+
/** A txout script template with a specific destination. It is either:
19+
* * CNoDestination: no destination set
20+
* * CKeyID: TX_PUBKEYHASH destination
21+
* * CScriptID: TX_SCRIPTHASH destination
22+
* A CTxDestination is the internal data type encoded in a CBitcoinAddress
23+
*/
24+
typedef boost::variant<CNoDestination, CKeyID, CScriptID> CTxDestination;
25+
1626
/** A virtual base class for key stores */
1727
class CKeyStore
1828
{
@@ -36,17 +46,23 @@ class CKeyStore
3646
virtual bool AddCScript(const CScript& redeemScript) =0;
3747
virtual bool HaveCScript(const CScriptID &hash) const =0;
3848
virtual bool GetCScript(const CScriptID &hash, CScript& redeemScriptOut) const =0;
49+
50+
// Support for Watch-only addresses
51+
virtual bool AddWatchOnly(const CScript &dest) =0;
52+
virtual bool HaveWatchOnly(const CScript &dest) const =0;
3953
};
4054

4155
typedef std::map<CKeyID, CKey> KeyMap;
4256
typedef std::map<CScriptID, CScript > ScriptMap;
57+
typedef std::set<CScript> WatchOnlySet;
4358

4459
/** Basic key store, that keeps keys in an address->secret map */
4560
class CBasicKeyStore : public CKeyStore
4661
{
4762
protected:
4863
KeyMap mapKeys;
4964
ScriptMap mapScripts;
65+
WatchOnlySet setWatchOnly;
5066

5167
public:
5268
bool AddKeyPubKey(const CKey& key, const CPubKey &pubkey);
@@ -88,6 +104,9 @@ class CBasicKeyStore : public CKeyStore
88104
virtual bool AddCScript(const CScript& redeemScript);
89105
virtual bool HaveCScript(const CScriptID &hash) const;
90106
virtual bool GetCScript(const CScriptID &hash, CScript& redeemScriptOut) const;
107+
108+
virtual bool AddWatchOnly(const CScript &dest);
109+
virtual bool HaveWatchOnly(const CScript &dest) const;
91110
};
92111

93112
typedef std::vector<unsigned char, secure_allocator<unsigned char> > CKeyingMaterial;

0 commit comments

Comments
 (0)