From f4f3f6bd6a4e6ca5765b26acc776056141570bf0 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Sun, 1 Mar 2015 18:51:30 +0300 Subject: [PATCH] prevent gaming sigTime too much on initial dsee --- src/masternodeman.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/masternodeman.cpp b/src/masternodeman.cpp index 2b6993ae3..002a9f031 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);