diff --git a/bitcoin-qt.pro b/bitcoin-qt.pro index 59210619b2..2dcfd48ef6 100644 --- a/bitcoin-qt.pro +++ b/bitcoin-qt.pro @@ -281,6 +281,7 @@ SOURCES += src/qt/bitcoin.cpp \ src/qt/walletstack.cpp \ src/qt/walletframe.cpp \ src/bitcoinrpc.cpp \ + src/rpcdarksend.cpp \ src/rpcdump.cpp \ src/rpcnet.cpp \ src/rpcmining.cpp \ diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp index c663f1fcac..d1b8bf9bc4 100644 --- a/src/bitcoinrpc.cpp +++ b/src/bitcoinrpc.cpp @@ -206,6 +206,9 @@ static const CRPCCommand vRPCCommands[] = { "getpeerinfo", &getpeerinfo, true, false, false }, { "addnode", &addnode, true, true, false }, { "darksendsub", &darksendsub, true, true, false }, + { "getpoolinfo", &getpoolinfo, true, false, false }, + { "darksend", &darksend, false, false, true }, + { "masternode", &masternode, false, false, true }, { "getaddednodeinfo", &getaddednodeinfo, true, true, false }, { "getdifficulty", &getdifficulty, true, false, false }, { "getnetworkhashps", &getnetworkhashps, true, false, false }, @@ -214,14 +217,12 @@ static const CRPCCommand vRPCCommands[] = { "gethashespersec", &gethashespersec, true, false, false }, { "getinfo", &getinfo, true, false, false }, { "getmininginfo", &getmininginfo, true, false, false }, - { "getpoolinfo", &getpoolinfo, true, false, false }, { "getnewaddress", &getnewaddress, true, false, true }, { "getaccountaddress", &getaccountaddress, true, false, true }, { "setaccount", &setaccount, true, false, true }, { "getaccount", &getaccount, false, false, true }, { "getaddressesbyaccount", &getaddressesbyaccount, true, false, true }, { "sendtoaddress", &sendtoaddress, false, false, true }, - { "darksend", &darksend, false, false, true }, { "getreceivedbyaddress", &getreceivedbyaddress, false, false, true }, { "getreceivedbyaccount", &getreceivedbyaccount, false, false, true }, { "listreceivedbyaddress", &listreceivedbyaddress, false, false, true }, diff --git a/src/bitcoinrpc.h b/src/bitcoinrpc.h index d0161970e3..d6fe5d75e7 100644 --- a/src/bitcoinrpc.h +++ b/src/bitcoinrpc.h @@ -136,10 +136,14 @@ extern std::string HexBits(unsigned int nBits); extern std::string HelpRequiringPassphrase(); extern void EnsureWalletIsUnlocked(); +extern json_spirit::Value darksendsub(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value getpoolinfo(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value darksend(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value masternode(const json_spirit::Array& params, bool fHelp); + extern json_spirit::Value getconnectioncount(const json_spirit::Array& params, bool fHelp); // in rpcnet.cpp extern json_spirit::Value getpeerinfo(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value addnode(const json_spirit::Array& params, bool fHelp); -extern json_spirit::Value darksendsub(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value getaddednodeinfo(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value dumpprivkey(const json_spirit::Array& params, bool fHelp); // in rpcdump.cpp extern json_spirit::Value importprivkey(const json_spirit::Array& params, bool fHelp); @@ -149,8 +153,6 @@ extern json_spirit::Value setgenerate(const json_spirit::Array& params, bool fHe extern json_spirit::Value getnetworkhashps(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value gethashespersec(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value getmininginfo(const json_spirit::Array& params, bool fHelp); -extern json_spirit::Value getpoolinfo(const json_spirit::Array& params, bool fHelp); -extern json_spirit::Value resetpool(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value getworkex(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value getwork(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value getblocktemplate(const json_spirit::Array& params, bool fHelp); @@ -162,8 +164,6 @@ extern json_spirit::Value setaccount(const json_spirit::Array& params, bool fHel extern json_spirit::Value getaccount(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value getaddressesbyaccount(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value sendtoaddress(const json_spirit::Array& params, bool fHelp); -extern json_spirit::Value darksend(const json_spirit::Array& params, bool fHelp); -extern json_spirit::Value denominate(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value signmessage(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value verifymessage(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value getreceivedbyaddress(const json_spirit::Array& params, bool fHelp); diff --git a/src/main.cpp b/src/main.cpp index e7eae7ebd4..a3fe8e8c1f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -6064,6 +6064,8 @@ bool CDarkSendPool::GetLastValidBlockHash(uint256& hash) void CDarkSendPool::NewBlock() { + if(myEntries.size() == 0) return; + printf("CDarkSendPool::NewBlock \n"); uint256 n1 = 0; diff --git a/src/makefile.linux-mingw b/src/makefile.linux-mingw index fa50f44495..3c71d5920d 100644 --- a/src/makefile.linux-mingw +++ b/src/makefile.linux-mingw @@ -72,6 +72,7 @@ OBJS= \ obj/net.o \ obj/protocol.o \ obj/bitcoinrpc.o \ + obj/rpcdarksend.o \ obj/rpcdump.o \ obj/rpcnet.o \ obj/rpcmining.o \ diff --git a/src/makefile.mingw b/src/makefile.mingw index aa3471f748..1288a09e14 100644 --- a/src/makefile.mingw +++ b/src/makefile.mingw @@ -84,6 +84,7 @@ OBJS= \ obj/net.o \ obj/protocol.o \ obj/bitcoinrpc.o \ + obj/rpcdarksend.o \ obj/rpcdump.o \ obj/rpcnet.o \ obj/rpcmining.o \ diff --git a/src/makefile.osx b/src/makefile.osx index 963c7542e0..5610c97712 100644 --- a/src/makefile.osx +++ b/src/makefile.osx @@ -89,6 +89,7 @@ OBJS= \ obj/net.o \ obj/protocol.o \ obj/bitcoinrpc.o \ + obj/rpcdarksend.o \ obj/rpcdump.o \ obj/rpcnet.o \ obj/rpcmining.o \ diff --git a/src/makefile.unix b/src/makefile.unix index e615de073b..1561ca5019 100644 --- a/src/makefile.unix +++ b/src/makefile.unix @@ -127,6 +127,7 @@ OBJS= \ obj/net.o \ obj/protocol.o \ obj/bitcoinrpc.o \ + obj/rpcdarksend.o \ obj/rpcdump.o \ obj/rpcnet.o \ obj/rpcmining.o \ diff --git a/src/rpcdarksend.cpp b/src/rpcdarksend.cpp new file mode 100644 index 0000000000..c014d64761 --- /dev/null +++ b/src/rpcdarksend.cpp @@ -0,0 +1,109 @@ +// Copyright (c) 2010 Satoshi Nakamoto +// Copyright (c) 2009-2012 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "main.h" +#include "db.h" +#include "init.h" +#include "bitcoinrpc.h" + +using namespace json_spirit; +using namespace std; + +Value darksend(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 2) + throw runtime_error( + "darksend \n" + " is a real and is rounded to the nearest 0.00000001" + + HelpRequiringPassphrase()); + + CBitcoinAddress address(params[0].get_str()); + if (!address.IsValid()) + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid DarkCoin address"); + + // Amount + int64 nAmount = AmountFromValue(params[1]); + + if (pwalletMain->IsLocked()) + throw JSONRPCError(RPC_WALLET_UNLOCK_NEEDED, "Error: Please enter the wallet passphrase with walletpassphrase first."); + + string strError = pwalletMain->DarkSendMoney(address.Get(), nAmount); + if (strError != "") + throw JSONRPCError(RPC_WALLET_ERROR, strError); + + return ""; +} + +Value getpoolinfo(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 0) + throw runtime_error( + "getpoolinfo\n" + "Returns an object containing anonymous pool-related information."); + + Object obj; + obj.push_back(Pair("masternode", darkSendPool.GetMasterNodeAddr())); + obj.push_back(Pair("state", darkSendPool.GetState())); + obj.push_back(Pair("entries", darkSendPool.GetEntriesCount())); + obj.push_back(Pair("entries_accepted", darkSendPool.GetCountEntriesAccepted())); + obj.push_back(Pair("signatures", darkSendPool.GetSignatureCount())); + return obj; +} + +Value darksendsub(const Array& params, bool fHelp) +{ + darkSendPool.SubscribeToMasterNode(); + return Value::null; +} + +Value masternode(const Array& params, bool fHelp) +{ + string strCommand; + if (params.size() == 1) + strCommand = params[0].get_str(); + if (fHelp || params.size() != 1 || + (strCommand != "start" && strCommand != "stop" && strCommand != "list" && strCommand != "count" + && strCommand != "debug" && strCommand != "create")) + throw runtime_error( + "masternode \n"); + + if (strCommand == "stop") + { + return "Not implemented yet"; + } + + if (strCommand == "list") + { + Object obj; + BOOST_FOREACH(CMasterNode mn, darkSendMasterNodes) { + mn.Check(); + obj.push_back(Pair(mn.addr.ToString().c_str(), (int)mn.IsEnabled())); + } + return obj; + } + + if (strCommand == "count") return (int)darkSendMasterNodes.size(); + + if (strCommand == "debug") + { + if(darkSendPool.isCapableMasterNode) return "is masternode"; + + CTxIn vin = CTxIn(); + bool found = darkSendPool.GetMasterNodeVin(vin); + if(!found){ + return "Missing masternode input, try running masternode create"; + } else { + return "No problems were found"; + } + } + + if (strCommand == "create") + { + return "Not implemented yet"; + } + + return Value::null; +} + diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index cdf38da4b8..2ba814e68d 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -161,28 +161,6 @@ Value getmininginfo(const Array& params, bool fHelp) return obj; } -Value getpoolinfo(const Array& params, bool fHelp) -{ - if (fHelp || params.size() != 0) - throw runtime_error( - "getpoolinfo\n" - "Returns an object containing anonymous pool-related information."); - - Object obj; - obj.push_back(Pair("masternode", darkSendPool.GetMasterNodeAddr())); - obj.push_back(Pair("state", darkSendPool.GetState())); - obj.push_back(Pair("entries", darkSendPool.GetEntriesCount())); - obj.push_back(Pair("entries_accepted", darkSendPool.GetCountEntriesAccepted())); - obj.push_back(Pair("signatures", darkSendPool.GetSignatureCount())); - return obj; -} - -Value darksendsub(const Array& params, bool fHelp) -{ - darkSendPool.SubscribeToMasterNode(); - return Value::null; -} - Value getworkex(const Array& params, bool fHelp) { if (fHelp || params.size() > 2) diff --git a/src/rpcwallet.cpp b/src/rpcwallet.cpp index f57030d8ee..91342330b1 100644 --- a/src/rpcwallet.cpp +++ b/src/rpcwallet.cpp @@ -94,8 +94,6 @@ Value getinfo(const Array& params, bool fHelp) return obj; } - - Value getnewaddress(const Array& params, bool fHelp) { if (fHelp || params.size() > 1) @@ -302,31 +300,6 @@ Value sendtoaddress(const Array& params, bool fHelp) return wtx.GetHash().GetHex(); } -Value darksend(const Array& params, bool fHelp) -{ - if (fHelp || params.size() != 2) - throw runtime_error( - "darksend \n" - " is a real and is rounded to the nearest 0.00000001" - + HelpRequiringPassphrase()); - - CBitcoinAddress address(params[0].get_str()); - if (!address.IsValid()) - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid DarkCoin address"); - - // Amount - int64 nAmount = AmountFromValue(params[1]); - - if (pwalletMain->IsLocked()) - throw JSONRPCError(RPC_WALLET_UNLOCK_NEEDED, "Error: Please enter the wallet passphrase with walletpassphrase first."); - - string strError = pwalletMain->DarkSendMoney(address.Get(), nAmount); - if (strError != "") - throw JSONRPCError(RPC_WALLET_ERROR, strError); - - return ""; -} - Value listaddressgroupings(const Array& params, bool fHelp) { if (fHelp)