// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2012 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
-// file license.txt or http://www.opensource.org/licenses/mit-license.php.
+// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_KEYSTORE_H
#define BITCOIN_KEYSTORE_H
#include "crypter.h"
-#include "script.h"
+#include "util.h"
+#include "base58.h"
+
+class CScript;
/** A virtual base class for key stores */
class CKeyStore
bool HaveKey(const CBitcoinAddress &address) const
{
bool result;
- CRITICAL_BLOCK(cs_KeyStore)
+ {
+ LOCK(cs_KeyStore);
result = (mapKeys.count(address) > 0);
+ }
return result;
}
void GetKeys(std::set<CBitcoinAddress> &setAddress) const
{
setAddress.clear();
- CRITICAL_BLOCK(cs_KeyStore)
{
+ LOCK(cs_KeyStore);
KeyMap::const_iterator mi = mapKeys.begin();
while (mi != mapKeys.end())
{
}
bool GetKey(const CBitcoinAddress &address, CKey &keyOut) const
{
- CRITICAL_BLOCK(cs_KeyStore)
{
+ LOCK(cs_KeyStore);
KeyMap::const_iterator mi = mapKeys.find(address);
if (mi != mapKeys.end())
{
if (!IsCrypted())
return false;
bool result;
- CRITICAL_BLOCK(cs_KeyStore)
+ {
+ LOCK(cs_KeyStore);
result = vMasterKey.empty();
+ }
return result;
}
if (!SetCrypted())
return false;
- CRITICAL_BLOCK(cs_KeyStore)
+ {
+ LOCK(cs_KeyStore);
vMasterKey.clear();
+ }
return true;
}
bool AddKey(const CKey& key);
bool HaveKey(const CBitcoinAddress &address) const
{
- CRITICAL_BLOCK(cs_KeyStore)
{
+ LOCK(cs_KeyStore);
if (!IsCrypted())
return CBasicKeyStore::HaveKey(address);
return mapCryptedKeys.count(address) > 0;