From 2a0d3dfb9dbf1890264b8f71b1183db218c4c67b Mon Sep 17 00:00:00 2001 From: Evan Duffield Date: Wed, 4 Feb 2015 13:25:12 -0700 Subject: [PATCH] Use hash after transaction was mined - Prevents an attacker from gaming which masternodes they'll use --- src/instantx.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/instantx.cpp b/src/instantx.cpp index 80c725c646..17580d1067 100644 --- a/src/instantx.cpp +++ b/src/instantx.cpp @@ -63,7 +63,13 @@ void ProcessMessageInstantX(CNode* pfrom, std::string& strCommand, CDataStream& return; } } - int nBlockHeight = chainActive.Tip()->nHeight - nTxAge; //calculate the height + + /* + Use a blockheight newer than the input. + This prevents attackers from using transaction mallibility to predict which masternodes + they'll use. + */ + int nBlockHeight = (chainActive.Tip()->nHeight - nTxAge)+4; BOOST_FOREACH(const CTxOut o, tx.vout){ if(!o.scriptPubKey.IsNormalPaymentScript()){ @@ -342,7 +348,7 @@ void CleanTransactionLocksList() if(mapTxLockReq.count(it->second.txHash)){ CTransaction& tx = mapTxLockReq[it->second.txHash]; - + BOOST_FOREACH(const CTxIn& in, tx.vin) mapLockedInputs.erase(in.prevout);