From 99cef996c788755af95a0a614d7154a30928d4b9 Mon Sep 17 00:00:00 2001 From: s_nakamoto Date: Wed, 21 Oct 2009 01:08:05 +0000 Subject: flush wallet.dat, multi-proc, reorg options, revert to startup folder shortcut git-svn-id: https://bitcoin.svn.sourceforge.net/svnroot/bitcoin/trunk@15 1a98c847-1fd6-4fd8-948a-caf3550aa51b --- key.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'key.h') diff --git a/key.h b/key.h index 8b0b54e4b3..39ca86d317 100644 --- a/key.h +++ b/key.h @@ -44,6 +44,7 @@ class CKey { protected: EC_KEY* pkey; + bool fSet; public: CKey() @@ -51,6 +52,7 @@ public: pkey = EC_KEY_new_by_curve_name(NID_secp256k1); if (pkey == NULL) throw key_error("CKey::CKey() : EC_KEY_new_by_curve_name failed"); + fSet = false; } CKey(const CKey& b) @@ -58,12 +60,14 @@ public: pkey = EC_KEY_dup(b.pkey); if (pkey == NULL) throw key_error("CKey::CKey(const CKey&) : EC_KEY_dup failed"); + fSet = b.fSet; } CKey& operator=(const CKey& b) { if (!EC_KEY_copy(pkey, b.pkey)) throw key_error("CKey::operator=(const CKey&) : EC_KEY_copy failed"); + fSet = b.fSet; return (*this); } @@ -72,10 +76,16 @@ public: EC_KEY_free(pkey); } + bool IsNull() const + { + return !fSet; + } + void MakeNewKey() { if (!EC_KEY_generate_key(pkey)) throw key_error("CKey::MakeNewKey() : EC_KEY_generate_key failed"); + fSet = true; } bool SetPrivKey(const CPrivKey& vchPrivKey) @@ -83,6 +93,7 @@ public: const unsigned char* pbegin = &vchPrivKey[0]; if (!d2i_ECPrivateKey(&pkey, &pbegin, vchPrivKey.size())) return false; + fSet = true; return true; } @@ -103,6 +114,7 @@ public: const unsigned char* pbegin = &vchPubKey[0]; if (!o2i_ECPublicKey(&pkey, &pbegin, vchPubKey.size())) return false; + fSet = true; return true; } -- cgit v1.2.3