diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2013-05-01 06:52:05 +0200 |
---|---|---|
committer | Pieter Wuille <sipa@ulyssis.org> | 2013-05-30 05:20:21 +0200 |
commit | dfa23b94c24aae6466152fccbe896ba5dc0e97b4 (patch) | |
tree | a1f7f856577b2223bae9351c960b595b4032ce7a /src/walletdb.cpp | |
parent | 5d891489ab7828ad8db15e85bb63e2f13f021a6a (diff) |
CSecret/CKey -> CKey/CPubKey split/refactor
Diffstat (limited to 'src/walletdb.cpp')
-rw-r--r-- | src/walletdb.cpp | 59 |
1 files changed, 20 insertions, 39 deletions
diff --git a/src/walletdb.cpp b/src/walletdb.cpp index 81a21443a1..4a73413d26 100644 --- a/src/walletdb.cpp +++ b/src/walletdb.cpp @@ -262,52 +262,33 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue, } else if (strType == "key" || strType == "wkey") { - vector<unsigned char> vchPubKey; + CPubKey vchPubKey; ssKey >> vchPubKey; + if (!vchPubKey.IsValid()) + { + strErr = "Error reading wallet database: CPubKey corrupt"; + return false; + } CKey key; + CPrivKey pkey; if (strType == "key") - { - CPrivKey pkey; ssValue >> pkey; - key.SetPubKey(vchPubKey); - if (!key.SetPrivKey(pkey)) - { - strErr = "Error reading wallet database: CPrivKey corrupt"; - return false; - } - if (key.GetPubKey() != vchPubKey) - { - strErr = "Error reading wallet database: CPrivKey pubkey inconsistency"; - return false; - } - if (!key.IsValid()) - { - strErr = "Error reading wallet database: invalid CPrivKey"; - return false; - } - } - else - { + else { CWalletKey wkey; ssValue >> wkey; - key.SetPubKey(vchPubKey); - if (!key.SetPrivKey(wkey.vchPrivKey)) - { - strErr = "Error reading wallet database: CPrivKey corrupt"; - return false; - } - if (key.GetPubKey() != vchPubKey) - { - strErr = "Error reading wallet database: CWalletKey pubkey inconsistency"; - return false; - } - if (!key.IsValid()) - { - strErr = "Error reading wallet database: invalid CWalletKey"; - return false; - } + pkey = wkey.vchPrivKey; + } + if (!key.SetPrivKey(pkey, vchPubKey.IsCompressed())) + { + strErr = "Error reading wallet database: CPrivKey corrupt"; + return false; + } + if (key.GetPubKey() != vchPubKey) + { + strErr = "Error reading wallet database: CPrivKey pubkey inconsistency"; + return false; } - if (!pwallet->LoadKey(key)) + if (!pwallet->LoadKey(key, vchPubKey)) { strErr = "Error reading wallet database: LoadKey failed"; return false; |