diff --git a/src/masternodeman.cpp b/src/masternodeman.cpp index 2b6993ae35..002a9f031c 100644 --- a/src/masternodeman.cpp +++ b/src/masternodeman.cpp @@ -481,6 +481,24 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData return; } + // verify that sig time is legit in past + // should be at least not earlier than block when 1000 DRK tx got MASTERNODE_MIN_CONFIRMATIONS + uint256 hashBlock = 0; + GetTransaction(vin.prevout.hash, tx, hashBlock, true); + map::iterator mi = mapBlockIndex.find(hashBlock); + if (mi != mapBlockIndex.end() && (*mi).second) + { + CBlockIndex* pMNIndex = (*mi).second; // block for 1000 DRK tx -> 1 confirmation + CBlockIndex* pConfIndex = chainActive[pMNIndex->nHeight + MASTERNODE_MIN_CONFIRMATIONS - 1]; // block where tx got MASTERNODE_MIN_CONFIRMATIONS + if(pConfIndex->GetBlockTime() > sigTime) + { + LogPrintf("dsee - Bad sigTime %d for masternode %20s %105s (%i conf block is at %d)\n", + sigTime, addr.ToString(), vin.ToString(), MASTERNODE_MIN_CONFIRMATIONS, pConfIndex->GetBlockTime()); + return; + } + } + + // use this as a peer addrman.Add(CAddress(addr), pfrom->addr, 2*60*60);