Skip to content

Commit

Permalink
adding hash through config and rpc commands now possible.
Browse files Browse the repository at this point in the history
  • Loading branch information
proletesseract committed Nov 23, 2016
1 parent a24d800 commit 4e2ce48
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 12 deletions.
1 change: 1 addition & 0 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ std::string HelpMessage()
strUsage += " -maxconnections=<n> " + _("Maintain at most <n> connections to peers (default: 125)") + "\n";
strUsage += " -addnode=<ip> " + _("Add a node to connect to and attempt to keep the connection open") + "\n";
strUsage += " -addanonserver=<ip> " + _("Add an anon node to use for sending anon transactions to") + "\n";
strUsage += " -anonhash=<ip> " + _("Add the md5 hash of your chosen anon server") + "\n";
strUsage += " -connect=<ip> " + _("Connect only to the specified node(s)") + "\n";
strUsage += " -seednode=<ip> " + _("Connect to a node to retrieve peer addresses, and disconnect") + "\n";
strUsage += " -externalip=<ip> " + _("Specify your own public address") + "\n";
Expand Down
3 changes: 3 additions & 0 deletions src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ CCriticalSection cs_vAddedNodes;
vector<std::string> vAddedAnonServers;
CCriticalSection cs_vAddedAnonServers;

vector<std::string> vAddedAnonHashes;
CCriticalSection cs_vAddedAnonHashes;

NodeId nLastNodeId = 0;
CCriticalSection cs_nLastNodeId;

Expand Down
3 changes: 3 additions & 0 deletions src/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ extern CCriticalSection cs_vAddedNodes;
extern std::vector<std::string> vAddedAnonServers;
extern CCriticalSection cs_vAddedAnonServers;

extern std::vector<std::string> vAddedAnonHashes;
extern CCriticalSection cs_vAddedAnonHashes;

extern NodeId nLastNodeId;
extern CCriticalSection cs_nLastNodeId;

