diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index f25b0c62a..63a8bbe3b 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -112,33 +112,20 @@ uint8_t DecodeMaramaraCoinbaseOpRet(const CScript &scriptPubKey,CPubKey &pk,int3 return(0); } -CScript Marmara_scriptPubKey(int32_t height,CScript scriptPubKey) +CScript Marmara_scriptPubKey(int32_t height,CPubKey pk) { - CTxOut ccvout; uint8_t *ptr; CPubKey pk; - if ( height > 0 && (height & 1) == 0 && scriptPubKey.size() == 35 ) - { - ptr = (uint8_t *)scriptPubKey.data(); - if ( ptr[0] == 33 && ptr[34] == OP_CHECKSIG ) - pk = buf2pk(ptr+1); + CTxOut ccvout; + if ( height > 0 && (height & 1) == 0 && pk.size() == 33 ) ccvout = MakeCC1vout(EVAL_MARMARA,0,pk); - return(ccvout.scriptPubKey); - } - return(scriptPubKey); + return(ccvout.scriptPubKey); } -CScript MarmaraCoinbaseOpret(int32_t height,CScript scriptPubKey) +CScript MarmaraCoinbaseOpret(int32_t height,CPubKey pk) { uint8_t *ptr; CPubKey pk; - if ( height > 0 && (height & 1) == 0 && scriptPubKey.size() == 35 ) - { - ptr = (uint8_t *)scriptPubKey.data(); - if ( ptr[0] == 33 && ptr[34] == OP_CHECKSIG ) - { - pk = buf2pk(ptr+1); - return(EncodeMarmaraCoinbaseOpRet(pk,height)); - } - } - return(scriptPubKey); + if ( height > 0 && (height & 1) == 0 && pk.size() == 33 ) + return(EncodeMarmaraCoinbaseOpRet(pk,height)); + return(CScript()); } int32_t MarmaraValidateCoinbase(int32_t height,CTransaction tx) diff --git a/src/miner.cpp b/src/miner.cpp index 223972c80..3322bbb16 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -155,8 +155,8 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt int32_t verus_staked(CBlock *pBlock, CMutableTransaction &txNew, uint32_t &nBits, arith_uint256 &hashResult, uint8_t *utxosig, CPubKey &pk); int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33); int32_t decode_hex(uint8_t *bytes,int32_t n,char *hex); -CScript Marmara_scriptPubKey(int32_t height,CScript scriptPubKey); -CScript MarmaraCoinbaseOpret(int32_t height,CScript scriptPubKey); +CScript Marmara_scriptPubKey(int32_t height,CPubKey pk); +CScript MarmaraCoinbaseOpret(int32_t height,CPubKey pk); CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, bool isStake) { @@ -540,7 +540,7 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, { txNew.vout.resize(2); txNew.vout[1].nValue = 0; - txNew.vout[1].scriptPubKey = MarmaraCoinbaseOpret(nHeight,scriptPubKeyIn); + txNew.vout[1].scriptPubKey = MarmaraCoinbaseOpret(nHeight,pk); } else if ((uint64_t)(txNew.vout[0].nValue) >= ASSETCHAINS_TIMELOCKGTE) { @@ -751,7 +751,10 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, int32_t nHeight, if ( nHeight == 1 && ASSETCHAINS_COMMISSION != 0 ) { if ( ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 ) - scriptPubKey = CScript() << ParseHex(ASSETCHAINS_OVERRIDE_PUBKEY) << OP_CHECKSIG; + { + pubkey = ParseHex(ASSETCHAINS_OVERRIDE_PUBKEY); + scriptPubKey = CScript() << pubkey << OP_CHECKSIG; + } else { len = strlen(ASSETCHAINS_SCRIPTPUB.c_str()); @@ -764,7 +767,8 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, int32_t nHeight, else if ( USE_EXTERNAL_PUBKEY != 0 ) { //fprintf(stderr,"use notary pubkey\n"); - scriptPubKey = CScript() << ParseHex(NOTARY_PUBKEY) << OP_CHECKSIG; + pubkey = ParseHex(NOTARY_PUBKEY); + scriptPubKey = CScript() << pubkey << OP_CHECKSIG; } else { @@ -783,8 +787,8 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, int32_t nHeight, //scriptPubKey = CScript() << ToByteVector(pubkey) << OP_CHECKSIG; } } - if ( ASSETCHAINS_MARMARA != 0 ) - scriptPubKey = Marmara_scriptPubKey(height,scriptPubKey); + if ( ASSETCHAINS_MARMARA != 0 && height > 0 && (height & 1) == 0 ) + scriptPubKey = Marmara_scriptPubKey(height,pubkey); return CreateNewBlock(scriptPubKey, gpucount, isStake); }