diff --git a/denarius-qt.pro b/denarius-qt.pro index 8a94108d..20162d1e 100644 --- a/denarius-qt.pro +++ b/denarius-qt.pro @@ -1,6 +1,6 @@ TEMPLATE = app TARGET = Denarius -VERSION = 3.3.9.1 +VERSION = 3.3.9.2 INCLUDEPATH += src src/json src/qt src/qt/plugins/mrichtexteditor DEFINES += QT_GUI BOOST_THREAD_USE_LIB BOOST_SPIRIT_THREADSAFE CONFIG += no_include_pwd diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp index e107047b..bc28f7b9 100644 --- a/src/bitcoinrpc.cpp +++ b/src/bitcoinrpc.cpp @@ -265,6 +265,11 @@ static const CRPCCommand vRPCCommands[] = { "getblockcount", &getblockcount, true, false }, { "getconnectioncount", &getconnectioncount, true, false }, { "getpeerinfo", &getpeerinfo, true, false }, + { "getaddednodeinfo", &getaddednodeinfo, true, true }, + { "ping", &ping, true, true }, + { "getnettotals", &getnettotals, true, false }, + { "disconnectnode", &disconnectnode, true, false }, + { "getnetworkinfo", &getnetworkinfo, true, false }, { "gethashespersec", &gethashespersec, true, false }, { "addnode", &addnode, true, true }, { "dumpbootstrap", &dumpbootstrap, false, false }, @@ -301,7 +306,7 @@ static const CRPCCommand vRPCCommands[] = { "addredeemscript", &addredeemscript, false, false }, { "getrawmempool", &getrawmempool, true, false }, { "getblock", &getblock, false, false }, - { "getblockheader", &getblockheader, false, false }, + { "getblockheader", &getblockheader, false, false }, { "getblock_old", &getblock_old, false, false }, { "getblockbynumber", &getblockbynumber, false, false }, { "getblockhash", &getblockhash, false, false }, @@ -359,7 +364,6 @@ static const CRPCCommand vRPCCommands[] = /* Fortunastake features */ { "getpoolinfo", &getpoolinfo, true, false}, - { "spork", &spork, true, false}, { "masternode", &masternode, true, false}, { "fortunastake", &fortunastake, true, false}, @@ -1314,7 +1318,7 @@ Array RPCConvertValues(const std::string &strMethod, const std::vector 1) ConvertTo(params[1]); if (strMethod == "getbalance" && n > 2) ConvertTo(params[2]); if (strMethod == "getblock" && n > 1) ConvertTo(params[1]); - if (strMethod == "getblockheader" && n > 1) ConvertTo(params[1]); + if (strMethod == "getblockheader" && n > 1) ConvertTo(params[1]); if (strMethod == "getblock_old" && n > 1) ConvertTo(params[1]); if (strMethod == "getblockbynumber" && n > 0) ConvertTo(params[0]); if (strMethod == "getblockbynumber" && n > 1) ConvertTo(params[1]); @@ -1365,8 +1369,8 @@ Array RPCConvertValues(const std::string &strMethod, const std::vector 2) ConvertTo(params[2]); if (strMethod == "sendanontod" && n > 1) ConvertTo(params[1]); if (strMethod == "sendanontod" && n > 2) ConvertTo(params[2]); - if (strMethod == "estimateanonfee" && n > 0) ConvertTo(params[0]); - if (strMethod == "estimateanonfee" && n > 1) ConvertTo(params[1]); + if (strMethod == "estimateanonfee" && n > 0) ConvertTo(params[0]); + if (strMethod == "estimateanonfee" && n > 1) ConvertTo(params[1]); if (strMethod == "getpoolinfo" && n > 0) ConvertTo(params[0]); diff --git a/src/bitcoinrpc.h b/src/bitcoinrpc.h index d469bda3..1a9a8d61 100644 --- a/src/bitcoinrpc.h +++ b/src/bitcoinrpc.h @@ -50,10 +50,14 @@ enum RPCErrorCode RPC_INVALID_PARAMETER = -8, // Invalid, missing or duplicate parameter RPC_DATABASE_ERROR = -20, // Database error RPC_DESERIALIZATION_ERROR = -22, // Error parsing or validating structure in raw format + RPC_SERVER_NOT_STARTED = -18, // RPC server was not started (StartRPCThreads() not called) // P2P client errors RPC_CLIENT_NOT_CONNECTED = -9, // Bitcoin is not connected RPC_CLIENT_IN_INITIAL_DOWNLOAD = -10, // Still downloading initial blocks + RPC_CLIENT_NODE_ALREADY_ADDED = -23, // Node is already added + RPC_CLIENT_NODE_NOT_ADDED = -24, // Node has not been added before + RPC_CLIENT_NODE_NOT_CONNECTED = -29, // Node to disconnect not found in connected nodes // Wallet errors RPC_WALLET_ERROR = -4, // Unspecified problem with wallet (key not found etc.) @@ -152,6 +156,12 @@ extern std::vector ParseHexO(const json_spirit::Object& o, std::s 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 ping(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value getaddednodeinfo(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value getnettotals(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value getnetworkinfo(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value disconnectnode(const json_spirit::Array& params, bool fHelp); + extern json_spirit::Value dumpwallet(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value importwallet(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value dumpprivkey(const json_spirit::Array& params, bool fHelp); // in rpcdump.cpp @@ -251,7 +261,6 @@ extern json_spirit::Value reloadanondata(const json_spirit::Array& params, bool extern json_spirit::Value txnreport(const json_spirit::Array& params, bool fHelp); //rpcfortuna.cpp -extern json_spirit::Value spork(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value getpoolinfo(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value masternode(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value fortunastake(const json_spirit::Array& params, bool fHelp); diff --git a/src/clientversion.h b/src/clientversion.h index 4cc32c11..b785d310 100644 --- a/src/clientversion.h +++ b/src/clientversion.h @@ -10,7 +10,7 @@ #define CLIENT_VERSION_MAJOR 3 #define CLIENT_VERSION_MINOR 3 #define CLIENT_VERSION_REVISION 9 -#define CLIENT_VERSION_BUILD 1 +#define CLIENT_VERSION_BUILD 2 // Converts the parameter X to a string after macro replacement on X has been performed. // Don't merge these into one macro! diff --git a/src/fortuna.cpp b/src/fortuna.cpp index a66f2ee1..8b278141 100644 --- a/src/fortuna.cpp +++ b/src/fortuna.cpp @@ -40,12 +40,12 @@ CActiveFortunastake activeFortunastake; int RequestedFortunaStakeList = 0; //MIN_MN_PROTO_VERSION -int MIN_MN_PROTO_VERSION = 31000; +int MIN_MN_PROTO_VERSION = 33900; // D v3.3.9.2 - Proto - 33900 /* *** BEGIN FORTUNA MAGIC ********** Copyright 2014, Darkcoin Developers eduffield - evan@darkcoin.io - Copyright 2018, Denarius Developers + Copyright 2018-2019, Denarius Developers carsenk - admin@denarius.io enkayz - enkayz@denarius.io */ diff --git a/src/fortuna.h b/src/fortuna.h index 90c24fd4..52b46374 100644 --- a/src/fortuna.h +++ b/src/fortuna.h @@ -224,7 +224,7 @@ class CFortunaSession class CForTunaPool { public: - static const int PROTOCOL_VERSION = 31005; //31005, D v3.3 + static const int PROTOCOL_VERSION = 33900; //33900, D v3.3.9.2 // clients entries std::vector myEntries; diff --git a/src/fortunastake.cpp b/src/fortunastake.cpp index add0ef40..f9c53a35 100644 --- a/src/fortunastake.cpp +++ b/src/fortunastake.cpp @@ -131,7 +131,7 @@ void ProcessMessageFortunastake(CNode* pfrom, std::string& strCommand, CDataStre if((fTestNet && addr.GetPort() != 19999) || (!fTestNet && addr.GetPort() != 9999)) return; //search existing fortunastake list, this is where we update existing fortunastakes with new dsee broadcasts - LOCK(cs_fortunastakes); + LOCK(cs_fortunastakes); BOOST_FOREACH(CFortunaStake& mn, vecFortunastakes) { if(mn.vin.prevout == vin.prevout) { // count == -1 when it's a new entry @@ -139,7 +139,8 @@ void ProcessMessageFortunastake(CNode* pfrom, std::string& strCommand, CDataStre // mn.pubkey = pubkey, IsVinAssociatedWithPubkey is validated once below, // after that they just need to match if(count == -1 && mn.pubkey == pubkey && !mn.UpdatedWithin(FORTUNASTAKE_MIN_DSEE_SECONDS)){ - mn.UpdateLastSeen(); // update last seen without the sigTime since it's a new entry + mn.UpdateLastSeen(sigTime); // Updated UpdateLastSeen with sigTime + //mn.UpdateLastSeen(); // update last seen without the sigTime since it's a new entry if(mn.now < sigTime){ //take the newest entry if (fDebugFS & fDebugNet) printf("dsee - Got updated entry for %s\n", addr.ToString().c_str()); diff --git a/src/fortunastake.h b/src/fortunastake.h index b67e90b0..c8a6d76b 100644 --- a/src/fortunastake.h +++ b/src/fortunastake.h @@ -203,7 +203,7 @@ class CFortunaStake void UpdateLastSeen(int64_t override=0) { - if (override == 0) { + if (override == 0 || override > GetAdjustedTime()) { lastTimeSeen = GetAdjustedTime(); } else { lastTimeSeen = override; @@ -342,8 +342,8 @@ class CFortunastakePayments public: CFortunastakePayments() { - strMainPubKey = "04af2b6c63d5e5937266a4ce630ab6ced73a0f6a5ff5611ef9b5cfc4f9e264e4a8a4840ab4da4d3ded243ef9f80f114d335dad9a87a50431004b35c01b2c68ea49"; - strTestPubKey = "0406d6c9580d20c4daaacbade0f5bbe4448c511c5860f6dc27a1bf2a8c043b2ad27f3831f8e24750488f0c715100cc5a5811ffd578029f3af62633d9e1c51be384"; + strMainPubKey = ""; + strTestPubKey = ""; enabled = false; } diff --git a/src/init.cpp b/src/init.cpp index e21a807e..0337487d 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -489,7 +489,7 @@ bool AppInit2() // Fee-per-kilobyte amount considered the same as "free" // Be careful setting this: if you set it to zero then // a transaction spammer can cheaply fill blocks using - // 1-satoshi-fee transactions. It should be set above the real + // 1-denarii-fee transactions. It should be set above the real // cost to you of processing a transaction. if (mapArgs.count("-mintxfee")) ParseMoney(mapArgs["-mintxfee"], nMinTxFee); diff --git a/src/main.cpp b/src/main.cpp index 7a17b677..d4ef26f5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2641,12 +2641,12 @@ bool CBlock::ConnectBlock(CTxDB& txdb, CBlockIndex* pindex, bool fJustCheck) if (!fIsInitialDownload) { if (!CheckFSPayment(pindex, vtx[1].vout[i].nValue, mn)) // if MN is being paid and it's bottom 50% ranked, don't let it be paid. { - if (pindexBest->nHeight >= MN_ENFORCEMENT_ACTIVE_HEIGHT) { - return error("CheckBlock-POS() : Out-of-cycle fortunastake payment detected, rejecting block."); + if (pindexBest->nHeight >= MN_ENFORCEMENT_ACTIVE_HEIGHT) { //Update PoS FS Payments to not go out of sync + return error("CheckBlock-POS() : Out-of-cycle fortunastake payment detected, rejecting block."); } else { - if (fDebug) printf("WARNING: This fortunastake payment is too aggressive and will not be accepted after block %d\n", MN_ENFORCEMENT_ACTIVE_HEIGHT); + if (fDebug) printf("CheckBlock-POS(): This fortunastake payment is too aggressive and will be accepted after block %d\n", MN_ENFORCEMENT_ACTIVE_HEIGHT); } - break; + //break; } else { if (fDebug) printf("CheckBlock-POS() : Payment meets rate requirement: payee has earnt %s against average %s\n",FormatMoney(mn.payValue).c_str(),FormatMoney(nAverageFSIncome).c_str()); } @@ -2769,8 +2769,7 @@ bool CBlock::ConnectBlock(CTxDB& txdb, CBlockIndex* pindex, bool fJustCheck) if (pindexBest->nHeight >= MN_ENFORCEMENT_ACTIVE_HEIGHT) { return error("CheckBlock-POW() : Fortunastake overpayment detected, rejecting block. rank:%d value:%s avg:%s payRate:%s",mn.nRank,FormatMoney(mn.payValue).c_str(),FormatMoney(nAverageFSIncome).c_str(),FormatMoney(mn.payRate).c_str()); - } else - { + } else { if (fDebug) printf("WARNING: This fortunastake payment is too aggressive and will not be accepted after block %d\n", MN_ENFORCEMENT_ACTIVE_HEIGHT); } } else { @@ -3681,7 +3680,7 @@ bool ProcessBlock(CNode* pfrom, CBlock* pblock) //After block 1.5m, The Minimum FortunaStake Protocol Version is 31005 if(nBestHeight >= 1500000) { - MIN_MN_PROTO_VERSION = 31005; + MIN_MN_PROTO_VERSION = 33900; } // ppcoin: if responsible for sync-checkpoint send it diff --git a/src/makefile.arm b/src/makefile.arm index a0ddc544..e1925b78 100644 --- a/src/makefile.arm +++ b/src/makefile.arm @@ -32,6 +32,7 @@ endif LIBS += \ -Wl,-B$(LMODE) \ -l boost_system$(BOOST_LIB_SUFFIX) \ + -l boost_chrono$(BOOST_LIB_SUFFIX) \ -l boost_filesystem$(BOOST_LIB_SUFFIX) \ -l boost_program_options$(BOOST_LIB_SUFFIX) \ -l boost_thread$(BOOST_LIB_SUFFIX) \ diff --git a/src/miner.cpp b/src/miner.cpp index 3727ea9a..d0e20cff 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -193,7 +193,7 @@ CBlock* CreateNewBlock(CWallet* pwallet, bool fProofOfStake, int64_t* pFees) // Fee-per-kilobyte amount considered the same as "free" // Be careful setting this: if you set it to zero then // a transaction spammer can cheaply fill blocks using - // 1-satoshi-fee transactions. It should be set above the real + // 1-denarii-fee transactions. It should be set above the real // cost to you of processing a transaction. int64_t nMinTxFee = MIN_TX_FEE; if (mapArgs.count("-mintxfee")) diff --git a/src/net.cpp b/src/net.cpp index e7ba6040..56ce4f72 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -47,19 +47,14 @@ void ThreadDNSAddressSeed2(void* parg); bool OpenNetworkConnection(const CAddress& addrConnect, CSemaphoreGrant *grantOutbound = NULL, const char *strDest = NULL, bool fOneShot = false); -struct LocalServiceInfo { - int nScore; - int nPort; -}; - // // Global state variables // bool fDiscover = true; bool fUseUPnP = false; uint64_t nLocalServices = NODE_NETWORK; -static CCriticalSection cs_mapLocalHost; -static map mapLocalHost; +CCriticalSection cs_mapLocalHost; +map mapLocalHost; static bool vfReachable[NET_MAX] = {}; static bool vfLimited[NET_MAX] = {}; static CNode* pnodeLocalHost = NULL; @@ -471,7 +466,7 @@ CNode* FindNode(const CNetAddr& ip) return NULL; } -CNode* FindNode(std::string addrName) +CNode* FindNode(const std::string& addrName) { LOCK(cs_vNodes); BOOST_FOREACH(CNode* pnode, vNodes) @@ -565,7 +560,7 @@ void CNode::CloseSocketDisconnect() fDisconnect = true; if (hSocket != INVALID_SOCKET) { - printf("disconnecting node %s\n", addrName.c_str()); + printf("Net() Disconnecting node %s\n", addrName.c_str()); closesocket(hSocket); hSocket = INVALID_SOCKET; @@ -621,6 +616,35 @@ bool CNode::IsBanned(CNetAddr ip) return fResult; } +bool CNode::Ban(const CNetAddr &addr) { + int64_t banTime = GetTime()+GetArg("-bantime", 60*60*24); // Default 24-hour ban + { + LOCK(cs_setBanned); + if (setBanned[addr] < banTime) + setBanned[addr] = banTime; + } + return true; +} + +//Whitelisted peers/nodes +//std::vector CNode::vWhitelistedRange; +//CCriticalSection CNode::cs_vWhitelistedRange; +/* +bool CNode::IsWhitelistedRange(const CNetAddr &addr) { + LOCK(cs_vWhitelistedRange); + BOOST_FOREACH(const CSubNet& subnet, vWhitelistedRange) { + if (subnet.Match(addr)) + return true; + } + return false; +} + +void CNode::AddWhitelistedRange(const CSubNet &subnet) { + LOCK(cs_vWhitelistedRange); + vWhitelistedRange.push_back(subnet); +} + */ + bool CNode::Misbehaving(int howmuch) { if (addr.IsLocal()) @@ -663,6 +687,7 @@ void CNode::copyStats(CNodeStats &stats) X(fInbound); X(nStartingHeight); X(nMisbehavior); + //X(fWhitelisted); // It is common for nodes with good ping times to suddenly become lagged, // due to a new block arriving or other large transfer. @@ -1107,6 +1132,17 @@ void ThreadSocketHandler2(void* parg) pnode->CloseSocketDisconnect(); } } + else if (nBytes > 100000) // 100,000 Bytes + { + // error + int nErr = WSAGetLastError(); + if (nErr != WSAEWOULDBLOCK && nErr != WSAEMSGSIZE && nErr != WSAEINTR && nErr != WSAEINPROGRESS) + { + if (!pnode->fDisconnect) + printf("Closing socket, output too large %d\n", nErr); + pnode->CloseSocketDisconnect(); + } + } } } } @@ -1785,12 +1821,12 @@ bool OpenNetworkConnection(const CAddress& addrConnect, CSemaphoreGrant *grantOu // if (fShutdown) return false; - if (!strDest) + if (!strDest) { if (IsLocal(addrConnect) || - FindNode((CNetAddr)addrConnect) || CNode::IsBanned(addrConnect) || - FindNode(addrConnect.ToStringIPPort().c_str())) + FindNode((CNetAddr) addrConnect) || CNode::IsBanned(addrConnect) || + FindNode(addrConnect.ToStringIPPort())) return false; - if (strDest && FindNode(strDest)) + } else if (FindNode(strDest)) return false; vnThreadsRunning[THREAD_OPENCONNECTIONS]--; diff --git a/src/net.h b/src/net.h index 572a1902..fd4bb029 100644 --- a/src/net.h +++ b/src/net.h @@ -31,7 +31,7 @@ static const int PING_INTERVAL = 2 * 60; /** Time after which to disconnect, after waiting for a ping response (or inactivity). */ static const int TIMEOUT_INTERVAL = 20 * 60; -inline unsigned int ReceiveFloodSize() { return 1000*GetArg("-maxreceivebuffer", 5*1000); } +inline unsigned int ReceiveFloodSize() { return 1000*GetArg("-maxreceivebuffer", 1*1000); } inline unsigned int SendBufferSize() { return 1000*GetArg("-maxsendbuffer", 1*1000); } void AddOneShot(std::string strDest); @@ -39,6 +39,7 @@ bool RecvLine(SOCKET hSocket, std::string& strLine); bool GetMyExternalIP(CNetAddr& ipRet); void AddressCurrentlyConnected(const CService& addr); CNode* FindNode(const CNetAddr& ip); +CNode* FindNode(const std::string& addrName); CNode* FindNode(const CService& ip); //CNode* ConnectNode(CAddress addrConnect, const char *strDest = NULL); CNode* ConnectNode(CAddress addrConnect, const char *strDest = NULL, bool forTunaMaster=false); @@ -157,6 +158,13 @@ extern std::map mapAlreadyAskedFor; extern NodeId nLastNodeId; extern CCriticalSection cs_nLastNodeId; +struct LocalServiceInfo { + int nScore; + int nPort; +}; + +extern CCriticalSection cs_mapLocalHost; +extern std::map mapLocalHost; class CNodeStateStats { @@ -291,6 +299,7 @@ class CNode CService addrLocal; int nVersion; std::string strSubVer; + //bool fWhitelisted; // This peer can bypass DoS banning. bool fOneShot; bool fClient; bool fInbound; @@ -314,6 +323,11 @@ class CNode static std::map setBanned; static CCriticalSection cs_setBanned; + // Whitelisted ranges. Any node connecting from these is automatically + // whitelisted (as well as those connecting to whitelisted binds). + //static std::vector vWhitelistedRange; + //static CCriticalSection cs_vWhitelistedRange; + std::vector vecRequestsFulfilled; //keep track of what client has asked for public: @@ -789,6 +803,7 @@ template::iterator it = mapSporksActive.begin(); - - Object ret; - while(it != mapSporksActive.end()) { - ret.push_back(Pair(sporkManager.GetSporkNameByID(it->second.nSporkID), it->second.nValue)); - it++; - } - return ret; - } else if (params.size() == 2){ - int nSporkID = sporkManager.GetSporkIDByName(params[0].get_str()); - if(nSporkID == -1){ - return "Invalid spork name"; - } - - // SPORK VALUE - int64_t nValue = params[1].get_int(); - - //broadcast new spork - if(sporkManager.UpdateSpork(nSporkID, nValue)){ - return "success"; - } else { - return "failure"; - } - - } - - throw runtime_error( - "spork []\n" - " is the corresponding spork name, or 'show' to show all current spork settings" - " is a epoch datetime to enable or disable spork" - + HelpRequiringPassphrase()); -} - Value gettxout(const Array& params, bool fHelp) { if (fHelp || params.size() < 2 || params.size() > 3) diff --git a/src/rpcdump.cpp b/src/rpcdump.cpp index 08a7280f..bdd663f0 100644 --- a/src/rpcdump.cpp +++ b/src/rpcdump.cpp @@ -107,15 +107,18 @@ class CTxDump Value importprivkey(const Array& params, bool fHelp) { - if (fHelp || params.size() < 1 || params.size() > 2) + if (fHelp || params.size() < 1 || params.size() > 3) throw runtime_error( - "importprivkey [label]\n" + "importprivkey [label] [rescan=true]\n" "Adds a private key (as returned by dumpprivkey) to your wallet."); + bool fRescan = true; string strSecret = params[0].get_str(); string strLabel = ""; if (params.size() > 1) strLabel = params[1].get_str(); + if (params.size() > 2) + fRescan = params[2].get_bool(); CBitcoinSecret vchSecret; bool fGood = vchSecret.SetString(strSecret); @@ -141,11 +144,12 @@ Value importprivkey(const Array& params, bool fHelp) if (!pwalletMain->AddKey(key)) throw JSONRPCError(RPC_WALLET_ERROR, "Error adding key to wallet"); - // whenever a key is imported, we need to scan the whole chain - pwalletMain->nTimeFirstKey = 1; // 0 would be considered 'no value' - - pwalletMain->ScanForWalletTransactions(pindexGenesisBlock, true); - pwalletMain->ReacceptWalletTransactions(); + // if rescan is true, we need to scan the whole chain + if(fRescan){ + pwalletMain->nTimeFirstKey = 1; // 0 would be considered 'no value' + pwalletMain->ScanForWalletTransactions(pindexGenesisBlock, true); + pwalletMain->ReacceptWalletTransactions(); + } } return Value::null; @@ -372,4 +376,4 @@ Value dumpwallet(const Array& params, bool fHelp) file << "# End of dump\n"; file.close(); return Value::null; -} +} \ No newline at end of file diff --git a/src/rpcnet.cpp b/src/rpcnet.cpp index b3aad66a..1db61338 100644 --- a/src/rpcnet.cpp +++ b/src/rpcnet.cpp @@ -36,6 +36,24 @@ static void CopyNodeStats(std::vector& vstats) } } +Value ping(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 0) + throw runtime_error( + "ping\n" + "Requests that a ping be sent to all other nodes, to measure ping time.\n" + "Results provided in getpeerinfo, pingtime and pingwait fields are decimal seconds.\n" + "Ping command is handled in queue with all other commands, so it measures processing backlog, not just network ping."); + + // Request that each node send a ping during next message processing pass + LOCK(cs_vNodes); + BOOST_FOREACH(CNode* pNode, vNodes) { + pNode->fPingQueued = true; + } + + return Value::null; +} + Value getpeerinfo(const Array& params, bool fHelp) { if (fHelp || params.size() != 0) @@ -52,10 +70,15 @@ Value getpeerinfo(const Array& params, bool fHelp) Object obj; obj.push_back(Pair("addr", stats.addrName)); + if (!(stats.addrLocal.empty())) + obj.push_back(Pair("addrlocal", stats.addrLocal)); obj.push_back(Pair("services", strprintf("%08" PRIx64, stats.nServices))); obj.push_back(Pair("lastsend", (int64_t)stats.nLastSend)); obj.push_back(Pair("lastrecv", (int64_t)stats.nLastRecv)); obj.push_back(Pair("conntime", (int64_t)stats.nTimeConnected)); + obj.push_back(Pair("pingtime", stats.dPingTime)); //return nodes ping time + if (stats.dPingWait > 0.0) + obj.push_back(Pair("pingwait", stats.dPingWait)); obj.push_back(Pair("version", stats.nVersion)); obj.push_back(Pair("subver", stats.strSubVer)); obj.push_back(Pair("inbound", stats.fInbound)); @@ -74,10 +97,10 @@ Value addnode(const Array& params, bool fHelp) if (params.size() == 2) strCommand = params[1].get_str(); if (fHelp || params.size() != 2 || - (strCommand != "onetry" && strCommand != "add" && strCommand != "remove")) + (strCommand != "onetry" && strCommand != "add" && strCommand != "remove" && strCommand != "ban")) throw runtime_error( - "addnode \n" - "Attempts add or remove from the addnode list or try a connection to once."); + "addnode \n" + "Attempts add or remove from the addnode list or try a connection to once, 'ban' to ban connected node\n"); string strNode = params[0].get_str(); @@ -87,6 +110,17 @@ Value addnode(const Array& params, bool fHelp) ConnectNode(addr, strNode.c_str()); return Value::null; } + else if(strCommand == "ban") + { + CNode* pnode = FindNode(strNode); + if(pnode) { + CNode::Ban(pnode->addr); + pnode->CloseSocketDisconnect(); + } else { + throw JSONRPCError(RPC_CLIENT_NOT_CONNECTED, "Error: Node is not connected."); + } + return Value::null; + } LOCK(cs_vAddedNodes); vector::iterator it = vAddedNodes.begin(); @@ -107,9 +141,223 @@ Value addnode(const Array& params, bool fHelp) vAddedNodes.erase(it); } + + return Value::null; +} + +Value disconnectnode(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 1) + throw runtime_error( + "disconnectnode \"node\" \n" + "\nImmediately disconnects from the specified node.\n" + "\nArguments:\n" + "1. \"node\" (string, required) The node (see getpeerinfo for nodes)\n" + ); + + string theNode = params[0].get_str(); + + CNode* pNode = FindNode(theNode); + if (pNode == NULL) + throw JSONRPCError(RPC_CLIENT_NODE_NOT_CONNECTED, "Node not found in connected nodes"); + + pNode->fDisconnect = true; + return Value::null; } +static Array GetNetworksInfo() +{ + Array networks; + for(int n=0; n(n); + if(network == NET_UNROUTABLE) + continue; + proxyType proxy; + Object obj; + GetProxy(network, proxy); + obj.push_back(Pair("name", GetNetworkName(network))); + obj.push_back(Pair("limited", IsLimited(network))); + //obj.push_back(Pair("reachable", IsReachable(network))); + //obj.push_back(Pair("proxy", proxy.IsValid() ? proxy.ToStringIPPort() : string())); + networks.push_back(obj); + } + return networks; +} + +static const string SingleAlertSubVersionsString( const std::set& setVersions ) +{ + std::string strSetSubVer; + BOOST_FOREACH(std::string str, setVersions) { + if(strSetSubVer.size()) // Must be more than one + strSetSubVer += " or "; + strSetSubVer += str; + } + return strSetSubVer; +} + +Value getnetworkinfo(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 0) + throw runtime_error( + "getnetworkinfo\n" + " Returns an object containing various state info regarding P2P networking.\n" + "\nResult:\n" + "{\n" + " \"version\": xxxxx, (numeric) the server version\n" + " \"subver\": \"/s:n.n.n.n/\", (string) this clients subversion string\n" + " \"protocolversion\": xxxxx, (numeric) the protocol version\n" + " \"localservices\": \"xxxx\", (hex string) Our local service bits as a 16 char string.\n" + " \"timeoffset\": xxxxx, (numeric) the time offset\n" + " \"connections\": xxxxx, (numeric) the number of connections\n" + " \"networkconnections\": [ (array) the state of each possible network connection type\n" + " \"name\": \"xxx\", (string) network name\n" + " \"limited\" : true|false, (boolean) if service is limited\n" + " ]\n" + " \"localaddresses\": [ (array) list of local addresses\n" + " \"address\": \"xxxx\", (string) network address\n" + " \"port\": xxx, (numeric) network port\n" + " \"score\": xxx (numeric) relative score\n" + " ]\n" + "}\n" + ); + + LOCK(cs_main); + + Object obj; + obj.push_back(Pair("version", (int)CLIENT_VERSION)); + obj.push_back(Pair("subversion", FormatSubVersion(CLIENT_NAME, CLIENT_VERSION, std::vector()))); + obj.push_back(Pair("protocolversion",(int)PROTOCOL_VERSION)); + obj.push_back(Pair("localservices", strprintf("%016", PRIx64, nLocalServices))); + obj.push_back(Pair("timeoffset", GetTimeOffset())); + obj.push_back(Pair("connections", (int)vNodes.size())); + //obj.push_back(Pair("relayfee", ValueFromAmount(minRelayTxFee.GetFeePerK()))); + obj.push_back(Pair("networkconnections",GetNetworksInfo())); + Array localAddresses; + { + LOCK(cs_mapLocalHost); + BOOST_FOREACH(const PAIRTYPE(CNetAddr, LocalServiceInfo) &item, mapLocalHost) + { + Object rec; + rec.push_back(Pair("address", item.first.ToString())); + rec.push_back(Pair("port", item.second.nPort)); + rec.push_back(Pair("score", item.second.nScore)); + localAddresses.push_back(rec); + } + } + obj.push_back(Pair("localaddresses", localAddresses)); + + return obj; +} + +Value getaddednodeinfo(const Array& params, bool fHelp) +{ + if (fHelp || params.size() < 1 || params.size() > 2) + throw runtime_error( + "getaddednodeinfo [node]\n" + "Returns information about the given added node, or all added nodes\n" + "(note that onetry addnodes are not listed here)\n" + "If dns is false, only a list of added nodes will be provided,\n" + "otherwise connected information will also be available."); + + bool fDns = params[0].get_bool(); + + list laddedNodes(0); + if (params.size() == 1) + { + LOCK(cs_vAddedNodes); + BOOST_FOREACH(string& strAddNode, vAddedNodes) + laddedNodes.push_back(strAddNode); + } + else + { + string strNode = params[1].get_str(); + LOCK(cs_vAddedNodes); + BOOST_FOREACH(string& strAddNode, vAddedNodes) + if (strAddNode == strNode) + { + laddedNodes.push_back(strAddNode); + break; + } + if (laddedNodes.size() == 0) + throw JSONRPCError(RPC_CLIENT_NODE_NOT_ADDED, "Error: Node has not been added."); + } + + if (!fDns) + { + Object ret; + BOOST_FOREACH(string& strAddNode, laddedNodes) + ret.push_back(Pair("addednode", strAddNode)); + return ret; + } + + Array ret; + + list > > laddedAddreses(0); + BOOST_FOREACH(string& strAddNode, laddedNodes) + { + vector vservNode(0); + if(Lookup(strAddNode.c_str(), vservNode, GetDefaultPort(), fNameLookup, 0)) + laddedAddreses.push_back(make_pair(strAddNode, vservNode)); + else + { + Object obj; + obj.push_back(Pair("addednode", strAddNode)); + obj.push_back(Pair("connected", false)); + Array addresses; + obj.push_back(Pair("addresses", addresses)); + } + } + + LOCK(cs_vNodes); + for (list > >::iterator it = laddedAddreses.begin(); it != laddedAddreses.end(); it++) + { + Object obj; + obj.push_back(Pair("addednode", it->first)); + + Array addresses; + bool fConnected = false; + BOOST_FOREACH(CService& addrNode, it->second) + { + bool fFound = false; + Object node; + node.push_back(Pair("address", addrNode.ToString())); + BOOST_FOREACH(CNode* pnode, vNodes) + if (pnode->addr == addrNode) + { + fFound = true; + fConnected = true; + node.push_back(Pair("connected", pnode->fInbound ? "inbound" : "outbound")); + break; + } + if (!fFound) + node.push_back(Pair("connected", "false")); + addresses.push_back(node); + } + obj.push_back(Pair("connected", fConnected)); + obj.push_back(Pair("addresses", addresses)); + ret.push_back(obj); + } + + return ret; +} + +Value getnettotals(const Array& params, bool fHelp) +{ + if (fHelp || params.size() > 0) + throw runtime_error( + "getnettotals\n" + "Returns information about network traffic, including bytes in, bytes out,\n" + "and current time."); + + Object obj; + obj.push_back(Pair("totalbytesrecv", CNode::GetTotalBytesRecv())); + obj.push_back(Pair("totalbytessent", CNode::GetTotalBytesSent())); + obj.push_back(Pair("timemillis", GetTimeMillis())); + return obj; +} + Value setdebug(const Array& params, bool fHelp) { string strType; diff --git a/src/spork.h b/src/spork.h index 70d4647b..59120810 100644 --- a/src/spork.h +++ b/src/spork.h @@ -95,8 +95,8 @@ class CSporkManager public: CSporkManager() { - strMainPubKey = "0417d4b095e451d08bd83111d9ddc7f648af93d8f72e4391940bfa97bde644c0504e1f04a9e7e89be7e1c54c8995f8905be76f50d43fb4a31a7abba5e5291fbc63"; - strTestPubKey = "0417d4b095e451d08bd83111d9ddc7f648af93d8f72e4391940bfa97bde644c0504e1f04a9e7e89be7e1c54c8995f8905be76f50d43fb4a31a7abba5e5291fbc63"; + strMainPubKey = "invalid"; //Sporks deprecated for dFPS Decentralized Denarius Fortuna Stake system + strTestPubKey = "invalid"; } std::string GetSporkNameByID(int id); diff --git a/src/util.cpp b/src/util.cpp index 4eda8889..f10c25ca 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -1178,12 +1178,12 @@ void WriteConfigFile(FILE* configFile) fputs ("daemon=1\n", configFile); fputs ("listen=1\n", configFile); fputs ("server=1\n", configFile); - fputs ("addnode=104.248.148.86:33369\n", configFile); - fputs ("addnode=124.183.249.162:33369\n", configFile); - fputs ("addnode=128.199.150.171:33369\n", configFile); - fputs ("addnode=148.122.187.2:33369\n", configFile); - fputs ("addnode=149.28.51.135:33369\n", configFile); - fputs ("addnode=168.62.175.85:33369\n", configFile); + fputs ("addnode=149.28.51.135\n", configFile); //mining.cafe + fputs ("addnode=144.136.70.136\n", configFile); // Peers need updating after mandatory + fputs ("addnode=24.117.192.101\n", configFile); + fputs ("addnode=24.205.81.255\n", configFile); + fputs ("addnode=45.77.235.152\n", configFile); + fputs ("addnode=81.204.3.6\n", configFile); fputs ("addnode=173.255.132.121:33369\n", configFile); fputs ("addnode=185.153.46.15:333691\n", configFile); fputs ("addnode=217.122.154.194:33369\n", configFile); @@ -1195,83 +1195,6 @@ void WriteConfigFile(FILE* configFile) fputs ("addnode=70.161.133.63:33369\n", configFile); fputs ("addnode=82.51.2.218:33369\n", configFile); fputs ("addnode=94.64.12.74:33369\n", configFile); - fputs ("addnode=100.38.242.115\n", configFile); - fputs ("addnode=104.156.255.101\n", configFile); - fputs ("addnode=104.238.162.100\n", configFile); - fputs ("addnode=104.248.41.59\n", configFile); - fputs ("addnode=109.134.82.155\n", configFile); - fputs ("addnode=123.211.68.126\n", configFile); - fputs ("addnode=124.191.151.106\n", configFile); - fputs ("addnode=137.59.252.143\n", configFile); - fputs ("addnode=139.162.38.211\n", configFile); - fputs ("addnode=139.99.195.240\n", configFile); - fputs ("addnode=144.136.70.136\n", configFile); - fputs ("addnode=155.138.133.72\n", configFile); - fputs ("addnode=159.69.149.169\n", configFile); - fputs ("addnode=163.172.216.135\n", configFile); - fputs ("addnode=167.86.103.39\n", configFile); - fputs ("addnode=173.212.200.54\n", configFile); - fputs ("addnode=173.212.203.31\n", configFile); - fputs ("addnode=173.212.233.87\n", configFile); - fputs ("addnode=173.244.200.118\n", configFile); - fputs ("addnode=179.108.185.4\n", configFile); - fputs ("addnode=184.82.239.220\n", configFile); - fputs ("addnode=185.153.46.151\n", configFile); - fputs ("addnode=192.64.24.117\n", configFile); - fputs ("addnode=198.144.158.68\n", configFile); - fputs ("addnode=207.148.116.109\n", configFile); - fputs ("addnode=207.148.86.124\n", configFile); - fputs ("addnode=209.250.240.123\n", configFile); - fputs ("addnode=212.237.18.237\n", configFile); - fputs ("addnode=217.104.40.146\n", configFile); - fputs ("addnode=24.159.177.122\n", configFile); - fputs ("addnode=24.20.163.158\n", configFile); - fputs ("addnode=24.243.68.87\n", configFile); - fputs ("addnode=37.97.136.239\n", configFile); - fputs ("addnode=45.32.111.0\n", configFile); - fputs ("addnode=45.32.238.209\n", configFile); - fputs ("addnode=46.164.32.192\n", configFile); - fputs ("addnode=46.45.35.61\n", configFile); - fputs ("addnode=46.45.38.100\n", configFile); - fputs ("addnode=5.79.133.86\n", configFile); - fputs ("addnode=54.39.50.173\n", configFile); - fputs ("addnode=58.84.91.117\n", configFile); - fputs ("addnode=61.73.245.43\n", configFile); - fputs ("addnode=67.167.13.102\n", configFile); - fputs ("addnode=71.104.62.144\n", configFile); - fputs ("addnode=71.76.176.17\n", configFile); - fputs ("addnode=72.76.16.71\n", configFile); - fputs ("addnode=73.111.172.144\n", configFile); - fputs ("addnode=73.163.144.109\n", configFile); - fputs ("addnode=75.67.45.138\n", configFile); - fputs ("addnode=75.84.146.213\n", configFile); - fputs ("addnode=75.9.150.108\n", configFile); - fputs ("addnode=76.10.217.138\n", configFile); - fputs ("addnode=76.113.60.252\n", configFile); - fputs ("addnode=76.115.234.254\n", configFile); - fputs ("addnode=78.45.117.19\n", configFile); - fputs ("addnode=78.46.46.38\n", configFile); - fputs ("addnode=79.216.91.125\n", configFile); - fputs ("addnode=8.40.180.108\n", configFile); - fputs ("addnode=80.211.103.62\n", configFile); - fputs ("addnode=80.211.141.205\n", configFile); - fputs ("addnode=80.211.7.186\n", configFile); - fputs ("addnode=82.1.110.30\n", configFile); - fputs ("addnode=84.205.5.160\n", configFile); - fputs ("addnode=84.236.48.53\n", configFile); - fputs ("addnode=85.156.168.35\n", configFile); - fputs ("addnode=85.214.152.190\n", configFile); - fputs ("addnode=85.214.204.133\n", configFile); - fputs ("addnode=88.198.38.83\n", configFile); - fputs ("addnode=92.42.12.212\n", configFile); - fputs ("addnode=93.82.23.12\n", configFile); - fputs ("addnode=95.90.222.253\n", configFile); - fputs ("addnode=96.38.188.5\n", configFile); - fputs ("addnode=96.43.143.42\n", configFile); - fputs ("addnode=98.116.221.45\n", configFile); - fputs ("addnode=98.116.47.234\n", configFile); - fputs ("addnode=98.163.65.122\n", configFile); - fputs ("addnode=98.202.247.195\n", configFile); fclose(configFile); ReadConfigFile(mapArgs, mapMultiArgs); } @@ -1334,7 +1257,7 @@ void ReadConfigFile(map& mapSettingsRet, FILE* configFile = fopen(GetConfigFile().string().c_str(), "a"); if (configFile != NULL) { WriteConfigFile(configFile); - fclose(configFile); + //fclose(configFile); printf("WriteConfigFile() Denarius.conf Setup Successfully!"); ReadConfigFile(mapSettingsRet, mapMultiSettingsRet); } else { diff --git a/src/version.cpp b/src/version.cpp index ae2d5f2e..3f2c0c09 100644 --- a/src/version.cpp +++ b/src/version.cpp @@ -8,7 +8,7 @@ // Name of client reported in the 'version' message. Report the same name // for both bitcoind and bitcoin-qt, to make it harder for attackers to // target servers or GUI users specifically. -const std::string CLIENT_NAME("Satoshi"); +const std::string CLIENT_NAME("Denarii"); // Client version number #define CLIENT_VERSION_SUFFIX "" diff --git a/src/version.h b/src/version.h index 0eb274c0..4de8509d 100644 --- a/src/version.h +++ b/src/version.h @@ -30,20 +30,20 @@ static const int DATABASE_VERSION = 21212; // network protocol versioning // -static const int PROTOCOL_VERSION = 33500; //Protocol is now 33500 as of D v3.3.5 +static const int PROTOCOL_VERSION = 33900; //Protocol is now 33900 as of D v3.3.9.2 // intial proto version, to be increased after version/verack negotiation -static const int INIT_PROTO_VERSION = 21212; +static const int INIT_PROTO_VERSION = 33900; // Bumped up from 21212 to 33900 v3.3.9.2 // disconnect from peers older than this proto version -static const int MIN_PEER_PROTO_VERSION = 31005; +static const int MIN_PEER_PROTO_VERSION = 33900; // Don't forget to change proto in FORTUNA.h as well!! On Block 1.5m this will be 31005 extern int MIN_MN_PROTO_VERSION; // nTime field added to CAddress, starting with this version; // if possible, avoid requesting addresses nodes older than this -static const int CADDR_TIME_VERSION = 33500; // start sharing node timeinfo with this proto version 33500 +static const int CADDR_TIME_VERSION = 33900; // start sharing node timeinfo with this proto version 33500 // only request blocks from nodes outside this range of versions static const int NOBLKS_VERSION_START = 70002;