aboutsummaryrefslogtreecommitdiff
path: root/key.h
diff options
context:
space:
mode:
authors_nakamoto <s_nakamoto@1a98c847-1fd6-4fd8-948a-caf3550aa51b>2009-10-21 01:08:05 +0000
committers_nakamoto <s_nakamoto@1a98c847-1fd6-4fd8-948a-caf3550aa51b>2009-10-21 01:08:05 +0000
commit52109986881e77ba2f7a2e3dfe39f2f842732f16 (patch)
treeff0219ae68db2625da26e3dbfeaa24ede689da14 /key.h
parentc199b8499d6c8ac08fad0349c3c53e07d41c6ac7 (diff)
flush wallet.dat, multi-proc, reorg options, revert to startup folder shortcut
Diffstat (limited to 'key.h')
-rw-r--r--key.h12
1 files changed, 12 insertions, 0 deletions
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;
}