| 53 | } |
| 54 | |
| 55 | void ProcessMasternode(CNode* pfrom, const std::string& strCommand, CDataStream& vRecv, bool& isMasternodeCommand) { |
| 56 | |
| 57 | int nHeight = chainActive.Height() + 1; |
| 58 | |
| 59 | // Do not accept the peers having older versions when the fork happens |
| 60 | if (nHeight >= nLuxProtocolSwitchHeight) |
| 61 | { |
| 62 | SCVersion = WORKING_VERSION; |
| 63 | } |
| 64 | |
| 65 | // Reject the MN from older version |
| 66 | if (pfrom && pfrom->strSubVer.compare(SCVersion) < 0) |
| 67 | { |
| 68 | LogPrintf("MASTERNODE: %s: Invalid MN %d, wrong wallet version %s\n", __func__, nHeight, pfrom->strSubVer.c_str()); |
| 69 | return; |
| 70 | } |
| 71 | |
| 72 | if (strCommand == "dsee") { //DarkSend Election Entry |
| 73 | isMasternodeCommand = true; |
| 74 | |
| 75 | bool fIsInitialDownload = IsInitialBlockDownload(); |
| 76 | if (fIsInitialDownload) return; |
| 77 | |
| 78 | CTxIn vin; |
| 79 | CService addr; |
| 80 | CPubKey pubkey; |
| 81 | CPubKey pubkey2; |
| 82 | vector<unsigned char> vchSig; |
| 83 | int64_t sigTime; |
| 84 | int count; |
| 85 | int current; |
| 86 | int64_t lastUpdated; |
| 87 | int protocolVersion; |
| 88 | std::string strMessage; |
| 89 | |
| 90 | // 70047 and greater |
| 91 | vRecv >> vin >> addr >> vchSig >> sigTime >> pubkey >> pubkey2 >> count >> current >> lastUpdated >> protocolVersion; |
| 92 | |
| 93 | // make sure signature isn't in the future (past is OK) |
| 94 | if (sigTime > GetAdjustedTime() + 60 * 60) { |
| 95 | LogPrintf("dsee - Signature rejected, too far into the future %s\n", vin.ToString().c_str()); |
| 96 | return; |
| 97 | } |
| 98 | |
| 99 | bool isLocal = addr.IsRFC1918() || addr.IsLocal(); |
| 100 | //if(Params().MineBlocksOnDemand()) isLocal = false; |
| 101 | |
| 102 | std::string vchPubKey(pubkey.begin(), pubkey.end()); |
| 103 | std::string vchPubKey2(pubkey2.begin(), pubkey2.end()); |
| 104 | |
| 105 | strMessage = addr.ToString() + boost::lexical_cast<std::string>(sigTime) + vchPubKey + vchPubKey2 + boost::lexical_cast<std::string>(protocolVersion); |
| 106 | |
| 107 | if (protocolVersion < MIN_PROTO_VERSION) { |
| 108 | LogPrintf("dsee - ignoring outdated masternode %s protocol version %d\n", vin.ToString().c_str(), protocolVersion); |
| 109 | return; |
| 110 | } |
| 111 | |
| 112 | CScript pubkeyScript; |
no test coverage detected