From 0b807a417f4a15f3e37ae35e70a72e6169f01c02 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Sat, 18 Feb 2012 14:55:02 +0100 Subject: Add SetMinVersion to CWallet --- src/wallet.cpp | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'src/wallet.cpp') diff --git a/src/wallet.cpp b/src/wallet.cpp index 1e769d7e6..42c49aa89 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. -- cgit v1.2.3 From 9976cf070fdda61afa30cd65ef5bcddad4f43e81 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Sat, 18 Feb 2012 15:02:36 +0100 Subject: Move GenerateNewKey back to CWallet --- src/wallet.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/wallet.cpp') diff --git a/src/wallet.cpp b/src/wallet.cpp index 42c49aa89..da64aa510 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -15,6 +15,16 @@ using namespace std; // mapWallet // +std::vector CWallet::GenerateNewKey() +{ + RandAddSeedPerfmon(); + CKey key; + key.MakeNewKey(); + if (!AddKey(key)) + throw std::runtime_error("CWallet::GenerateNewKey() : AddKey failed"); + return key.GetPubKey(); +} + bool CWallet::AddKey(const CKey& key) { if (!CCryptoKeyStore::AddKey(key)) -- cgit v1.2.3 From 38067c18f8b54c7121643fa3291ffe81b6eefef1 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Sat, 18 Feb 2012 15:06:32 +0100 Subject: Make compressed pubkeys require 0.6.0 --- src/wallet.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/wallet.cpp') diff --git a/src/wallet.cpp b/src/wallet.cpp index da64aa510..8a33041a1 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -17,9 +17,16 @@ using namespace std; std::vector CWallet::GenerateNewKey() { + bool fCompressed = true; // default to compressed public keys + RandAddSeedPerfmon(); CKey key; - key.MakeNewKey(); + key.MakeNewKey(fCompressed); + + // Compressed public keys were introduced in version 0.6.0 + if (fCompressed) + SetMinVersion(59900); + if (!AddKey(key)) throw std::runtime_error("CWallet::GenerateNewKey() : AddKey failed"); return key.GetPubKey(); -- cgit v1.2.3