Skip to content
Permalink
Browse files

adding hash through config and rpc commands now possible.

  • Loading branch information...
craigmacgregor committed Nov 23, 2016
1 parent a24d800 commit 4e2ce48a2700d8d2fc2d9d73c603443671096e73
Showing with 81 additions and 12 deletions.
  1. +1 −0 src/init.cpp
  2. +3 −0 src/net.cpp
  3. +3 −0 src/net.h
  4. +15 −1 src/qt/sendcoinsdialog.cpp
  5. +1 −0 src/rpcclient.cpp
  6. +53 −11 src/rpcnet.cpp
  7. +2 −0 src/rpcserver.cpp
  8. +3 −0 src/rpcserver.h
@@ -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";
@@ -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;

@@ -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;

@@ -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;
}
@@ -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;

@@ -105,6 +105,7 @@ static const CRPCConvertParam vRPCConvertParams[] =
{
{ "stop", 0 },
{ "getaddednodeinfo", 0 },
{ "getaddedanonhashinfo", 0 },
{ "getaddedserverinfo", 0 },
{ "sendtoaddress", 1 },
{ "settxfee", 0 },
@@ -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++)
@@ -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)
@@ -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 },
@@ -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);

0 comments on commit 4e2ce48

Please sign in to comment.
You can’t perform that action at this time.