Replace the use of hanko with public keys.

This commit is contained in:
Arthur Britto
2012-04-05 16:42:21 -07:00
parent 31f4b5335c
commit af800ffe14
7 changed files with 14 additions and 27 deletions

View File

@@ -60,8 +60,7 @@ const char *WalletDBInit[] = {
PrivateKey CHARACTER(52) \
);",
"CREATE TABLE TrustedNodes ( \
Hanko CHARACTER(35) PRIMARY KEY, \
PublicKey CHARACTER(53), \
PublicKey CHARACTER(53) PRIMARY KEY, \
Comment TEXT \
);"
};

View File

@@ -592,23 +592,23 @@ Json::Value RPCServer::doUnlDefault(Json::Value& params) {
else return "invalid params";
}
// unl_delete <hanko>
// unl_delete <public_key>
Json::Value RPCServer::doUnlDelete(Json::Value& params) {
if(params.size()==1)
{
std::string strHanko=params[0u].asString();
std::string strNodePublic=params[0u].asString();
NewcoinAddress hanko;
NewcoinAddress naNodePublic;
if(hanko.setHanko(strHanko))
if(naNodePublic.setNodePublic(strNodePublic))
{
theApp->getUNL().nodeRemove(hanko);
theApp->getUNL().nodeRemove(naNodePublic);
return "removing node";
}
else
{
return "invalid hanko";
return "invalid public key";
}
}
else return "invalid params";

View File

@@ -276,14 +276,10 @@ void UniqueNodeList::nodeAdd(NewcoinAddress naNodePublic, std::string strComment
{
Database* db=theApp->getWalletDB()->getDB();
std::string strHanko = naNodePublic.humanHanko();
std::string strPublicKey = naNodePublic.humanNodePublic();
std::string strTmp;
std::string strSql="INSERT INTO TrustedNodes (Hanko,PublicKey,Comment) values (";
db->escape(reinterpret_cast<const unsigned char*>(strHanko.c_str()), strHanko.size(), strTmp);
strSql.append(strTmp);
strSql.append(",");
std::string strSql="INSERT INTO TrustedNodes (PublicKey,Comment) values (";
db->escape(reinterpret_cast<const unsigned char*>(strPublicKey.c_str()), strPublicKey.size(), strTmp);
strSql.append(strTmp);
strSql.append(",");
@@ -295,15 +291,15 @@ void UniqueNodeList::nodeAdd(NewcoinAddress naNodePublic, std::string strComment
db->executeSQL(strSql.c_str());
}
void UniqueNodeList::nodeRemove(NewcoinAddress naHanko)
void UniqueNodeList::nodeRemove(NewcoinAddress naNodePublic)
{
Database* db=theApp->getWalletDB()->getDB();
std::string strHanko = naHanko.humanHanko();
std::string strPublic = naNodePublic.humanNodePublic();
std::string strTmp;
std::string strSql = "DELETE FROM TrustedNodes where Hanko=";
db->escape(reinterpret_cast<const unsigned char*>(strHanko.c_str()), strHanko.size(), strTmp);
std::string strSql = "DELETE FROM TrustedNodes where PublicKey=";
db->escape(reinterpret_cast<const unsigned char*>(strPublic.c_str()), strPublic.size(), strTmp);
strSql.append(strTmp);
ScopedLock sl(theApp->getWalletDB()->getDBLock());
@@ -359,17 +355,14 @@ Json::Value UniqueNodeList::getUnlJson()
bool more = db->startIterRows();
while (more)
{
std::string strHanko;
std::string strPublicKey;
std::string strComment;
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;

View File

@@ -50,7 +50,7 @@ public:
void nodeAdd(NewcoinAddress naNodePublic, std::string strComment);
void nodeFetch(std::string strDomain);
void nodeRemove(NewcoinAddress naHanko);
void nodeRemove(NewcoinAddress naNodePublic);
void nodeDefault(std::string strValidators);
void nodeReset();

View File

@@ -350,9 +350,6 @@ bool Wallet::nodeIdentityLoad()
db->endIterRows();
// Derive hanko from public key.
mNodeHanko.setHanko(mNodePublicKey);
return true;
}
@@ -409,7 +406,6 @@ void Wallet::load()
}
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());

View File

@@ -28,7 +28,6 @@ private:
protected:
boost::recursive_mutex mLock;
NewcoinAddress mNodeHanko;
NewcoinAddress mNodePublicKey;
NewcoinAddress mNodePrivateKey;

View File

@@ -37,7 +37,7 @@ void printHelp()
cout << " stop" << endl;
cout << " tx" << endl;
cout << " unl_add <public> [<comment>]" << endl;
cout << " unl_delete <hanko>" << endl;
cout << " unl_delete <public_key>" << endl;
cout << " unl_list" << endl;
cout << " unl_reset" << endl;
cout << " unlock <passphrase>" << endl;