diff --git a/src/assetchains.old b/src/assetchains.old index cf46922de..af9361746 100755 --- a/src/assetchains.old +++ b/src/assetchains.old @@ -34,68 +34,5 @@ echo $pubkey ./komodod -pubkey=$pubkey -ac_name=DSEC -ac_supply=7000000 -addnode=185.148.147.30 & ./komodod -pubkey=$pubkey -ac_name=GLXT -ac_supply=100000000 -addnode=13.230.224.15 & ./komodod -pubkey=$pubkey -ac_name=EQL -ac_supply=500000000 -addnode=46.101.124.153 & -#sleep $delay +~/VerusCoin/src/komodod -ac_name=VRSC -ac_algo=verushash -ac_cc=1 -ac_veruspos=50 -ac_supply=0 -ac_eras=3 -ac_reward=0,38400000000,2400000000 -ac_halving=1,43200,1051920 -ac_decay=100000000,0,0 -ac_end=10080,226080,0 -ac_timelockgte=19200000000 -ac_timeunlockfrom=129600 -ac_timeunlockto=1180800 -addnode=185.25.48.236 -addnode=185.64.105.111 & -#./komodod -pubkey=$pubkey -ac_name=USD -addnode=78.47.196.146 $1 & -#sleep $delay -#./komodod -pubkey=$pubkey -ac_name=EUR -addnode=78.47.196.146 $1 & -#sleep $delay -#./komodod -pubkey=$pubkey -ac_name=JPY -addnode=78.47.196.146 $1 & -#sleep $delay -#./komodod -pubkey=$pubkey -ac_name=GBP -addnode=78.47.196.146 $1 & -#sleep $delay -#./komodod -pubkey=$pubkey -ac_name=AUD -addnode=78.47.196.146 $1 & -#sleep $delay -#./komodod -pubkey=$pubkey -ac_name=CAD -addnode=78.47.196.146 $1 & -#sleep $delay -#./komodod -pubkey=$pubkey -ac_name=CHF -addnode=78.47.196.146 $1 & -#sleep $delay -#./komodod -pubkey=$pubkey -ac_name=NZD -addnode=78.47.196.146 $1 & -#sleep $delay -#./komodod -pubkey=$pubkey -ac_name=CNY -addnode=78.47.196.146 $1 & -#sleep $delay -#./komodod -pubkey=$pubkey -ac_name=RUB -addnode=78.47.196.146 $1 & -#sleep $delay -#./komodod -pubkey=$pubkey -ac_name=MXN -addnode=78.47.196.146 $1 & -#sleep $delay -#./komodod -pubkey=$pubkey -ac_name=BRL -addnode=78.47.196.146 $1 & -#sleep $delay -#./komodod -pubkey=$pubkey -ac_name=INR -addnode=78.47.196.146 $1 & -#sleep $delay -#./komodod -pubkey=$pubkey -ac_name=HKD -addnode=78.47.196.146 $1 & -#sleep $delay -#./komodod -pubkey=$pubkey -ac_name=TRY -addnode=78.47.196.146 $1 & -#sleep $delay -#./komodod -pubkey=$pubkey -ac_name=ZAR -addnode=78.47.196.146 $1 & -#sleep $delay -#./komodod -pubkey=$pubkey -ac_name=PLN -addnode=78.47.196.146 $1 & -#sleep $delay -#./komodod -pubkey=$pubkey -ac_name=NOK -addnode=78.47.196.146 $1 & -#sleep $delay -#./komodod -pubkey=$pubkey -ac_name=SEK -addnode=78.47.196.146 $1 & -#sleep $delay -#./komodod -pubkey=$pubkey -ac_name=DKK -addnode=78.47.196.146 $1 & -#sleep $delay -#./komodod -pubkey=$pubkey -ac_name=CZK -addnode=78.47.196.146 $1 & -#sleep $delay -#./komodod -pubkey=$pubkey -ac_name=HUF -addnode=78.47.196.146 $1 & -#sleep $delay -#./komodod -pubkey=$pubkey -ac_name=ILS -addnode=78.47.196.146 $1 & -#sleep $delay -#./komodod -pubkey=$pubkey -ac_name=KRW -addnode=78.47.196.146 $1 & -#sleep $delay -#./komodod -pubkey=$pubkey -ac_name=MYR -addnode=78.47.196.146 $1 & -#sleep $delay -#./komodod -pubkey=$pubkey -ac_name=PHP -addnode=78.47.196.146 $1 & -#sleep $delay -#./komodod -pubkey=$pubkey -ac_name=RON -addnode=78.47.196.146 $1 & -#sleep $delay -#./komodod -pubkey=$pubkey -ac_name=SGD -addnode=78.47.196.146 $1 & -#sleep $delay -#./komodod -pubkey=$pubkey -ac_name=THB -addnode=78.47.196.146 $1 & -#sleep $delay -#./komodod -pubkey=$pubkey -ac_name=BGN -addnode=78.47.196.146 $1 & -#sleep $delay -#./komodod -pubkey=$pubkey -ac_name=IDR -addnode=78.47.196.146 $1 & -#sleep $delay -#./komodod -pubkey=$pubkey -ac_name=HRK -addnode=78.47.196.146 $1 & diff --git a/src/komodo.h b/src/komodo.h index 36c7c2ef3..efb59dee1 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -113,7 +113,7 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char if ( fread(&MoMdepth,1,sizeof(MoMdepth),fp) != sizeof(MoMdepth) ) errs++; if ( 1 && ASSETCHAINS_SYMBOL[0] != 0 && sp != 0 ) - printf("%s load[%s.%d -> %s] NOTARIZED %d %s MoM.%s %d\n",ASSETCHAINS_SYMBOL,symbol,sp->NUM_NPOINTS,dest,notarized_height,notarized_hash.ToString().c_str(),MoM.ToString().c_str(),MoMdepth); + printf("%s load[%s.%d -> %s] NOTARIZED %d %s MoM.%s %d CCid.%u\n",ASSETCHAINS_SYMBOL,symbol,sp->NUM_NPOINTS,dest,notarized_height,notarized_hash.ToString().c_str(),MoM.ToString().c_str(),MoMdepth&0xffff,(MoMdepth>>16)&0xffff); } else { @@ -201,8 +201,7 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char komodo_eventadd_pricefeed(sp,symbol,ht,pvals,numpvals); //printf("load pvals ht.%d numpvals.%d\n",ht,numpvals); } else printf("error loading pvals[%d]\n",numpvals); - } - else printf("[%s] %s illegal func.(%d %c)\n",ASSETCHAINS_SYMBOL,symbol,func,func); + } // else printf("[%s] %s illegal func.(%d %c)\n",ASSETCHAINS_SYMBOL,symbol,func,func); return(func); } else return(-1); } @@ -259,7 +258,7 @@ int32_t komodo_parsestatefiledata(struct komodo_state *sp,uint8_t *filedata,long if ( memread(&MoMdepth,sizeof(MoMdepth),filedata,&fpos,datalen) != sizeof(MoMdepth) ) errs++; if ( 1 && ASSETCHAINS_SYMBOL[0] != 0 && sp != 0 ) - printf("%s load[%s.%d -> %s] NOTARIZED %d %s MoM.%s %d\n",ASSETCHAINS_SYMBOL,symbol,sp->NUM_NPOINTS,dest,notarized_height,notarized_hash.ToString().c_str(),MoM.ToString().c_str(),MoMdepth); + printf("%s load[%s.%d -> %s] NOTARIZED %d %s MoM.%s %d CCid.%u\n",ASSETCHAINS_SYMBOL,symbol,sp->NUM_NPOINTS,dest,notarized_height,notarized_hash.ToString().c_str(),MoM.ToString().c_str(),MoMdepth&0xffff,(MoMdepth>>16)&0xffff); } else { @@ -342,8 +341,7 @@ int32_t komodo_parsestatefiledata(struct komodo_state *sp,uint8_t *filedata,long komodo_eventadd_pricefeed(sp,symbol,ht,pvals,numpvals); //printf("load pvals ht.%d numpvals.%d\n",ht,numpvals); } else printf("error loading pvals[%d]\n",numpvals); - } - else printf("[%s] %s illegal func.(%d %c)\n",ASSETCHAINS_SYMBOL,symbol,func,func); + } // else printf("[%s] %s illegal func.(%d %c)\n",ASSETCHAINS_SYMBOL,symbol,func,func); *fposp = fpos; return(func); } @@ -482,7 +480,7 @@ void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotar //printf("ht.%d func N ht.%d errs.%d\n",height,NOTARIZED_HEIGHT,errs); if ( sp != 0 ) { - if ( sp->MoMdepth > 0 && sp->MoM != zero ) + if ( sp->MoMdepth != 0 && sp->MoM != zero ) fputc('M',fp); else fputc('N',fp); if ( fwrite(&height,1,sizeof(height),fp) != sizeof(height) ) @@ -493,7 +491,7 @@ void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotar errs++; if ( fwrite(&sp->NOTARIZED_DESTTXID,1,sizeof(sp->NOTARIZED_DESTTXID),fp) != sizeof(sp->NOTARIZED_DESTTXID) ) errs++; - if ( sp->MoMdepth > 0 && sp->MoM != zero ) + if ( sp->MoMdepth != 0 && sp->MoM != zero ) { if ( fwrite(&sp->MoM,1,sizeof(sp->MoM),fp) != sizeof(sp->MoM) ) errs++; @@ -643,10 +641,12 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr len += iguana_rwbignum(0,&scriptbuf[len],32,(uint8_t *)&MoM); len += iguana_rwnum(0,&scriptbuf[len],sizeof(MoMdepth),(uint8_t *)&MoMdepth); ccdata.MoMdata.MoM = MoM; - ccdata.MoMdata.MoMdepth = MoMdepth; + ccdata.MoMdata.MoMdepth = MoMdepth & 0xffff; if ( len+sizeof(ccdata.CCid)-opoffset <= opretlen ) { len += iguana_rwnum(0,&scriptbuf[len],sizeof(ccdata.CCid),(uint8_t *)&ccdata.CCid); + if ( ((MoMdepth>>16) & 0xffff) != (ccdata.CCid & 0xffff) ) + fprintf(stderr,"%s CCid mismatch %u != %u\n",ASSETCHAINS_SYMBOL,((MoMdepth>>16) & 0xffff),(ccdata.CCid & 0xffff)); ccdata.len = sizeof(ccdata.CCid); if ( ASSETCHAINS_SYMBOL[0] != 0 ) { @@ -672,7 +672,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr } else ccdata.len = MoMoMdata.len = 0; } } - if ( MoM == zero || MoMdepth > *notarizedheightp || MoMdepth < 0 ) + if ( MoM == zero || (MoMdepth&0xffff) > *notarizedheightp || (MoMdepth&0xffff) < 0 ) { memset(&MoM,0,sizeof(MoM)); MoMdepth = 0; @@ -681,7 +681,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr { komodo_rwccdata(ASSETCHAINS_SYMBOL,1,&ccdata,&MoMoMdata); if ( matched != 0 ) - printf("[%s] matched.%d VALID (%s) MoM.%s [%d]\n",ASSETCHAINS_SYMBOL,matched,ccdata.symbol,MoM.ToString().c_str(),MoMdepth); + printf("[%s] matched.%d VALID (%s) MoM.%s [%d] CCid.%u\n",ASSETCHAINS_SYMBOL,matched,ccdata.symbol,MoM.ToString().c_str(),MoMdepth&0xffff,(MoMdepth>>16)&0xffff); } if ( MoMoMdata.pairs != 0 ) free(MoMoMdata.pairs); @@ -695,7 +695,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr sp->NOTARIZED_HEIGHT = *notarizedheightp; sp->NOTARIZED_HASH = srchash; sp->NOTARIZED_DESTTXID = desttxid; - if ( MoM != zero && MoMdepth > 0 ) + if ( MoM != zero && (MoMdepth&0xffff) > 0 ) { sp->MoM = MoM; sp->MoMdepth = MoMdepth; diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 6f971afcc..35214edd8 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -932,7 +932,7 @@ int32_t komodo_MoM(int32_t *notarized_heightp,uint256 *MoMp,uint256 *kmdtxidp,in memset(MoMp,0,sizeof(*MoMp)); memset(kmdtxidp,0,sizeof(*kmdtxidp)); *notarized_heightp = 0; - if ( depth > 0 && notarized_ht > 0 && nHeight > notarized_ht-depth && nHeight <= notarized_ht ) + if ( depth != 0 && notarized_ht > 0 && nHeight > notarized_ht-depth && nHeight <= notarized_ht ) { *MoMp = MoM; *notarized_heightp = notarized_ht; @@ -1265,6 +1265,29 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_ return(isPoS); } +int64_t komodo_checkcommission(CBlock *pblock,int32_t height) +{ + int64_t checktoshis=0; uint8_t *script; + if ( ASSETCHAINS_COMMISSION != 0 ) + { + checktoshis = komodo_commission(pblock); + if ( checktoshis > 10000 && pblock->vtx[0].vout.size() != 2 ) + return(-1); + else if ( checktoshis != 0 ) + { + script = (uint8_t *)pblock->vtx[0].vout[1].scriptPubKey.data(); + if ( script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(script+1,ASSETCHAINS_OVERRIDE_PUBKEY33,33) != 0 ) + return(-1); + if ( pblock->vtx[0].vout[1].nValue != checktoshis ) + { + fprintf(stderr,"ht.%d checktoshis %.8f vs actual vout[1] %.8f\n",height,dstr(checktoshis),dstr(pblock->vtx[0].vout[1].nValue)); + return(-1); + } + } + } + return(checktoshis); +} + bool KOMODO_TEST_ASSETCHAIN_SKIP_POW = 0; int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) @@ -1336,21 +1359,18 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) } else if ( is_PoSblock < 0 ) return(-1); } - if ( failed == 0 && ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 && ASSETCHAINS_COMMISSION != 0 ) + if ( failed == 0 && ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 ) { - checktoshis = komodo_commission(pblock); - if ( checktoshis > 10000 && pblock->vtx[0].vout.size() != 2 ) - return(-1); - else if ( checktoshis != 0 ) + if ( height == 1 ) { - script = (uint8_t *)pblock->vtx[0].vout[1].scriptPubKey.data(); + script = (uint8_t *)pblock->vtx[0].vout[0].scriptPubKey.data(); if ( script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(script+1,ASSETCHAINS_OVERRIDE_PUBKEY33,33) != 0 ) return(-1); - if ( pblock->vtx[0].vout[1].nValue != checktoshis ) - { - fprintf(stderr,"checktoshis %.8f vs actual vout[1] %.8f\n",dstr(checktoshis),dstr(pblock->vtx[0].vout[1].nValue)); + } + else + { + if ( komodo_checkcommission(pblock,height) < 0 ) return(-1); - } } } //fprintf(stderr,"komodo_checkPOW possible.%d slowflag.%d ht.%d notaryid.%d failed.%d\n",possible,slowflag,height,notaryid,failed); diff --git a/src/komodo_ccdata.h b/src/komodo_ccdata.h index 637d13557..6fd065953 100644 --- a/src/komodo_ccdata.h +++ b/src/komodo_ccdata.h @@ -25,6 +25,7 @@ uint256 komodo_calcMoM(int32_t height,int32_t MoMdepth) { static uint256 zero; CBlockIndex *pindex; int32_t i; std::vector tree, leaves; bool fMutated; + MoMdepth &= 0xffff; if ( MoMdepth >= height ) return(zero); for (i=0; i 0 || strangeout != 0 ) + checktoshis = 0; + if ( ASSETCHAINS_COMMISSION != 0 && height > 1 ) { - if ( strangeout != 0 ) - fprintf(stderr,">>>>>>>>>>>>> %s DUST ht.%d strangout.%d notmatched.%d <<<<<<<<<\n",ASSETCHAINS_SYMBOL,height,strangeout,notmatched); - return(-1); + if ( (checktoshis= komodo_checkcommission((CBlock *)&block,height)) < 0 ) + return(-1); + } + else + { + if ( overflow != 0 || total > checktoshis || strangeout != 0 ) + { + if ( strangeout != 0 ) + fprintf(stderr,">>>>>>>>>>>>> %s DUST ht.%d strangout.%d notmatched.%d <<<<<<<<<\n",ASSETCHAINS_SYMBOL,height,strangeout,notmatched); + return(-1); + } } } return(0); diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 9aadae598..4711a9afc 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -393,7 +393,7 @@ struct notarized_checkpoint *komodo_npptr_for_height(int32_t height, int *idx) { *idx = i; np = &sp->NPOINTS[i]; - if ( np->MoMdepth > 0 && height > np->notarized_height-np->MoMdepth && height <= np->notarized_height ) + if ( np->MoMdepth != 0 && height > np->notarized_height-(np->MoMdepth&0xffff) && height <= np->notarized_height ) return(np); } } @@ -464,7 +464,7 @@ int32_t komodo_MoMdata(int32_t *notarized_htp,uint256 *MoMp,uint256 *kmdtxidp,in *MoMoMdepthp = np->MoMoMdepth; *kmdstartip = np->kmdstarti; *kmdendip = np->kmdendi; - return(np->MoMdepth); + return(np->MoMdepth & 0xffff); } *notarized_htp = *MoMoMoffsetp = *MoMoMdepthp = *kmdstartip = *kmdendip = 0; memset(MoMp,0,sizeof(*MoMp)); diff --git a/src/komodo_port.c b/src/komodo_port.c index e92da3af1..991be2013 100644 --- a/src/komodo_port.c +++ b/src/komodo_port.c @@ -809,7 +809,7 @@ uint16_t komodo_calcport(char *name,uint64_t supply,uint64_t endsubsidy,uint64_t decay = 0; printf("decay cant be more than 100000000\n"); } - if ( endsubsidy != 0 || reward != 0 || halving != 0 || decay != 0 || commission != 0 || cc != 0 || staked != 0 ) + if ( endsubsidy != 0 || reward != 0 || halving != 0 || decay != 0 || commission != 0 || cc != 0 || staked != 0 || ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 ) { //printf("end.%llu reward.%llu halving.%llu decay.%llu perc.%llu\n",(long long)endsubsidy,(long long)reward,(long long)halving,(long long)decay,(long long)commission); extraptr = extrabuf; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 36766a1f7..119c4d6f4 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1559,7 +1559,7 @@ void komodo_args(char *argv0) ASSETCHAINS_DECAY = 0; printf("ASSETCHAINS_DECAY cant be more than 100000000\n"); } - if ( strlen(ASSETCHAINS_OVERRIDE_PUBKEY.c_str()) == 66 && ASSETCHAINS_COMMISSION > 0 && ASSETCHAINS_COMMISSION <= 100000000 ) + if ( strlen(ASSETCHAINS_OVERRIDE_PUBKEY.c_str()) == 66 ) decode_hex(ASSETCHAINS_OVERRIDE_PUBKEY33,33,(char *)ASSETCHAINS_OVERRIDE_PUBKEY.c_str()); else if ( ASSETCHAINS_COMMISSION != 0 ) { diff --git a/src/main.cpp b/src/main.cpp index 47f9fbf3d..15fe3e5a0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5200,10 +5200,11 @@ void static CheckBlockIndex() // Build forward-pointing map of the entire block tree. std::multimap forward; for (BlockMap::iterator it = mapBlockIndex.begin(); it != mapBlockIndex.end(); it++) { - forward.insert(std::make_pair(it->second->pprev, it->second)); + if ( it->second != 0 ) + forward.insert(std::make_pair(it->second->pprev, it->second)); } - - assert(forward.size() == mapBlockIndex.size()); + if ( Params().NetworkIDString() != "regtest" ) + assert(forward.size() == mapBlockIndex.size()); std::pair::iterator,std::multimap::iterator> rangeGenesis = forward.equal_range(NULL); CBlockIndex *pindex = rangeGenesis.first->second; diff --git a/src/miner.cpp b/src/miner.cpp index 34ade493e..c7422a458 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -109,7 +109,8 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, extern int32_t ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE,KOMODO_PASSPORT_INITDONE; extern uint64_t ASSETCHAINS_REWARD,ASSETCHAINS_COMMISSION,ASSETCHAINS_STAKED; extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; -extern std::string NOTARY_PUBKEY; +extern std::string NOTARY_PUBKEY,ASSETCHAINS_OVERRIDE_PUBKEY; + extern uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33]; uint32_t Mining_start,Mining_height; int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,uint32_t timestamp); @@ -447,7 +448,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) txNew.vin[0].scriptSig = CScript() << nHeight << OP_0; pblock->vtx[0] = txNew; - if ( ASSETCHAINS_SYMBOL[0] != 0 && ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 && ASSETCHAINS_COMMISSION != 0 && (commission= komodo_commission((CBlock*)&pblocktemplate->block)) != 0 ) + if ( nHeight > 1 && ASSETCHAINS_SYMBOL[0] != 0 && ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 && ASSETCHAINS_COMMISSION != 0 && (commission= komodo_commission((CBlock*)&pblocktemplate->block)) != 0 ) { int32_t i; uint8_t *ptr; txNew.vout.resize(2); @@ -486,11 +487,13 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) pblock->nTime = pindexPrev->nTime + 65; if ( komodo_notaryvin(txNotary,NOTARY_PUBKEY33) > 0 ) { - CAmount txfees = 0; + CAmount txfees = 5000; pblock->vtx.push_back(txNotary); pblocktemplate->vTxFees.push_back(txfees); pblocktemplate->vTxSigOps.push_back(GetLegacySigOpCount(txNotary)); nFees += txfees; + pblocktemplate->vTxFees[0] = -nFees; + //*(uint64_t *)(&pblock->vtx[0].vout[0].nValue) += txfees; //fprintf(stderr,"added notaryvin\n"); } else @@ -590,10 +593,14 @@ void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& // Internal miner // -CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey) +CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey,int32_t nHeight) { CPubKey pubkey; CScript scriptPubKey; uint8_t *script,*ptr; int32_t i; - if ( USE_EXTERNAL_PUBKEY != 0 ) + if ( nHeight == 1 && ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 ) + { + scriptPubKey = CScript() << ParseHex(ASSETCHAINS_OVERRIDE_PUBKEY) << OP_CHECKSIG; + } + else if ( USE_EXTERNAL_PUBKEY != 0 ) { //fprintf(stderr,"use notary pubkey\n"); scriptPubKey = CScript() << ParseHex(NOTARY_PUBKEY) << OP_CHECKSIG; @@ -795,7 +802,7 @@ void static BitcoinMiner() sleep(3); } #ifdef ENABLE_WALLET - CBlockTemplate *ptr = CreateNewBlockWithKey(reservekey); + CBlockTemplate *ptr = CreateNewBlockWithKey(reservekey,pindexPrev->nHeight+1); #else CBlockTemplate *ptr = CreateNewBlockWithKey(); #endif diff --git a/src/miner.h b/src/miner.h index bf1a088f0..684b10187 100644 --- a/src/miner.h +++ b/src/miner.h @@ -30,7 +30,7 @@ struct CBlockTemplate CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn); #ifdef ENABLE_WALLET boost::optional GetMinerScriptPubKey(CReserveKey& reservekey); -CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey); +CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey,int32_t nHeight); #else boost::optional GetMinerScriptPubKey(); CBlockTemplate* CreateNewBlockWithKey(); diff --git a/src/pow.cpp b/src/pow.cpp index 817dcc1fe..e942883f2 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -86,6 +86,8 @@ bool CheckEquihashSolution(const CBlockHeader *pblock, const CChainParams& param unsigned int n = params.EquihashN(); unsigned int k = params.EquihashK(); + if ( Params().NetworkIDString() == "regtest" ) + return(true); // Hash state crypto_generichash_blake2b_state state; EhInitialiseState(n, k, state); diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index bd9c45f5d..e3341144a 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -214,7 +214,7 @@ UniValue generate(const UniValue& params, bool fHelp) lastTime = GetTime(); #ifdef ENABLE_WALLET - std::unique_ptr pblocktemplate(CreateNewBlockWithKey(reservekey)); + std::unique_ptr pblocktemplate(CreateNewBlockWithKey(reservekey,nHeight)); #else std::unique_ptr pblocktemplate(CreateNewBlockWithKey()); #endif @@ -639,7 +639,7 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) } #ifdef ENABLE_WALLET CReserveKey reservekey(pwalletMain); - pblocktemplate = CreateNewBlockWithKey(reservekey); + pblocktemplate = CreateNewBlockWithKey(reservekey,chainActive.Tip()->nHeight+1); #else pblocktemplate = CreateNewBlockWithKey(); #endif diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 70a5488f8..0b3b45a80 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -2696,6 +2696,7 @@ UniValue listunspent(const UniValue& params, bool fHelp) uint64_t komodo_interestsum() { +#ifdef ENABLE_WALLET uint64_t interest,sum = 0; int32_t txheight; uint32_t locktime; vector vecOutputs; assert(pwalletMain != NULL); @@ -2719,6 +2720,9 @@ uint64_t komodo_interestsum() KOMODO_INTERESTSUM = sum; KOMODO_WALLETBALANCE = pwalletMain->GetBalance(); return(sum); +#else + return(0); +#endif } UniValue fundrawtransaction(const UniValue& params, bool fHelp) @@ -4519,7 +4523,7 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) txNew.vin.resize(1); txNew.vout.resize(1); - txfee = utxovalue / 2;; + txfee = utxovalue / 2; //for (i=0; i<32; i++) // ((uint8_t *)&revtxid)[i] = ((uint8_t *)&utxotxid)[31 - i]; txNew.vin[0].prevout.hash = utxotxid; //revtxid;