diff options
author | Gavin Andresen <gavinandresen@gmail.com> | 2013-10-16 20:12:38 -0700 |
---|---|---|
committer | Gavin Andresen <gavinandresen@gmail.com> | 2013-10-16 20:12:38 -0700 |
commit | 796e7b7aecd84a5c0cd7098c2f770ef8fba732e3 (patch) | |
tree | 1abfc8aaa832090071cf96ea611685d7af86a64f /src/key.cpp | |
parent | 5a8a4be28949fd0531ae5ea8e21c713373e22c01 (diff) | |
parent | bc68788317a4ece16f0cfb0cb7eb1e0e220cbc6f (diff) |
Merge pull request #2950 from pstratem/walletload
Walletload
Diffstat (limited to 'src/key.cpp')
-rw-r--r-- | src/key.cpp | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/key.cpp b/src/key.cpp index 8ef1c414c4..414845a9da 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)) @@ -411,6 +414,24 @@ 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; + + if (fSkipCheck) + return true; + + if (GetPubKey() != vchPubKey) + return false; + + return true; +} + bool CPubKey::Verify(const uint256 &hash, const std::vector<unsigned char>& vchSig) const { if (!IsValid()) return false; |