aboutsummaryrefslogtreecommitdiff
path: root/src/wallet.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/wallet.cpp')
-rw-r--r--src/wallet.cpp32
1 files changed, 16 insertions, 16 deletions
diff --git a/src/wallet.cpp b/src/wallet.cpp
index 62f663c0dc..2f8d7c05ab 100644
--- a/src/wallet.cpp
+++ b/src/wallet.cpp
@@ -16,7 +16,7 @@ using namespace std;
// mapWallet
//
-std::vector<unsigned char> CWallet::GenerateNewKey()
+CPubKey CWallet::GenerateNewKey()
{
bool fCompressed = CanSupportFeature(FEATURE_COMPRPUBKEY); // default to compressed public keys if we want 0.6.0 wallets
@@ -44,7 +44,7 @@ bool CWallet::AddKey(const CKey& key)
return true;
}
-bool CWallet::AddCryptedKey(const vector<unsigned char> &vchPubKey, const vector<unsigned char> &vchCryptedSecret)
+bool CWallet::AddCryptedKey(const CPubKey &vchPubKey, const vector<unsigned char> &vchCryptedSecret)
{
if (!CCryptoKeyStore::AddCryptedKey(vchPubKey, vchCryptedSecret))
return false;
@@ -366,7 +366,7 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn)
{
if (txout.scriptPubKey == scriptDefaultKey)
{
- std::vector<unsigned char> newDefaultKey;
+ CPubKey newDefaultKey;
if (GetKeyFromPool(newDefaultKey, false))
{
SetDefaultKey(newDefaultKey);
@@ -1095,7 +1095,7 @@ bool CWallet::CreateTransaction(const vector<pair<CScript, int64> >& vecSend, CW
// post-backup change.
// Reserve a new key pair from key pool
- vector<unsigned char> vchPubKey = reservekey.GetReservedKey();
+ CPubKey vchPubKey = reservekey.GetReservedKey();
// assert(mapKeys.count(vchPubKey));
// Fill a vout to ourself
@@ -1278,7 +1278,7 @@ int CWallet::LoadWallet(bool& fFirstRunRet)
if (nLoadWalletRet != DB_LOAD_OK)
return nLoadWalletRet;
- fFirstRunRet = vchDefaultKey.empty();
+ fFirstRunRet = !vchDefaultKey.IsValid();
CreateThread(ThreadFlushWalletDB, &strWalletFile);
return DB_LOAD_OK;
@@ -1332,7 +1332,7 @@ bool CWallet::GetTransaction(const uint256 &hashTx, CWalletTx& wtx)
return false;
}
-bool CWallet::SetDefaultKey(const std::vector<unsigned char> &vchPubKey)
+bool CWallet::SetDefaultKey(const CPubKey &vchPubKey)
{
if (fFileBacked)
{
@@ -1408,7 +1408,7 @@ bool CWallet::TopUpKeyPool()
void CWallet::ReserveKeyFromKeyPool(int64& nIndex, CKeyPool& keypool)
{
nIndex = -1;
- keypool.vchPubKey.clear();
+ keypool.vchPubKey = CPubKey();
{
LOCK(cs_wallet);
@@ -1425,9 +1425,9 @@ void CWallet::ReserveKeyFromKeyPool(int64& nIndex, CKeyPool& keypool)
setKeyPool.erase(setKeyPool.begin());
if (!walletdb.ReadPool(nIndex, keypool))
throw runtime_error("ReserveKeyFromKeyPool() : read failed");
- if (!HaveKey(Hash160(keypool.vchPubKey)))
+ if (!HaveKey(keypool.vchPubKey.GetID()))
throw runtime_error("ReserveKeyFromKeyPool() : unknown key in key pool");
- assert(!keypool.vchPubKey.empty());
+ assert(keypool.vchPubKey.IsValid());
printf("keypool reserve %"PRI64d"\n", nIndex);
}
}
@@ -1468,7 +1468,7 @@ void CWallet::ReturnKey(int64 nIndex)
printf("keypool return %"PRI64d"\n", nIndex);
}
-bool CWallet::GetKeyFromPool(vector<unsigned char>& result, bool fAllowReuse)
+bool CWallet::GetKeyFromPool(CPubKey& result, bool fAllowReuse)
{
int64 nIndex = 0;
CKeyPool keypool;
@@ -1477,7 +1477,7 @@ bool CWallet::GetKeyFromPool(vector<unsigned char>& result, bool fAllowReuse)
ReserveKeyFromKeyPool(nIndex, keypool);
if (nIndex == -1)
{
- if (fAllowReuse && !vchDefaultKey.empty())
+ if (fAllowReuse && vchDefaultKey.IsValid())
{
result = vchDefaultKey;
return true;
@@ -1503,7 +1503,7 @@ int64 CWallet::GetOldestKeyPoolTime()
return keypool.nTime;
}
-vector<unsigned char> CReserveKey::GetReservedKey()
+CPubKey CReserveKey::GetReservedKey()
{
if (nIndex == -1)
{
@@ -1517,7 +1517,7 @@ vector<unsigned char> CReserveKey::GetReservedKey()
vchPubKey = pwallet->vchDefaultKey;
}
}
- assert(!vchPubKey.empty());
+ assert(vchPubKey.IsValid());
return vchPubKey;
}
@@ -1526,7 +1526,7 @@ void CReserveKey::KeepKey()
if (nIndex != -1)
pwallet->KeepKey(nIndex);
nIndex = -1;
- vchPubKey.clear();
+ vchPubKey = CPubKey();
}
void CReserveKey::ReturnKey()
@@ -1534,7 +1534,7 @@ void CReserveKey::ReturnKey()
if (nIndex != -1)
pwallet->ReturnKey(nIndex);
nIndex = -1;
- vchPubKey.clear();
+ vchPubKey = CPubKey();
}
void CWallet::GetAllReserveAddresses(set<CBitcoinAddress>& setAddress)
@@ -1550,7 +1550,7 @@ void CWallet::GetAllReserveAddresses(set<CBitcoinAddress>& setAddress)
if (!walletdb.ReadPool(id, keypool))
throw runtime_error("GetAllReserveKeyHashes() : read failed");
CBitcoinAddress address(keypool.vchPubKey);
- assert(!keypool.vchPubKey.empty());
+ assert(keypool.vchPubKey.IsValid());
if (!HaveKey(address))
throw runtime_error("GetAllReserveKeyHashes() : unknown key in key pool");
setAddress.insert(address);