diff options
author | patrick s <patrick.strateman@gmail.com> | 2013-08-28 23:53:26 -0700 |
---|---|---|
committer | patrick s <patrick.strateman@gmail.com> | 2013-08-28 23:53:26 -0700 |
commit | 6e51b3bddf782f53527cf968445b298ebdec9bbc (patch) | |
tree | d7cd486a75648cbcc5e5aec9da4bbf4e21292bb6 /src/key.cpp | |
parent | ff33a3470dd1d1446549d02609c991c0490e0fdf (diff) |
improve wallet load time by removing duplicated calls to EC_KEY_check_key and adding a hash for vchPubKey/vchPrivKey entries in wallet.dat
backwards compatible with previous wallet.dat format
Diffstat (limited to 'src/key.cpp')
-rw-r--r-- | src/key.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/key.cpp b/src/key.cpp index 85dc9cda2b..0377140f79 100644 --- a/src/key.cpp +++ b/src/key.cpp @@ -166,9 +166,12 @@ public: assert(nSize == nSize2); } - bool SetPrivKey(const CPrivKey &privkey) { + bool SetPrivKey(const CPrivKey &privkey, bool fSkipCheck=false) { const unsigned char* pbegin = &privkey[0]; if (d2i_ECPrivateKey(&pkey, &pbegin, privkey.size())) { + if(fSkipCheck) + return true; + // d2i_ECPrivateKey returns true if parsing succeeds. // This doesn't necessarily mean the key is valid. if (EC_KEY_check_key(pkey)) @@ -409,6 +412,18 @@ bool CKey::SignCompact(const uint256 &hash, std::vector<unsigned char>& vchSig) return true; } +bool CKey::Load(CPrivKey &privkey, CPubKey &vchPubKey, bool fSkipCheck=false) { + CECKey key; + if (!key.SetPrivKey(privkey, fSkipCheck)) + return false; + + key.GetSecretBytes(vch); + fCompressed = vchPubKey.IsCompressed(); + fValid = true; + + return true; +} + bool CPubKey::Verify(const uint256 &hash, const std::vector<unsigned char>& vchSig) const { if (!IsValid()) return false; |