void ProcessMessageMasternode(CNode* pfrom, std::string& strCommand, CDataStream& vRecv) { if (strCommand == "dsee") { //DarkSend Election Entry if (pfrom->nVersion != darkSendPool.MIN_PEER_PROTO_VERSION) { return; } bool fIsInitialDownload = IsInitialBlockDownload(); if(fIsInitialDownload) return; CTxIn vin; CService addr; CPubKey pubkey; CPubKey pubkey2; vector<unsigned char> vchSig; int64 sigTime; int count; int current; int64 lastUpdated; vRecv >> vin >> addr >> vchSig >> sigTime >> pubkey >> pubkey2 >> count >> current >> lastUpdated; bool isLocal = false; // addr.IsRFC1918(); std::string vchPubKey(pubkey.begin(), pubkey.end()); std::string vchPubKey2(pubkey2.begin(), pubkey2.end()); CScript pubkeyScript; pubkeyScript.SetDestination(pubkey.GetID()); if(pubkeyScript.size() != 25) { LogPrintf("dsee - pubkey the wrong size\n"); pfrom->Misbehaving(100); return; } std::string strMessage = addr.ToString() + boost::lexical_cast<std::string>(sigTime) + vchPubKey + vchPubKey2; CScript pubkeyScript2; pubkeyScript2.SetDestination(pubkey2.GetID()); if(pubkeyScript2.size() != 25) { LogPrintf("dsee - pubkey the wrong size\n"); pfrom->Misbehaving(100); return; } std::string errorMessage = ""; if(!darkSendSigner.VerifyMessage(pubkey, vchSig, strMessage, errorMessage)){ LogPrintf("dsee - Got bad masternode address signature\n"); pfrom->Misbehaving(100); return; } if((fTestNet && addr.GetPort() != 19999) || (!fTestNet && addr.GetPort() != 9999)) return; //LogPrintf("Searching existing masternodes : %s - %s\n", addr.ToString().c_str(), vin.ToString().c_str()); BOOST_FOREACH(CMasterNode& mn, darkSendMasterNodes) { //LogPrintf(" -- %s\n", mn.vin.ToString().c_str()); if(mn.vin.prevout == vin.prevout) { //count == -1 when it's a new entry // e.g. We don't want the entry relayed/time updated when we're syncing the list if(count == -1 && !mn.UpdatedWithin(MASTERNODE_MIN_SECONDS)){ mn.UpdateLastSeen(); if(mn.now < sigTime){ //take the newest entry LogPrintf("dsee - Got updated entry for %s\n", addr.ToString().c_str()); mn.pubkey2 = pubkey2; mn.now = sigTime; mn.sig = vchSig; if(pubkey2 == activeMasternode.pubkeyMasterNode2){ activeMasternode.EnableHotColdMasterNode(vin, sigTime, addr); } RelayDarkSendElectionEntry(vin, addr, vchSig, sigTime, pubkey, pubkey2, count, current, lastUpdated); } } return; } } if(!darkSendSigner.IsVinAssociatedWithPubkey(vin, pubkey)) { LogPrintf("dsee - Got mismatched pubkey and vin\n"); pfrom->Misbehaving(100); return; } LogPrintf("dsee - Got NEW masternode entry %s\n", addr.ToString().c_str()); CValidationState state; CTransaction tx = CTransaction(); CTxOut vout = CTxOut(999.99*COIN, darkSendPool.collateralPubKey); tx.vin.push_back(vin); tx.vout.push_back(vout); if(tx.AcceptableInputs(state, true)){ LogPrintf("dsee - Accepted masternode entry %i %i\n", count, current); if(GetInputAge(vin) < MASTERNODE_MIN_CONFIRMATIONS){ LogPrintf("dsee - Input must have least %d confirmations\n", MASTERNODE_MIN_CONFIRMATIONS); pfrom->Misbehaving(20); return; } addrman.Add(CAddress(addr), pfrom->addr, 2*60*60); CMasterNode mn(addr, vin, pubkey, vchSig, sigTime, pubkey2); mn.UpdateLastSeen(lastUpdated); darkSendMasterNodes.push_back(mn); if(pubkey2 == activeMasternode.pubkeyMasterNode2){ activeMasternode.EnableHotColdMasterNode(vin, sigTime, addr); } if(count == -1 && !isLocal) RelayDarkSendElectionEntry(vin, addr, vchSig, sigTime, pubkey, pubkey2, count, current, lastUpdated); } else { LogPrintf("dsee - Rejected masternode entry\n"); int nDoS = 0; if (state.IsInvalid(nDoS)) { LogPrintf("dsee - %s from %s %s was not accepted into the memory pool\n", tx.GetHash().ToString().c_str(), pfrom->addr.ToString().c_str(), pfrom->cleanSubVer.c_str()); if (nDoS > 0) pfrom->Misbehaving(nDoS); } } } else if (strCommand == "dseep") { //DarkSend Election Entry Ping