Bugfixes walletclass
[novacoin.git] / src / keystore.h
1 // Copyright (c) 2009-2011 Satoshi Nakamoto & Bitcoin developers
2 // Distributed under the MIT/X11 software license, see the accompanying
3 // file license.txt or http://www.opensource.org/licenses/mit-license.php.
4 #ifndef BITCOIN_KEYSTORE_H
5 #define BITCOIN_KEYSTORE_H
6
7 class CKeyStore
8 {
9 public:
10     std::map<std::vector<unsigned char>, CPrivKey> mapKeys;
11     mutable CCriticalSection cs_mapKeys;
12     virtual bool AddKey(const CKey& key);
13     bool HaveKey(const std::vector<unsigned char> &vchPubKey) const
14     {
15         return (mapKeys.count(vchPubKey) > 0);
16     }
17     bool GetPrivKey(const std::vector<unsigned char> &vchPubKey, CPrivKey& keyOut) const
18     {
19         std::map<std::vector<unsigned char>, CPrivKey>::const_iterator mi = mapKeys.find(vchPubKey);
20         if (mi != mapKeys.end())
21         {
22             keyOut = (*mi).second;
23             return true;
24         }
25         return false;
26     }
27     std::vector<unsigned char> GenerateNewKey();
28 };
29
30 #endif