diff --git a/src/main.cpp b/src/main.cpp index cd42e109a..eafde8df6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3248,6 +3248,24 @@ static int64_t nTimeTotal = 0; bool FindBlockPos(int32_t tmpflag,CValidationState &state, CDiskBlockPos &pos, unsigned int nAddSize, unsigned int nHeight, uint64_t nTime, bool fKnown = false); bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBlockIndex *pindexNew, const CDiskBlockPos& pos); +bool check_pprevnotarizedht() +{ + static bool init; + if ( init ) + return(true); + int32_t notarizedht,prevMoMheight,prevnotarizedht,pprevnotarizedht; uint256 notarizedhash,txid; + uint64_t AmountToPay=0,ret=0; + notarizedht = komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid,&prevnotarizedht,&pprevnotarizedht); + if ( pprevnotarizedht > 0 ) + { + init = true; + return(true); + } + else + return(false); +} + + bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pindex, CCoinsViewCache& view, bool fJustCheck,bool fCheckPOW) { CDiskBlockPos blockPos; @@ -3282,7 +3300,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin fprintf(stderr,"grandfathered exception, until jan 15th 2019\n"); } // Do this here before the block is moved to the main block files. - if ( ASSETCHAINS_NOTARY_PAY[0] != 0 && pindex->GetHeight() > 10 ) + if ( ASSETCHAINS_NOTARY_PAY[0] != 0 && pindex->GetHeight() > 10 && check_pprevnotarizedht() ) { // do a full block scan to get notarisation position and to enforce a valid notarization is in position 1. // if notarisation in the block, must be position 1 and the coinbase must pay notaries. diff --git a/src/miner.cpp b/src/miner.cpp index ba946fe58..a0174a884 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -393,6 +393,9 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 if (fNotarisation) { + // Can't make payment until 3 notarizations have happened. + if ( !check_pprevnotarizedht() ) + fNotarisation = false; // check if the notarization found is actually valid. if ( tx.vout.size() == 2 && tx.vout[1].nValue == 0 ) {