From 7ec552676c66488fe00fb503d02ec4a389a715b7 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Tue, 5 Jul 2011 03:06:19 +0200 Subject: Add minversion to wallet. --- src/db.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/db.cpp') diff --git a/src/db.cpp b/src/db.cpp index f044355a35..9e13727ae7 100644 --- a/src/db.cpp +++ b/src/db.cpp @@ -670,7 +670,7 @@ void CWalletDB::ListAccountCreditDebit(const string& strAccount, listvchDefaultKey.clear(); int nFileVersion = 0; @@ -690,7 +690,7 @@ bool CWalletDB::LoadWallet(CWallet* pwallet) // Get cursor Dbc* pcursor = GetCursor(); if (!pcursor) - return false; + return DB_CORRUPT; loop { @@ -701,7 +701,7 @@ bool CWalletDB::LoadWallet(CWallet* pwallet) if (ret == DB_NOTFOUND) break; else if (ret != 0) - return false; + return DB_CORRUPT; // Unserialize // Taking advantage of the fact that pair serialization @@ -809,6 +809,13 @@ bool CWalletDB::LoadWallet(CWallet* pwallet) if (strKey == "addrProxy") ssValue >> addrProxy; if (fHaveUPnP && strKey == "fUseUPnP") ssValue >> fUseUPnP; } + else if (strType == "minversion") + { + int nMinVersion = 0; + ssValue >> nMinVersion; + if (nMinVersion > VERSION) + return DB_TOO_NEW; + } } pcursor->close(); } @@ -839,7 +846,7 @@ bool CWalletDB::LoadWallet(CWallet* pwallet) } - return true; + return DB_LOAD_OK; } void ThreadFlushWalletDB(void* parg) -- cgit v1.2.3 From acd6501610817eee0bd1c8ea9c591f043affbaec Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Sat, 25 Jun 2011 14:57:32 +0200 Subject: Prepare codebase for Encrypted Keys. --- src/db.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src/db.cpp') diff --git a/src/db.cpp b/src/db.cpp index f044355a35..c479a452cd 100644 --- a/src/db.cpp +++ b/src/db.cpp @@ -685,7 +685,7 @@ bool CWalletDB::LoadWallet(CWallet* pwallet) //// todo: shouldn't we catch exceptions and try to recover and continue? CRITICAL_BLOCK(pwallet->cs_mapWallet) - CRITICAL_BLOCK(pwallet->cs_mapKeys) + CRITICAL_BLOCK(pwallet->cs_KeyStore) { // Get cursor Dbc* pcursor = GetCursor(); @@ -765,14 +765,20 @@ bool CWalletDB::LoadWallet(CWallet* pwallet) { vector vchPubKey; ssKey >> vchPubKey; - CWalletKey wkey; + CKey key; if (strType == "key") - ssValue >> wkey.vchPrivKey; + { + CPrivKey pkey; + ssValue >> pkey; + key.SetPrivKey(pkey); + } else + { + CWalletKey wkey; ssValue >> wkey; - - pwallet->mapKeys[vchPubKey] = wkey.vchPrivKey; - mapPubKeys[Hash160(vchPubKey)] = vchPubKey; + key.SetPrivKey(wkey.vchPrivKey); + } + pwallet->LoadKey(key); } else if (strType == "defaultkey") { -- cgit v1.2.3 From 4e87d341f75f13bbd7d108c31c03886fbc4df56f Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Fri, 8 Jul 2011 15:47:35 +0200 Subject: Add wallet privkey encryption. This commit adds support for ckeys, or enCrypted private keys, to the wallet. All keys are stored in memory in their encrypted form and thus the passphrase is required from the user to spend coins, or to create new addresses. Keys are encrypted with AES-256-CBC using OpenSSL's EVP library. The key is calculated via EVP_BytesToKey using SHA512 with (by default) 25000 rounds and a random salt. By default, the user's wallet remains unencrypted until they call the RPC command encryptwallet or, from the GUI menu, Options-> Encrypt Wallet. When the user is attempting to call RPC functions which require the password to unlock the wallet, an error will be returned unless they call walletpassphrase