Expand Down
16 changes: 15 additions & 1 deletion src/qt/sendcoinsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ std::vector<anonServer> SendCoinsDialog::getAnonServers() {

if (vAddedAnonServers.size() < 1 && mapMultiArgs["-addanonserver"].size() < 1) {
QMessageBox::warning(this, tr("Anonymous Transaction"),
tr("You must have at least one anonymouns server added to your conf file or by rpc command"),
tr("You must have at least one anonymous server added to your conf file or by rpc command"),
QMessageBox::Ok, QMessageBox::Ok);
return returnServers;
}
Expand Down Expand Up @@ -418,6 +418,20 @@ QJsonObject SendCoinsDialog::testEncrypted(QString server, int port, QString enc
void SendCoinsDialog::on_sendButton_clicked()
{

// if (mapMultiArgs["-anonhash"].size() > 0) {
// cout << "-anonhash " << mapMultiArgs["-anonhash"][0] << endl;
// cout << "-anonhash " << mapMultiArgs["-anonhash"][1] << endl;
// cout << "-anonhash " << mapMultiArgs["-anonhash"][2] << endl;
// } else {
// cout << " no -anonhash " << endl;
// }

// if (vAddedAnonHashes.size() > 0) {
// cout << "-vAddedAnonHashes " << vAddedAnonHashes[0] << endl;
// } else {
// cout << "no -vAddedAnonHashes " << endl;
// }

if(!model || !model->getOptionsModel())
return;

Expand Down
1 change: 1 addition & 0 deletions src/rpcclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ static const CRPCConvertParam vRPCConvertParams[] =
{
{ "stop", 0 },
{ "getaddednodeinfo", 0 },
{ "getaddedanonhashinfo", 0 },
{ "getaddedserverinfo", 0 },
{ "sendtoaddress", 1 },
{ "settxfee", 0 },
Expand Down
64 changes: 53 additions & 11 deletions src/rpcnet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,18 +157,11 @@ Value addanonserver(const Array& params, bool fHelp)
if (fHelp || params.size() != 2 ||
(strCommand != "onetry" && strCommand != "add" && strCommand != "remove"))
throw runtime_error(
"addanonserver <anonserver> <add|remove|onetry>\n"
"Attempts add or remove <anonserver> from the addanonserver list or try a connection to <node> once.");
"addanonserver <anonserver> <add|remove>\n"
"Attempts add or remove <anonserver> from the addanonserver list.");

string strNode = params[0].get_str();

if (strCommand == "onetry")
{
CAddress addr;
ConnectNode(addr, strNode.c_str());
return Value::null;
}

LOCK(cs_vAddedAnonServers);
vector<string>::iterator it = vAddedAnonServers.begin();
for(; it != vAddedAnonServers.end(); it++)
Expand All @@ -178,19 +171,68 @@ Value addanonserver(const Array& params, bool fHelp)
if (strCommand == "add")
{
if (it != vAddedAnonServers.end())
throw JSONRPCError(RPC_CLIENT_NODE_ALREADY_ADDED, "Error: Node already added");
throw JSONRPCError(RPC_CLIENT_NODE_ALREADY_ADDED, "Error: Anon server already added");
vAddedAnonServers.push_back(strNode);
}
else if(strCommand == "remove")
{
if (it == vAddedAnonServers.end())
throw JSONRPCError(RPC_CLIENT_NODE_NOT_ADDED, "Error: Node has not been added.");
throw JSONRPCError(RPC_CLIENT_NODE_NOT_ADDED, "Error: Anon server has not been added.");
vAddedAnonServers.erase(it);
}

return Value::null;
}

Value anonhash(const Array& params, bool fHelp)
{
string strCommand;
if (params.size() == 2)
strCommand = params[1].get_str();
if (fHelp || params.size() != 2 ||
(strCommand != "onetry" && strCommand != "add" && strCommand != "remove"))
throw runtime_error(
"anonhash <anonhash> <add|remove>\n"
"Attempts add or remove <anonhash> from the accepted hashes list.");

string strNode = params[0].get_str();


LOCK(cs_vAddedAnonHashes);
vector<string>::iterator it = vAddedAnonHashes.begin();
for(; it != vAddedAnonHashes.end(); it++)
if (strNode == *it)
break;

if (strCommand == "add")
{
if (it != vAddedAnonHashes.end())
throw JSONRPCError(RPC_CLIENT_NODE_ALREADY_ADDED, "Error: Hash already added");
vAddedAnonHashes.push_back(strNode);
}
else if(strCommand == "remove")
{
if (it == vAddedAnonHashes.end())
throw JSONRPCError(RPC_CLIENT_NODE_NOT_ADDED, "Error: Hash has not been added.");
vAddedAnonHashes.erase(it);
}

return Value::null;
}

Value getaddedanonhashinfo(bool fHelp)
{

Array ret;

LOCK(cs_vAddedAnonHashes);
BOOST_FOREACH(string& strAddNode, vAddedAnonHashes)
ret.push_back(strAddNode);

return ret;

}

Value getaddedanonserverinfo(const Array& params, bool fHelp)
{
if (fHelp || params.size() < 1 || params.size() > 2)
Expand Down
2 changes: 2 additions & 0 deletions src/rpcserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ static const CRPCCommand vRPCCommands[] =
{ "getaddednodeinfo", &getaddednodeinfo, true, true, false },
{ "addanonserver", &addanonserver, true, true, false },
{ "getaddedanonserverinfo", &getaddedanonserverinfo, true, true, false },
{ "getaddedanonhashinfo", &getaddedanonhashinfo, true, true, false },
{ "anonhash", &anonhash, true, true, false },
{ "ping", &ping, true, false, false },
{ "getnettotals", &getnettotals, true, true, false },
{ "getdifficulty", &getdifficulty, true, false, false },
Expand Down
3 changes: 3 additions & 0 deletions src/rpcserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,11 @@ extern json_spirit::Value getpeerinfo(const json_spirit::Array& params, bool fHe
extern json_spirit::Value ping(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value addnode(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value addanonserver(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value anonhash(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value getaddednodeinfo(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value getaddedanonserverinfo(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value getaddedanonhashinfo(bool fHelp);

extern json_spirit::Value getnettotals(const json_spirit::Array& params, bool fHelp);

extern json_spirit::Value addincoming(const json_spirit::Array& params, bool fHelp);
Expand Down

0 comments on commit 4e2ce48

Please sign in to comment.