diff --git a/src/AccountState.cpp b/src/AccountState.cpp index e4a6ddbff0..166ab530f3 100644 --- a/src/AccountState.cpp +++ b/src/AccountState.cpp @@ -32,8 +32,7 @@ void AccountState::addJson(Json::Value& val) { Json::Value as(Json::objectValue); - // XXX Might want account public here, if available. - as["Account"]=mAccountID.humanAccountID(); + as["AccountID"]=mAccountID.humanAccountID(); as["Balance"]=boost::lexical_cast(mBalance); as["SendSequence"]=mAccountSeq; if(!mValid) as["Invalid"]=true; diff --git a/src/DBInit.cpp b/src/DBInit.cpp index 6eff69b219..49f36c2303 100644 --- a/src/DBInit.cpp +++ b/src/DBInit.cpp @@ -4,11 +4,11 @@ const char *TxnDBInit[] = { "CREATE TABLE Transactions ( \ TransID CHARACTER(64) PRIMARY KEY, \ - FromAcct CHARACTER(40), \ + FromAcct CHARACTER(35), \ FromSeq BIGINT UNSIGNED, \ FromLedger BIGINT UNSIGNED, \ Identifier BIGINT UNSIGNED, \ - ToAcct CHARACTER(40), \ + ToAcct CHARACTER(35), \ Amount BIGINT UNSIGNED, \ Fee BIGINT UNSIGNED, \ FirstSeen TEXT, \ @@ -17,7 +17,7 @@ const char *TxnDBInit[] = { Signature BLOB \ );", "CREATE TABLE PubKeys ( \ - ID CHARACTER(40) PRIMARY KEY, \ + ID CHARACTER(35) PRIMARY KEY, \ PubKey BLOB \ );" }; @@ -35,14 +35,17 @@ const char *LedgerDBInit[] = { TransSetHash CHARACTER(64) \ );", "CREATE INDEX SeqLedger ON Ledgers(LedgerSeq);", +#if 0 "CREATE TABLE LedgerConfirmations ( \ LedgerSeq BIGINT UNSIGNED, \ LedgerHash CHARACTER(64), \ - Hanko CHARACTER(40), \ + Hanko CHARACTER(35), \ Signature BLOB \ );", "CREATE INDEX LedgerConfByHash ON \ - LedgerConfirmations(LedgerHash)l" }; + LedgerConfirmations(LedgerHash)" +#endif + }; int LedgerDBCount=sizeof(LedgerDBInit)/sizeof(const char *); @@ -53,22 +56,22 @@ const char *WalletDBInit[] = { Seq BIGINT UNSIGNED, \ Comment TEXT \ );", + "CREATE TABLE TrustedNodes ( \ + Hanko CHARACTER(35) PRIMARY KEY, \ + PubKey CHARACTER(53), \ + Comment TEXT \ + );" }; + +#if 0 "CREATE TABLE LocalAccounts ( \ - ID CHARACTER(40) PRIMARY KEY, \ - KeyType CHARACTER(1), \ + ID CHARACTER(35) PRIMARY KEY, \ PrivateKey TEXT \ Seq BIGINT UNSIGNED, \ Balance BIGINT UNSIGNED, \ LedgerSeq BIGINT UNSIGNED, \ Comment TEXT \ );", - "CREATE TABLE TrustedNodes ( \ - Hanko CHARACTER(40) PRIMARY KEY, \ - PubKey CHARACTER(66), \ - Comment TEXT \ - );" }; - -// TrustLevel SMALLINT, +#endif int WalletDBCount=sizeof(WalletDBInit)/sizeof(const char *); @@ -89,11 +92,12 @@ int HashNodeDBCount=sizeof(HashNodeDBInit)/sizeof(const char *); // Net node database holds nodes seen on the network const char *NetNodeDBInit[] = { "CREATE TABLE KnownNodes ( \ - Hanko CHARACTER(40) PRIMARY KEY, \ + Hanko CHARACTER(35) PRIMARY KEY, \ LastSeen TEXT, \ HaveContactInfo CHARACTER(1), \ ContactObject BLOB \ - );" }; + );" + }; int NetNodeDBCount=sizeof(NetNodeDBInit)/sizeof(const char *); diff --git a/src/PubKeyCache.cpp b/src/PubKeyCache.cpp index cc97bbbd8c..47ed41dc73 100644 --- a/src/PubKeyCache.cpp +++ b/src/PubKeyCache.cpp @@ -35,7 +35,7 @@ CKey::pointer PubKeyCache::locate(const NewcoinAddress& id) assert(false); // bad data in DB return CKey::pointer(); } - + if(1) { // put it in cache (okay if we race with another retriever) boost::mutex::scoped_lock sl(mLock); @@ -53,15 +53,17 @@ CKey::pointer PubKeyCache::store(const NewcoinAddress& id, CKey::pointer key) if(!pit.second) // there was an existing key return pit.first->second; } - std::string sql="INSERT INTO PubKeys (ID,PubKey) VALUES ('"; - sql+=id.humanAccountID(); - sql+="',"; std::vector pk=key->GetPubKey(); std::string encodedPK; theApp->getTxnDB()->getDB()->escape(&(pk.front()), pk.size(), encodedPK); + + std::string sql="INSERT INTO PubKeys (ID,PubKey) VALUES ('"; + sql+=id.humanAccountID(); + sql+="',"; sql+=encodedPK; sql.append(");"); + ScopedLock dbl(theApp->getTxnDB()->getDBLock()); theApp->getTxnDB()->getDB()->executeSQL(sql.c_str(), true); return key; diff --git a/src/Wallet.cpp b/src/Wallet.cpp index 60bfd65e6d..f2f9d2f504 100644 --- a/src/Wallet.cpp +++ b/src/Wallet.cpp @@ -154,15 +154,6 @@ void LocalAccountFamily::write(bool is_new) sql.append(mFamily.humanFamilyGenerator()); sql.append("','"); - // EC_GROUP* grp=EC_GROUP_new_by_curve_name(NID_secp256k1); - // if(!grp) return; - // char *rpk=EC_POINT_point2hex(grp, mRootPubKey, POINT_CONVERSION_COMPRESSED, NULL); - // EC_GROUP_free(grp); - // if(!rpk) return; - // sql.append(rpk); - // OPENSSL_free(rpk); - // sql.append("','"); - sql.append(boost::lexical_cast(mLastSeq)); sql.append("',"); @@ -374,7 +365,6 @@ void Wallet::load() LocalAccountFamily::pointer f(doPublic(familyGenerator, true, false)); if(f) { - // XXX Compare could be better. assert(f->getFamily().getFamilyGenerator()==familyGenerator.getFamilyGenerator()); f->setSeq(seq); f->setComment(comment);