DB_NEED_REWRITE
};
+class CKeyMetadata
+{
+public:
+ static const int CURRENT_VERSION=1;
+ int nVersion;
+ int64 nCreateTime; // 0 means unknown
+
+ CKeyMetadata()
+ {
+ SetNull();
+ }
+ CKeyMetadata(int64 nCreateTime_)
+ {
+ nVersion = CKeyMetadata::CURRENT_VERSION;
+ nCreateTime = nCreateTime_;
+ }
+
+ IMPLEMENT_SERIALIZE
+ (
+ READWRITE(this->nVersion);
+ nVersion = this->nVersion;
+ READWRITE(nCreateTime);
+ )
+
+ void SetNull()
+ {
+ nVersion = CKeyMetadata::CURRENT_VERSION;
+ nCreateTime = 0;
+ }
+};
+
+
/** Access to the wallet database (wallet.dat) */
class CWalletDB : public CDB
{
return Erase(std::make_pair(std::string("tx"), hash));
}
- bool WriteKey(const CPubKey& vchPubKey, const CPrivKey& vchPrivKey)
+ bool WriteKey(const CPubKey& vchPubKey, const CPrivKey& vchPrivKey, int64 nCreateTime)
{
nWalletDBUpdated++;
+
+ CKeyMetadata keyMeta(nCreateTime);
+ if(!Write(std::make_pair(std::string("keymeta"), vchPubKey), keyMeta, false))
+ return false;
+
return Write(std::make_pair(std::string("key"), vchPubKey.Raw()), vchPrivKey, false);
}
- bool WriteCryptedKey(const CPubKey& vchPubKey, const std::vector<unsigned char>& vchCryptedSecret, bool fEraseUnencryptedKey = true)
+ bool WriteCryptedKey(const CPubKey& vchPubKey, const std::vector<unsigned char>& vchCryptedSecret, int64 nCreateTime)
{
nWalletDBUpdated++;
+ bool fEraseUnencryptedKey = true;
+
+ CKeyMetadata keyMeta(nCreateTime);
+ if(!Write(std::make_pair(std::string("keymeta"), vchPubKey), keyMeta, false))
+ return false;
+
if (!Write(std::make_pair(std::string("ckey"), vchPubKey.Raw()), vchCryptedSecret, false))
return false;
if (fEraseUnencryptedKey)