eduffield
Core Developer
eduffield : Is it possible that this piece of code is vulnerable for tampered blocks?
Code:for (unsigned int i = 1; i < vtx[0].vout.size(); i++) if(vtx[0].vout[i].nValue == masternodePaymentAmount && mv1.GetPubKey() == vtx[0].vout[i].scriptPubKey) { foundMasterNodePayment++; } else if(mv1.GetPubKey() == vtx[0].vout[i].scriptPubKey) { printf(" BAD MASTERNODE PAYMENT DETECTED: %"PRI64u"\n", vtx[0].vout[i].nValue); }
Since your test loop is starting at index 1, you are assuming that index 0 has to be miner reward, which is not the case for Block 18135. And the printf is not really catching the exception properly. I don't know yet if this can the exploited, e.g. by swapping value of miner and masternode rewards from 80:20 to 20:80 and pushing the 80% vout to the top in the tx....
It can't be exploited, but if the masternode payment is the first entry then the block would get rejected by the whole network. I might as well fix it while we have the chance.