diff --git a/src/Application.cpp b/src/Application.cpp index a4cd2ed4b2..63d30385f7 100644 --- a/src/Application.cpp +++ b/src/Application.cpp @@ -111,3 +111,4 @@ Application::~Application() delete mHashNodeDB; delete mNetNodeDB; } +// vim:ts=4 diff --git a/src/DBInit.cpp b/src/DBInit.cpp index 49f36c2303..48be4d9c2d 100644 --- a/src/DBInit.cpp +++ b/src/DBInit.cpp @@ -19,7 +19,8 @@ const char *TxnDBInit[] = { "CREATE TABLE PubKeys ( \ ID CHARACTER(35) PRIMARY KEY, \ PubKey BLOB \ - );" }; + );" +}; int TxnDBCount=sizeof(TxnDBInit)/sizeof(const char *); @@ -45,7 +46,7 @@ const char *LedgerDBInit[] = { "CREATE INDEX LedgerConfByHash ON \ LedgerConfirmations(LedgerHash)" #endif - }; +}; int LedgerDBCount=sizeof(LedgerDBInit)/sizeof(const char *); @@ -56,11 +57,16 @@ const char *WalletDBInit[] = { Seq BIGINT UNSIGNED, \ Comment TEXT \ );", + "CREATE TABLE NodeIdentity ( \ + PublicKey CHARACTER(53), \ + PrivateKey CHARACTER(52) \ + );" "CREATE TABLE TrustedNodes ( \ - Hanko CHARACTER(35) PRIMARY KEY, \ - PubKey CHARACTER(53), \ - Comment TEXT \ - );" }; + Hanko CHARACTER(35) PRIMARY KEY, \ + PublicKey CHARACTER(53), \ + Comment TEXT \ + );" +}; #if 0 "CREATE TABLE LocalAccounts ( \ @@ -97,7 +103,7 @@ const char *NetNodeDBInit[] = { HaveContactInfo CHARACTER(1), \ ContactObject BLOB \ );" - }; +}; int NetNodeDBCount=sizeof(NetNodeDBInit)/sizeof(const char *); diff --git a/src/LocalAccount.h b/src/LocalAccount.h index 542ef2a500..3f10d8ae3b 100644 --- a/src/LocalAccount.h +++ b/src/LocalAccount.h @@ -77,7 +77,7 @@ protected: public: - LocalAccountFamily(const NewcoinAddress& family); + LocalAccountFamily(const NewcoinAddress& familyGenerator); ~LocalAccountFamily(); const NewcoinAddress& getFamily() const { return mFamily; } @@ -106,3 +106,4 @@ public: }; #endif +// vim:ts=4 diff --git a/src/NewcoinAddress.cpp b/src/NewcoinAddress.cpp index c49bbbf006..96b65f9182 100644 --- a/src/NewcoinAddress.cpp +++ b/src/NewcoinAddress.cpp @@ -2,7 +2,8 @@ #include "key.h" #include "Config.h" #include "BitcoinUtil.h" -#include "openssl/ec.h" + +#include "openssl/rand.h" #include #include @@ -73,6 +74,10 @@ void NewcoinAddress::setHanko(const uint160& hash160) SetData(VER_HANKO, hash160.begin(), 20); } +void NewcoinAddress::setHanko(const NewcoinAddress& nodePublic) { + setHanko(nodePublic.getHanko()); +} + // // NodePublic // @@ -158,6 +163,10 @@ bool NewcoinAddress::setNodePrivate(const std::string& strPrivate) return SetString(strPrivate.c_str(), VER_NODE_PRIVATE); } +void NewcoinAddress::setNodePrivate(const std::vector& vPrivate) { + SetData(VER_NODE_PRIVATE, vPrivate); +} + void NewcoinAddress::setNodePrivate(uint256 hash256) { SetData(VER_NODE_PRIVATE, hash256.begin(), 32); @@ -311,6 +320,11 @@ bool NewcoinAddress::setAccountPrivate(const std::string& strPrivate) return SetString(strPrivate.c_str(), VER_ACCOUNT_PRIVATE); } +void NewcoinAddress::setAccountPrivate(const std::vector& vPrivate) +{ + SetData(VER_ACCOUNT_PRIVATE, vPrivate); +} + void NewcoinAddress::setAccountPrivate(uint256 hash256) { SetData(VER_ACCOUNT_PRIVATE, hash256.begin(), 32); @@ -446,4 +460,13 @@ bool NewcoinAddress::setFamilySeed(const std::string& strSeed) void NewcoinAddress::setFamilySeed(uint128 hash128) { SetData(VER_FAMILY_SEED, hash128.begin(), 16); } + +void NewcoinAddress::setFamilySeedRandom() +{ + uint128 key; + + RAND_bytes((unsigned char *) &key, sizeof(key)); + + NewcoinAddress::setFamilySeed(key); +} // vim:ts=4 diff --git a/src/NewcoinAddress.h b/src/NewcoinAddress.h index 644d000bce..9ca8ebc0f1 100644 --- a/src/NewcoinAddress.h +++ b/src/NewcoinAddress.h @@ -38,6 +38,7 @@ public: bool setHanko(const std::string& strHanko); void setHanko(const uint160& hash160); + void setHanko(const NewcoinAddress& nodePublic); // // Node Public @@ -57,6 +58,7 @@ public: std::string humanNodePrivate() const; bool setNodePrivate(const std::string& strPrivate); + void setNodePrivate(const std::vector& vPrivate); void setNodePrivate(uint256 hash256); // @@ -88,6 +90,7 @@ public: std::string humanAccountPrivate() const; bool setAccountPrivate(const std::string& strPrivate); + void setAccountPrivate(const std::vector& vPrivate); void setAccountPrivate(uint256 hash256); // @@ -112,6 +115,7 @@ public: bool setFamilySeed(const std::string& strSeed); void setFamilySeed(uint128 hash128); + void setFamilySeedRandom(); }; #endif diff --git a/src/RPCServer.cpp b/src/RPCServer.cpp index 05a66215aa..b82cdee14f 100644 --- a/src/RPCServer.cpp +++ b/src/RPCServer.cpp @@ -5,7 +5,6 @@ #include #include -#include "../json/value.h" #include "../json/reader.h" #include "../json/writer.h" @@ -498,9 +497,9 @@ Json::Value RPCServer::doLedger(Json::Value& params) return "not implemented"; } -Json::Value RPCServer::doAddUnl(Json::Value& params) { - // addUNL - // addUNL +Json::Value RPCServer::doUnlAdd(Json::Value& params) { + // unl_add + // unl_add if(params.size()==1 || params.size()==2) { std::string pubKey=params[0u].asString(); @@ -524,23 +523,43 @@ Json::Value RPCServer::doAddUnl(Json::Value& params) { else return "invalid params"; } -Json::Value RPCServer::doGetUnl(Json::Value& params) { - std::string str; - theApp->getUNL().dumpUNL(str); +Json::Value RPCServer::doUnlDefault(Json::Value& params) { + return "not implemented"; +} - return str.c_str(); +Json::Value RPCServer::doUnlDelete(Json::Value& params) { + return "not implemented"; +} + +Json::Value RPCServer::doUnlFetch(Json::Value& params) { + return "not implemented"; +} + +Json::Value RPCServer::doUnlList(Json::Value& params) { + return theApp->getUNL().getUnlJson(); +} + +Json::Value RPCServer::doUnlReset(Json::Value& params) { + return "not implemented"; } Json::Value RPCServer::doCommand(const std::string& command, Json::Value& params) { std::cerr << "RPC:" << command << std::endl; + if(command== "stop") { mSocket.get_io_service().stop(); return "newcoin server stopping"; } - if(command=="addUNL") return doAddUnl(params); - if(command=="getUNL") return doGetUnl(params); + + if(command=="unl_add") return doUnlAdd(params); + if(command=="unl_default") return doUnlDefault(params); + if(command=="unl_delete") return doUnlDelete(params); + if(command=="unl_fetch") return doUnlFetch(params); + if(command=="unl_list") return doUnlList(params); + if(command=="unl_reset") return doUnlReset(params); + if(command=="createfamily") return doCreateFamily(params); if(command=="familyinfo") return doFamilyInfo(params); if(command=="accountinfo") return doAccountInfo(params); diff --git a/src/RPCServer.h b/src/RPCServer.h index 93f19ced90..21cf90df39 100644 --- a/src/RPCServer.h +++ b/src/RPCServer.h @@ -45,8 +45,13 @@ class RPCServer : public boost::enable_shared_from_this Json::Value doTx(Json::Value& params); Json::Value doLedger(Json::Value& params); Json::Value doAccount(Json::Value& params); - Json::Value doAddUnl(Json::Value& params); - Json::Value doGetUnl(Json::Value& params); + + Json::Value doUnlAdd(Json::Value& params); + Json::Value doUnlDefault(Json::Value& params); + Json::Value doUnlDelete(Json::Value& params); + Json::Value doUnlFetch(Json::Value& params); + Json::Value doUnlList(Json::Value& params); + Json::Value doUnlReset(Json::Value& params); // Parses a string account name into a local or remote NewcoinAddress. NewcoinAddress parseAccount(const std::string& account); diff --git a/src/UniqueNodeList.cpp b/src/UniqueNodeList.cpp index 503488bb3f..7779fe522f 100644 --- a/src/UniqueNodeList.cpp +++ b/src/UniqueNodeList.cpp @@ -2,41 +2,42 @@ #include "Application.h" #include "Conversion.h" -void UniqueNodeList::addNode(NewcoinAddress address,std::string comment) +void UniqueNodeList::addNode(NewcoinAddress nodePublic, std::string strComment) { Database* db=theApp->getWalletDB()->getDB(); - // void UniqueNodeList::addNode(uint160& hanko, std::vector& publicKey,std::string comment) + std::string strHanko = nodePublic.humanHanko(); + std::string strPublicKey = nodePublic.humanNodePublic(); + std::string strTmp; - std::string hanko = address.humanHanko(); - std::string publicKey = address.humanNodePublic(); - - std::string sql="INSERT INTO TrustedNodes (Hanko,PubKey,Comment) values ("; - std::string tmpStr; - db->escape(reinterpret_cast(hanko.c_str()), hanko.size(), tmpStr); - sql.append(tmpStr); - sql.append(","); - db->escape(reinterpret_cast(publicKey.c_str()), publicKey.size(), tmpStr); - sql.append(tmpStr); - sql.append(","); - db->escape(reinterpret_cast(comment.c_str()), comment.size(), tmpStr); - sql.append(tmpStr); - sql.append(")"); + std::string strSql="INSERT INTO TrustedNodes (Hanko,PublicKey,Comment) values ("; + db->escape(reinterpret_cast(strHanko.c_str()), strHanko.size(), strTmp); + strSql.append(strTmp); + strSql.append(","); + db->escape(reinterpret_cast(strPublicKey.c_str()), strPublicKey.size(), strTmp); + strSql.append(strTmp); + strSql.append(","); + db->escape(reinterpret_cast(strComment.c_str()), strComment.size(), strTmp); + strSql.append(strTmp); + strSql.append(")"); ScopedLock sl(theApp->getWalletDB()->getDBLock()); - db->executeSQL(sql.c_str()); + db->executeSQL(strSql.c_str()); } -void UniqueNodeList::removeNode(uint160& hanko) +void UniqueNodeList::removeNode(NewcoinAddress hanko) { Database* db=theApp->getWalletDB()->getDB(); - std::string sql="DELETE FROM TrustedNodes where hanko="; - std::string hashStr; - db->escape(hanko.begin(), hanko.GetSerializeSize(), hashStr); - sql.append(hashStr); + + std::string strHanko = hanko.humanHanko(); + std::string strTmp; + + std::string strSql = "DELETE FROM TrustedNodes where Hanko="; + db->escape(reinterpret_cast(strHanko.c_str()), strHanko.size(), strTmp); + strSql.append(strTmp); ScopedLock sl(theApp->getWalletDB()->getDBLock()); - db->executeSQL(sql.c_str()); + db->executeSQL(strSql.c_str()); } // 0- we don't care, 1- we care and is valid, 2-invalid signature @@ -44,13 +45,13 @@ void UniqueNodeList::removeNode(uint160& hanko) int UniqueNodeList::checkValid(newcoin::Validation& valid) { Database* db=theApp->getWalletDB()->getDB(); - std::string sql="SELECT pubkey from TrustedNodes where hanko="; + std::string strSql="SELECT pubkey from TrustedNodes where hanko="; std::string hashStr; db->escape((unsigned char*) &(valid.hanko()[0]),valid.hanko().size(),hashStr); - sql.append(hashStr); + strSql.append(hashStr); ScopedLock sl(theApp->getWalletDB()->getDBLock()); - if( db->executeSQL(sql.c_str()) ) + if( db->executeSQL(strSql.c_str()) ) { if(db->startIterRows() && db->getNextRow()) { @@ -66,28 +67,41 @@ int UniqueNodeList::checkValid(newcoin::Validation& valid) } #endif -void UniqueNodeList::dumpUNL(std::string& retStr) +Json::Value UniqueNodeList::getUnlJson() { Database* db=theApp->getWalletDB()->getDB(); - std::string sql="SELECT * FROM TrustedNodes;"; + std::string strSql="SELECT * FROM TrustedNodes;"; - retStr.append("hello\n"); + Json::Value ret(Json::arrayValue); ScopedLock sl(theApp->getWalletDB()->getDBLock()); - if( db->executeSQL(sql.c_str()) ) + if( db->executeSQL(strSql.c_str()) ) { - db->startIterRows(); - while(db->getNextRow()) + bool more = db->startIterRows(); + while (more) { - uint160 hanko; - db->getBinary("Hanko", hanko.begin(), hanko.GetSerializeSize()); - std::string tstr; - u160ToHuman(hanko, tstr); + std::string strHanko; + std::string strPublicKey; + std::string strComment; - retStr.append(tstr); - retStr.append("\n"); + db->getStr("Hanko", strHanko); + db->getStr("PublicKey", strPublicKey); + db->getStr("Comment", strComment); + + Json::Value node(Json::objectValue); + + node["Hanko"] = strHanko; + node["PublicKey"] = strPublicKey; + node["Comment"] = strComment; + + ret.append(node); + + more = db->getNextRow(); } + db->endIterRows(); } -} + return ret; +} +// vim:ts=4 diff --git a/src/UniqueNodeList.h b/src/UniqueNodeList.h index 3341a0d2e0..d43f58133f 100644 --- a/src/UniqueNodeList.h +++ b/src/UniqueNodeList.h @@ -1,6 +1,8 @@ #ifndef __UNIQUE_NODE_LIST__ #define __UNIQUE_NODE_LIST__ -#include "../obj/src/newcoin.pb.h" + +#include "../json/value.h" + #include "uint256.h" #include "NewcoinAddress.h" @@ -12,13 +14,13 @@ public: //void load(); //void save(); - void addNode(NewcoinAddress address,std::string comment); - void removeNode(uint160& hanko); + void addNode(NewcoinAddress nodePublic, std::string strComment); + void removeNode(NewcoinAddress hanko); // 0- we don't care, 1- we care and is valid, 2-invalid signature // int checkValid(newcoin::Validation& valid); - void dumpUNL(std::string& retStr); + Json::Value getUnlJson(); }; #endif diff --git a/src/Wallet.cpp b/src/Wallet.cpp index f2f9d2f504..60693009e9 100644 --- a/src/Wallet.cpp +++ b/src/Wallet.cpp @@ -2,7 +2,6 @@ #include -#include "openssl/rand.h" #include "openssl/ec.h" #include "boost/foreach.hpp" @@ -10,7 +9,6 @@ #include "boost/interprocess/sync/scoped_lock.hpp" #include "boost/make_shared.hpp" - #include "Wallet.h" #include "Ledger.h" #include "NewcoinAddress.h" @@ -29,17 +27,64 @@ LocalAccount::LocalAccount(boost::shared_ptr family, int fam mPublicKey(family->getPublicKey(familySeq)), mFamily(family), mAccountFSeq(familySeq), mLgrBalance(0), mTxnDelta(0), mTxnSeq(0) { - mAcctID=mPublicKey->GetAddress(); + mAcctID.setAccountPublic(mPublicKey->GetPubKey()); if(theApp!=NULL) mPublicKey=theApp->getPubKeyCache().store(mAcctID, mPublicKey); } +std::string LocalAccount::getFullName() const +{ + std::string ret(mFamily->getFamily().humanFamilyGenerator()); + ret.append(":"); + ret.append(boost::lexical_cast(mAccountFSeq)); + + return ret; +} + +bool LocalAccount::isLocked() const +{ + return mFamily->isLocked(); +} + +std::string LocalAccount::getFamilyName() const +{ + return mFamily->getFamily().humanFamilyGenerator(); +} + +Json::Value LocalAccount::getJson() const +{ + Json::Value ret(Json::objectValue); + ret["Family"]=getFamilyName(); + ret["AccountID"]=getAddress().humanAccountID(); + ret["AccountPublic"]=getAddress().humanAccountPublic(); + ret["FullName"]=getFullName(); + ret["Issued"]=Json::Value(isIssued()); + ret["IsLocked"]=mFamily->isLocked(); + + uint64 eb=getEffectiveBalance(); + if(eb!=0) ret["Balance"]=boost::lexical_cast(eb); + + uint32 sq=getTxnSeq(); + if(sq!=0) ret["TxnSeq"]=boost::lexical_cast(sq); + + return ret; +} + +bool LocalAccount::isIssued() const +{ + return mAccountFSeq < mFamily->getSeq(); +} + +CKey::pointer LocalAccount::getPrivateKey() +{ + return mFamily->getPrivateKey(mAccountFSeq); +} // // LocalAccountFamily - a sequences of accounts // -LocalAccountFamily::LocalAccountFamily(const NewcoinAddress& family) : - mFamily(family), mLastSeq(0), mRootPrivateKey(NULL) +LocalAccountFamily::LocalAccountFamily(const NewcoinAddress& familyGenerator) : + mFamily(familyGenerator), mLastSeq(0), mRootPrivateKey(NULL) { } @@ -209,11 +254,7 @@ NewcoinAddress Wallet::addFamily(const NewcoinAddress& familySeed, bool lock) // Create a family. Return the family public generator and the seed. NewcoinAddress Wallet::addRandomFamily(NewcoinAddress& familySeed) { - uint128 key; - - RAND_bytes((unsigned char *) &key, sizeof(key)); - - familySeed.setFamilySeed(key); + familySeed.setFamilySeedRandom(); return addFamily(familySeed, false); } @@ -241,54 +282,6 @@ NewcoinAddress Wallet::findFamilyPK(const NewcoinAddress& familyGenerator) return fam ? fam->getFamily() : NewcoinAddress(); } -std::string LocalAccount::getFullName() const -{ - std::string ret(mFamily->getFamily().humanFamilyGenerator()); - ret.append(":"); - ret.append(boost::lexical_cast(mAccountFSeq)); - - return ret; -} - -bool LocalAccount::isLocked() const -{ - return mFamily->isLocked(); -} - -std::string LocalAccount::getFamilyName() const -{ - return mFamily->getFamily().humanFamilyGenerator(); -} - -Json::Value LocalAccount::getJson() const -{ - Json::Value ret(Json::objectValue); - ret["Family"]=getFamilyName(); - ret["AccountID"]=getAddress().humanAccountID(); - ret["AccountPublic"]=getAddress().humanAccountPublic(); - ret["FullName"]=getFullName(); - ret["Issued"]=Json::Value(isIssued()); - ret["IsLocked"]=mFamily->isLocked(); - - uint64 eb=getEffectiveBalance(); - if(eb!=0) ret["Balance"]=boost::lexical_cast(eb); - - uint32 sq=getTxnSeq(); - if(sq!=0) ret["TxnSeq"]=boost::lexical_cast(sq); - - return ret; -} - -bool LocalAccount::isIssued() const -{ - return mAccountFSeq < mFamily->getSeq(); -} - -CKey::pointer LocalAccount::getPrivateKey() -{ - return mFamily->getPrivateKey(mAccountFSeq); -} - void Wallet::getFamilies(std::vector& familyIDs) { boost::recursive_mutex::scoped_lock sl(mLock); @@ -337,8 +330,89 @@ Json::Value Wallet::getFamilyJson(const NewcoinAddress& family) return fit->second->getJson(); } +bool Wallet::nodeIdentityLoad() +{ + std::string strSql("SELECT * FROM NodeIdentity;"); + + ScopedLock sl(theApp->getWalletDB()->getDBLock()); + Database *db=theApp->getWalletDB()->getDB(); + + if(!db->executeSQL(strSql.c_str())) return false; + if(!db->startIterRows()) return false; + + std::string strPublicKey, strPrivateKey; + + db->getStr("PublicKey", strPublicKey); + db->getStr("PrivateKey", strPrivateKey); + + mNodePublicKey.setNodePublic(strPublicKey); + mNodePrivateKey.setNodePrivate(strPrivateKey); + + db->endIterRows(); + + // Derive hanko from public key. + mNodeHanko.setHanko(mNodePublicKey); + + return true; +} + +bool Wallet::nodeIdentityCreate() { + // + // Generate the public and private key + // + NewcoinAddress familySeed; + NewcoinAddress familyGenerator; + NewcoinAddress nodePublicKey; + NewcoinAddress nodePrivateKey; + + familySeed.setFamilySeedRandom(); // Get a random seed. + familyGenerator.setFamilyGenerator(familySeed); // Derive generator from seed. + + // The node public and private is 0th of the sequence. + nodePublicKey.setNodePublic(CKey(familyGenerator, 0).GetPubKey()); + nodePrivateKey.setNodePrivate(CKey(familyGenerator, familySeed.getFamilyPrivateKey(), 0).GetSecret()); + + std::cerr << "New NodeIdentity:" << std::endl; + fprintf(stderr, "public: %s\n", nodePublicKey.humanNodePublic().c_str()); + fprintf(stderr, "private: %s\n", nodePrivateKey.humanNodePrivate().c_str()); + + // + // Store the node information + // + Database* db = theApp->getWalletDB()->getDB(); + + std::string strTmp; + + std::string strPublicKey = nodePublicKey.humanNodePublic(); + std::string strPrivateKey = nodePrivateKey.humanNodePrivate(); + + std::string strSql = "INSERT INTO NodeIdentity (PublicKey,PrivateKey) VALUES ("; + db->escape(reinterpret_cast(strPublicKey.c_str()), strPublicKey.size(), strTmp); + strSql.append(strTmp); + strSql.append(","); + db->escape(reinterpret_cast(strPrivateKey.c_str()), strPrivateKey.size(), strTmp); + strSql.append(strTmp); + strSql.append(");"); + + ScopedLock sl(theApp->getWalletDB()->getDBLock()); + db->executeSQL(strSql.c_str()); + + return true; +} + void Wallet::load() { + if (!nodeIdentityLoad()) { + nodeIdentityCreate(); + if (!nodeIdentityLoad()) + throw std::runtime_error("unable to retrieve new node identity."); + } + + std::cerr << "NodeIdentity:" << std::endl; + fprintf(stderr, "hanko: %s\n", mNodeHanko.humanHanko().c_str()); + fprintf(stderr, "public: %s\n", mNodePublicKey.humanNodePublic().c_str()); + fprintf(stderr, "private: %s\n", mNodePrivateKey.humanNodePrivate().c_str()); + std::string sql("SELECT * FROM LocalAcctFamilies;"); ScopedLock sl(theApp->getWalletDB()->getDBLock()); @@ -350,24 +424,27 @@ void Wallet::load() #endif return; } + if(!db->startIterRows()) return; + while(db->getNextRow()) { - std::string generator, comment; - db->getStr("FamilyGenerator", generator); - db->getStr("Comment", comment); + std::string strGenerator, strComment; + + db->getStr("FamilyGenerator", strGenerator); + db->getStr("Comment", strComment); int seq=db->getBigInt("Seq"); NewcoinAddress familyGenerator; - familyGenerator.setFamilyGenerator(generator); + familyGenerator.setFamilyGenerator(strGenerator); LocalAccountFamily::pointer f(doPublic(familyGenerator, true, false)); if(f) { assert(f->getFamily().getFamilyGenerator()==familyGenerator.getFamilyGenerator()); f->setSeq(seq); - f->setComment(comment); + f->setComment(strComment); } else assert(false); } @@ -503,6 +580,7 @@ void Wallet::delFamily(const NewcoinAddress& familyName) mFamilies.erase(familyName); } +// Look for and possible create a family based on its generator. // --> pubKey: hex // --> do_create: Add to mFamilies // --> do_db: write out db @@ -537,25 +615,26 @@ LocalAccountFamily::pointer Wallet::doPublic(const NewcoinAddress& familyGenerat return fam; } +// Look for and possible create a family based on its seed. LocalAccountFamily::pointer Wallet::doPrivate(const NewcoinAddress& familySeed, bool do_create, bool do_unlock) { - NewcoinAddress family; - family.setFamilyGenerator(familySeed); + NewcoinAddress familyGenerator; + familyGenerator.setFamilyGenerator(familySeed); boost::recursive_mutex::scoped_lock sl(mLock); LocalAccountFamily::pointer fam; - std::map::iterator it=mFamilies.find(family); + std::map::iterator it=mFamilies.find(familyGenerator); if(it==mFamilies.end()) { // family not found - fam=LocalAccountFamily::readFamily(family); + fam=LocalAccountFamily::readFamily(familyGenerator); if(!fam) { if(!do_create) { return LocalAccountFamily::pointer(); } - fam=boost::make_shared(family); - mFamilies.insert(std::make_pair(family, fam)); + fam=boost::make_shared(familyGenerator); + mFamilies.insert(std::make_pair(familyGenerator, fam)); fam->write(true); } } diff --git a/src/Wallet.h b/src/Wallet.h index b2f70878bf..51b1d7fa8a 100644 --- a/src/Wallet.h +++ b/src/Wallet.h @@ -21,9 +21,17 @@ class Ledger; class Wallet { +private: + bool nodeIdentityLoad(); + bool nodeIdentityCreate(); + protected: boost::recursive_mutex mLock; + NewcoinAddress mNodeHanko; + NewcoinAddress mNodePublicKey; + NewcoinAddress mNodePrivateKey; + std::map mFamilies; std::map mAccounts; std::map mTransactions; diff --git a/src/key.h b/src/key.h index af608d9536..7eb4d0aeae 100644 --- a/src/key.h +++ b/src/key.h @@ -273,15 +273,6 @@ public: return false; return true; } - - NewcoinAddress GetAddress() const - { - NewcoinAddress* ret = new NewcoinAddress(); - - ret->setAccountPublic(GetPubKey()); - - return *ret; - } }; #endif