Cleanups.

This commit is contained in:
JoelKatz
2011-12-27 20:48:44 -08:00
parent 4b88113a51
commit ca33205b83
2 changed files with 8 additions and 18 deletions

View File

@@ -33,9 +33,10 @@ std::string LocalAccountEntry::getLocalAccountName() const
return NewcoinAddress(mAccountFamily).GetString() + ":" + boost::lexical_cast<std::string>(mAccountSeq); return NewcoinAddress(mAccountFamily).GetString() + ":" + boost::lexical_cast<std::string>(mAccountSeq);
} }
LocalAccountFamily::LocalAccountFamily(const uint160& family, EC_POINT* pubKey) : LocalAccountFamily::LocalAccountFamily(const uint160& family, const EC_GROUP* group, const EC_POINT* pubKey) :
mFamily(family), mRootPubKey(pubKey), mLastSeq(0), mRootPrivateKey(NULL) mFamily(family), mLastSeq(0), mRootPrivateKey(NULL)
{ {
mRootPubKey=EC_POINT_dup(pubKey, group);
#ifdef DEBUG #ifdef DEBUG
std::cerr << "LocalAccountFamily::LocalAccountFamily(" << family.GetHex() << "," << std::endl; std::cerr << "LocalAccountFamily::LocalAccountFamily(" << family.GetHex() << "," << std::endl;
EC_GROUP *grp=EC_GROUP_new_by_curve_name(NID_secp256k1); EC_GROUP *grp=EC_GROUP_new_by_curve_name(NID_secp256k1);
@@ -274,15 +275,9 @@ LocalAccountFamily::pointer Wallet::doPublic(const std::string& pubKey)
return fit->second; return fit->second;
} }
EC_POINT* rootPub=EC_POINT_dup(EC_KEY_get0_public_key(pkey), EC_KEY_get0_group(pkey)); LocalAccountFamily::pointer fam(new LocalAccountFamily(family,
EC_KEY_get0_group(pkey), EC_KEY_get0_public_key(pkey)));
EC_KEY_free(pkey); EC_KEY_free(pkey);
if(!rootPub)
{
assert(false);
return LocalAccountFamily::pointer();
}
LocalAccountFamily::pointer fam(new LocalAccountFamily(family, rootPub));
families.insert(std::make_pair(family, fam)); families.insert(std::make_pair(family, fam));
return fam; return fam;
} }
@@ -308,13 +303,8 @@ LocalAccountFamily::pointer Wallet::doPrivate(const uint256& passPhrase, bool do
EC_KEY_free(base); EC_KEY_free(base);
return LocalAccountFamily::pointer(); return LocalAccountFamily::pointer();
} }
EC_POINT *pubKey=EC_POINT_dup(EC_KEY_get0_public_key(base), EC_KEY_get0_group(base)); fam=LocalAccountFamily::pointer(new LocalAccountFamily(family,
if(!pubKey) EC_KEY_get0_group(base), EC_KEY_get0_public_key(base)));
{
EC_KEY_free(base);
return LocalAccountFamily::pointer();
}
fam=LocalAccountFamily::pointer(new LocalAccountFamily(family, pubKey));
families.insert(std::make_pair(family, fam)); families.insert(std::make_pair(family, fam));
} }
else fam=it->second; else fam=it->second;

View File

@@ -76,7 +76,7 @@ protected:
public: public:
LocalAccountFamily(const uint160& family, EC_POINT* pubKey); LocalAccountFamily(const uint160& family, const EC_GROUP* group, const EC_POINT* pubKey);
~LocalAccountFamily(); ~LocalAccountFamily();
const uint160& getFamily() { return mFamily; } const uint160& getFamily() { return mFamily; }