mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-15 12:51:00 +02:00
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
This commit is contained in:
parent
ff33a3470d
commit
6e51b3bddf
4 changed files with 55 additions and 9 deletions
17
src/key.cpp
17
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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue