Browse Source

Move GenerateNewKey back to CWallet

miguelfreitas
Pieter Wuille 13 years ago
parent
commit
9976cf070f
  1. 10
      src/keystore.cpp
  2. 2
      src/keystore.h
  3. 10
      src/wallet.cpp
  4. 2
      src/wallet.h

10
src/keystore.cpp

@ -8,16 +8,6 @@
#include "db.h" #include "db.h"
#include "script.h" #include "script.h"
std::vector<unsigned char> CKeyStore::GenerateNewKey()
{
RandAddSeedPerfmon();
CKey key;
key.MakeNewKey();
if (!AddKey(key))
throw std::runtime_error("CKeyStore::GenerateNewKey() : AddKey failed");
return key.GetPubKey();
}
bool CKeyStore::GetPubKey(const CBitcoinAddress &address, std::vector<unsigned char> &vchPubKeyOut) const bool CKeyStore::GetPubKey(const CBitcoinAddress &address, std::vector<unsigned char> &vchPubKeyOut) const
{ {
CKey key; CKey key;

2
src/keystore.h

@ -29,8 +29,6 @@ public:
virtual bool HaveCScript(const uint160 &hash) const =0; virtual bool HaveCScript(const uint160 &hash) const =0;
virtual bool GetCScript(const uint160 &hash, CScript& redeemScriptOut) const =0; virtual bool GetCScript(const uint160 &hash, CScript& redeemScriptOut) const =0;
// Generate a new key, and add it to the store
virtual std::vector<unsigned char> GenerateNewKey();
virtual bool GetSecret(const CBitcoinAddress &address, CSecret& vchSecret, bool &fCompressed) const virtual bool GetSecret(const CBitcoinAddress &address, CSecret& vchSecret, bool &fCompressed) const
{ {
CKey key; CKey key;

10
src/wallet.cpp

@ -15,6 +15,16 @@ using namespace std;
// mapWallet // mapWallet
// //
std::vector<unsigned char> CWallet::GenerateNewKey()
{
RandAddSeedPerfmon();
CKey key;
key.MakeNewKey();
if (!AddKey(key))
throw std::runtime_error("CWallet::GenerateNewKey() : AddKey failed");
return key.GetPubKey();
}
bool CWallet::AddKey(const CKey& key) bool CWallet::AddKey(const CKey& key)
{ {
if (!CCryptoKeyStore::AddKey(key)) if (!CCryptoKeyStore::AddKey(key))

2
src/wallet.h

@ -66,6 +66,8 @@ public:
std::vector<unsigned char> vchDefaultKey; std::vector<unsigned char> vchDefaultKey;
// keystore implementation // keystore implementation
// Generate a new key
std::vector<unsigned char> GenerateNewKey();
// Adds a key to the store, and saves it to disk. // Adds a key to the store, and saves it to disk.
bool AddKey(const CKey& key); bool AddKey(const CKey& key);
// Adds a key to the store, without saving it to disk (used by LoadWallet) // Adds a key to the store, without saving it to disk (used by LoadWallet)

Loading…
Cancel
Save