diff options
| author | Gavin Andresen <[email protected]> | 2013-10-16 20:12:38 -0700 |
|---|---|---|
| committer | Gavin Andresen <[email protected]> | 2013-10-16 20:12:38 -0700 |
| commit | 796e7b7aecd84a5c0cd7098c2f770ef8fba732e3 (patch) | |
| tree | 1abfc8aaa832090071cf96ea611685d7af86a64f /src/key.cpp | |
| parent | Merge pull request #2645 from sipa/inlinesighash (diff) | |
| parent | comment explaining new wallet format for key/wkey entries (diff) | |
| download | discoin-796e7b7aecd84a5c0cd7098c2f770ef8fba732e3.tar.xz discoin-796e7b7aecd84a5c0cd7098c2f770ef8fba732e3.zip | |
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 8ef1c414c..414845a9d 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; |