aboutsummaryrefslogtreecommitdiff
path: root/src/wallet.cpp
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2012-02-18 14:55:02 +0100
committerPieter Wuille <pieter.wuille@gmail.com>2012-02-18 15:42:29 +0100
commit0b807a417f4a15f3e37ae35e70a72e6169f01c02 (patch)
treeda6bc0f32945d45a8cb9a366d6a729260e33bdda /src/wallet.cpp
parent2d36b60f9278f2b6fedadbb3b5f29e19244f5cef (diff)
downloadbitcoin-0b807a417f4a15f3e37ae35e70a72e6169f01c02.tar.xz
Add SetMinVersion to CWallet
Diffstat (limited to 'src/wallet.cpp')
-rw-r--r--src/wallet.cpp31
1 files changed, 29 insertions, 2 deletions
diff --git a/src/wallet.cpp b/src/wallet.cpp
index 1e769d7e61..42c49aa891 100644
--- a/src/wallet.cpp
+++ b/src/wallet.cpp
@@ -131,6 +131,32 @@ public:
)
};
+bool CWallet::SetMinVersion(int nVersion, CWalletDB* pwalletdbIn)
+{
+ if (nWalletVersion >= nVersion)
+ return true;
+
+ nWalletVersion = nVersion;
+
+ if (fFileBacked)
+ {
+ CWalletDB* pwalletdb = pwalletdbIn ? pwalletdbIn : new CWalletDB(strWalletFile);
+ if (nWalletVersion >= 40000)
+ {
+ // Versions prior to 0.4.0 did not support the "minversion" record.
+ // Use a CCorruptAddress to make them crash instead.
+ CCorruptAddress corruptAddress;
+ pwalletdb->WriteSetting("addrIncoming", corruptAddress);
+ }
+ if (nWalletVersion > 40000)
+ pwalletdb->WriteMinVersion(nWalletVersion);
+ if (!pwalletdbIn)
+ delete pwalletdb;
+ }
+
+ return true;
+}
+
bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase)
{
if (IsCrypted())
@@ -184,10 +210,11 @@ bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase)
exit(1); //We now probably have half of our keys encrypted in memory, and half not...die and let the user reload their unencrypted wallet.
}
+ // Encryption was introduced in version 0.4.0
+ SetMinVersion(40000, pwalletdbEncryption);
+
if (fFileBacked)
{
- CCorruptAddress corruptAddress;
- pwalletdbEncryption->WriteSetting("addrIncoming", corruptAddress);
if (!pwalletdbEncryption->TxnCommit())
exit(1); //We now have keys encrypted in memory, but no on disk...die to avoid confusion and let the user reload their unencrypted wallet.