// Copyright (c) 2009-2010 Satoshi Nakamoto
-// Copyright (c) 2011 The Bitcoin developers
+// 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.
#include "db.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
{
CKey key;
return true;
}
-bool CBasicKeyStore::AddCScript(const uint160 &hash, const CScript& redeemScript)
+bool CBasicKeyStore::AddCScript(const CScript& redeemScript)
{
CRITICAL_BLOCK(cs_KeyStore)
- mapScripts[hash] = redeemScript;
+ mapScripts[Hash160(redeemScript)] = redeemScript;
return true;
}
CSecret vchSecret;
if(!DecryptSecret(vMasterKeyIn, vchCryptedSecret, Hash(vchPubKey.begin(), vchPubKey.end()), vchSecret))
return false;
+ if (vchSecret.size() != 32)
+ return false;
CKey key;
key.SetPubKey(vchPubKey);
key.SetSecret(vchSecret);
CSecret vchSecret;
if (!DecryptSecret(vMasterKey, vchCryptedSecret, Hash(vchPubKey.begin(), vchPubKey.end()), vchSecret))
return false;
+ if (vchSecret.size() != 32)
+ return false;
keyOut.SetPubKey(vchPubKey);
keyOut.SetSecret(vchSecret);
return true;
BOOST_FOREACH(KeyMap::value_type& mKey, mapKeys)
{
CKey key;
- if (!key.SetSecret(mKey.second.first, false))
+ if (!key.SetSecret(mKey.second.first, mKey.second.second))
return false;
const std::vector<unsigned char> vchPubKey = key.GetPubKey();
std::vector<unsigned char> vchCryptedSecret;