get rid of mapPubKeys

Make CKeyStore's interface work on uint160's instead of pubkeys, so
no separate global mapPubKeys is necessary anymore.
This commit is contained in:
Pieter Wuille
2011-07-05 16:42:32 +02:00
parent 133ccbe408
commit 03fbd79049
11 changed files with 97 additions and 110 deletions

View File

@@ -124,7 +124,6 @@ public:
bool CWallet::EncryptWallet(const string& strWalletPassphrase)
{
CRITICAL_BLOCK(cs_mapPubKeys)
CRITICAL_BLOCK(cs_KeyStore)
CRITICAL_BLOCK(cs_vMasterKey)
CRITICAL_BLOCK(cs_pwalletdbEncryption)
@@ -439,10 +438,8 @@ void CWalletTx::GetAmounts(int64& nGeneratedImmature, int64& nGeneratedMature, l
string address;
uint160 hash160;
vector<unsigned char> vchPubKey;
if (ExtractHash160(txout.scriptPubKey, hash160))
if (ExtractHash160(txout.scriptPubKey, pwallet, hash160))
address = Hash160ToAddress(hash160);
else if (ExtractPubKey(txout.scriptPubKey, NULL, vchPubKey))
address = PubKeyToAddress(vchPubKey);
else
{
printf("CWalletTx::GetAmounts: Unknown transaction type found, txid %s\n",
@@ -1136,7 +1133,7 @@ int CWallet::LoadWallet(bool& fFirstRunRet)
return nLoadWalletRet;
fFirstRunRet = vchDefaultKey.empty();
if (!HaveKey(vchDefaultKey))
if (!HaveKey(Hash160(vchDefaultKey)))
{
// Create new keyUser and set as default key
RandAddSeedPerfmon();
@@ -1263,7 +1260,7 @@ void CWallet::ReserveKeyFromKeyPool(int64& nIndex, CKeyPool& keypool)
setKeyPool.erase(setKeyPool.begin());
if (!walletdb.ReadPool(nIndex, keypool))
throw runtime_error("ReserveKeyFromKeyPool() : read failed");
if (!HaveKey(keypool.vchPubKey))
if (!HaveKey(Hash160(keypool.vchPubKey)))
throw runtime_error("ReserveKeyFromKeyPool() : unknown key in key pool");
assert(!keypool.vchPubKey.empty());
printf("keypool reserve %"PRI64d"\n", nIndex);