aboutsummaryrefslogtreecommitdiff
path: root/src/wallet.cpp
diff options
context:
space:
mode:
authorJeff Garzik <jgarzik@bitpay.com>2013-06-10 09:36:29 -0400
committerJeff Garzik <jgarzik@bitpay.com>2013-06-10 09:36:29 -0400
commit3869fb89b60091281b43a35921057ba3f43c18f0 (patch)
tree3510aec7ccc74db41f25393f929db896f087cfea /src/wallet.cpp
parentf59530ce6eb5a889e6eb750024ddb20e7b0df9d7 (diff)
Wallet: store key creation time. Calculate whole-wallet birthday.
This also encapsulate wallet-read state information into CWalletScanState.
Diffstat (limited to 'src/wallet.cpp')
-rw-r--r--src/wallet.cpp27
1 files changed, 22 insertions, 5 deletions
diff --git a/src/wallet.cpp b/src/wallet.cpp
index 7041d49dab..aa13711110 100644
--- a/src/wallet.cpp
+++ b/src/wallet.cpp
@@ -45,20 +45,33 @@ CPubKey CWallet::GenerateNewKey()
return pubkey;
}
-bool CWallet::AddKeyPubKey(const CKey& secret, const CPubKey &pubkey)
+bool CWallet::AddKeyPubKey(const CKey& secret, const CPubKey &pubkey,
+ int64 nCreateTime)
{
+ if (!nCreateTime)
+ nCreateTime = GetTime();
+ if (!nTimeFirstKey || (nCreateTime < nTimeFirstKey))
+ nTimeFirstKey = nCreateTime;
if (!CCryptoKeyStore::AddKeyPubKey(secret, pubkey))
return false;
if (!fFileBacked)
return true;
if (!IsCrypted()) {
- return CWalletDB(strWalletFile).WriteKey(pubkey, secret.GetPrivKey());
+ return CWalletDB(strWalletFile).WriteKey(pubkey,
+ secret.GetPrivKey(),
+ nCreateTime);
}
return true;
}
-bool CWallet::AddCryptedKey(const CPubKey &vchPubKey, const vector<unsigned char> &vchCryptedSecret)
+bool CWallet::AddCryptedKey(const CPubKey &vchPubKey,
+ const vector<unsigned char> &vchCryptedSecret,
+ int64 nCreateTime)
{
+ if (!nCreateTime)
+ nCreateTime = GetTime();
+ if (!nTimeFirstKey || (nCreateTime < nTimeFirstKey))
+ nTimeFirstKey = nCreateTime;
if (!CCryptoKeyStore::AddCryptedKey(vchPubKey, vchCryptedSecret))
return false;
if (!fFileBacked)
@@ -66,9 +79,13 @@ bool CWallet::AddCryptedKey(const CPubKey &vchPubKey, const vector<unsigned char
{
LOCK(cs_wallet);
if (pwalletdbEncryption)
- return pwalletdbEncryption->WriteCryptedKey(vchPubKey, vchCryptedSecret);
+ return pwalletdbEncryption->WriteCryptedKey(vchPubKey,
+ vchCryptedSecret,
+ nCreateTime);
else
- return CWalletDB(strWalletFile).WriteCryptedKey(vchPubKey, vchCryptedSecret);
+ return CWalletDB(strWalletFile).WriteCryptedKey(vchPubKey,
+ vchCryptedSecret,
+ nCreateTime);
}
return false;
}