diff --git a/src/komodo.h b/src/komodo.h index 42a632827..981dc0ddd 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -678,5 +678,12 @@ void komodo_index2pubkey33(uint8_t *pubkey33,CBlockIndex *pindex,int32_t height) } } +int32_t komodo_opreturn(uint8_t *opret,int32_t maxsize) +{ + int32_t i; + for (i=0; i<8; i++) + opret[i] = i; + return(i); +} #endif diff --git a/src/miner.cpp b/src/miner.cpp index c5a4fa3dc..80f974759 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -96,6 +96,8 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, consensusParams); } +int32_t komodo_opreturn(uint8_t *opret,int32_t maxsize); + CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) { const CChainParams& chainparams = Params(); @@ -333,11 +335,19 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) //txNew.nLockTime = (uint32_t)time(NULL) - 60; txNew.vin.resize(1); txNew.vin[0].prevout.SetNull(); - txNew.vout.resize(1); + int32_t opretlen; uint8_t opret[8192]; + if ( (opretlen= komodo_opreturn(opret,sizeof(opret))) > 0 ) + { + txNew.vout.resize(2); + txNew.vout[1].scriptPubKey.resize(opretlen); + memcpy(txNew.vout[1].scriptPubKey.data(),opret,opretlen); + txNew.vout[1].nValue = 0; + } else txNew.vout.resize(1); txNew.vout[0].scriptPubKey = scriptPubKeyIn; txNew.vout[0].nValue = GetBlockSubsidy(nHeight, chainparams.GetConsensus()); // Add fees txNew.vout[0].nValue += nFees; + txNew.vin[0].scriptSig = CScript() << nHeight << OP_0; pblock->vtx[0] = txNew; diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index a609881f6..39b98f0f7 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -2372,7 +2372,7 @@ Value listunspent(const Array& params, bool fHelp) uint64_t interest; if ( pindex != 0 ) { - interest = komodo_interest(out.tx->nHeight,nValue,out.tx->nLockTime,pindex->nTime); + interest = komodo_interest(pindex->nHeight,nValue,out.tx->nLockTime,pindex->nTime); entry.push_back(Pair("interest",ValueFromAmount(interest))); } }