From 2ffba736e9102d016b96c2e5de2ce7757e612667 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Tue, 5 Jul 2011 20:53:43 +0200 Subject: Use CBitcoinAddress instead of string/uint160 Instead of conversion functions between pubkey/uint160/address in base58.h, have a fully fledged class CBitcoinAddress (CAddress was already taken) to represent addresses. --- src/keystore.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/keystore.cpp') diff --git a/src/keystore.cpp b/src/keystore.cpp index 9e1dab65fd..2125d8472a 100644 --- a/src/keystore.cpp +++ b/src/keystore.cpp @@ -16,10 +16,10 @@ std::vector CKeyStore::GenerateNewKey() return key.GetPubKey(); } -bool CKeyStore::GetPubKey(const uint160 &hashAddress, std::vector &vchPubKeyOut) const +bool CKeyStore::GetPubKey(const CBitcoinAddress &address, std::vector &vchPubKeyOut) const { CKey key; - if (!GetKey(hashAddress, key)) + if (!GetKey(address, key)) return false; vchPubKeyOut = key.GetPubKey(); return true; @@ -28,7 +28,7 @@ bool CKeyStore::GetPubKey(const uint160 &hashAddress, std::vector bool CBasicKeyStore::AddKey(const CKey& key) { CRITICAL_BLOCK(cs_KeyStore) - mapKeys[Hash160(key.GetPubKey())] = key.GetSecret(); + mapKeys[key.GetAddress()] = key.GetSecret(); return true; } @@ -98,19 +98,19 @@ bool CCryptoKeyStore::AddCryptedKey(const std::vector &vchPubKey, if (!SetCrypted()) return false; - mapCryptedKeys[Hash160(vchPubKey)] = make_pair(vchPubKey, vchCryptedSecret); + mapCryptedKeys[CBitcoinAddress(vchPubKey)] = make_pair(vchPubKey, vchCryptedSecret); } return true; } -bool CCryptoKeyStore::GetKey(const uint160 &hashAddress, CKey& keyOut) const +bool CCryptoKeyStore::GetKey(const CBitcoinAddress &address, CKey& keyOut) const { CRITICAL_BLOCK(cs_vMasterKey) { if (!IsCrypted()) - return CBasicKeyStore::GetKey(hashAddress, keyOut); + return CBasicKeyStore::GetKey(address, keyOut); - CryptedKeyMap::const_iterator mi = mapCryptedKeys.find(hashAddress); + CryptedKeyMap::const_iterator mi = mapCryptedKeys.find(address); if (mi != mapCryptedKeys.end()) { const std::vector &vchPubKey = (*mi).second.first; @@ -125,14 +125,14 @@ bool CCryptoKeyStore::GetKey(const uint160 &hashAddress, CKey& keyOut) const return false; } -bool CCryptoKeyStore::GetPubKey(const uint160 &hashAddress, std::vector& vchPubKeyOut) const +bool CCryptoKeyStore::GetPubKey(const CBitcoinAddress &address, std::vector& vchPubKeyOut) const { CRITICAL_BLOCK(cs_vMasterKey) { if (!IsCrypted()) - return CKeyStore::GetPubKey(hashAddress, vchPubKeyOut); + return CKeyStore::GetPubKey(address, vchPubKeyOut); - CryptedKeyMap::const_iterator mi = mapCryptedKeys.find(hashAddress); + CryptedKeyMap::const_iterator mi = mapCryptedKeys.find(address); if (mi != mapCryptedKeys.end()) { vchPubKeyOut = (*mi).second.first; -- cgit v1.2.3