diff --git a/README.md b/README.md index 0f112982d..d0bc3cf52 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ Komodo is based on Zcash and has been extended by our innovative consensus algor ```shell #The following packages are needed: -sudo apt-get install build-essential pkg-config libc6-dev m4 g++-multilib autoconf libtool ncurses-dev unzip git python python-zmq zlib1g-dev wget libcurl4-gnutls-dev bsdmainutils automake curl +sudo apt-get install build-essential pkg-config libc6-dev m4 g++-multilib autoconf libtool ncurses-dev unzip git python python-zmq zlib1g-dev wget libcurl4-gnutls-dev bsdmainutils automake curl libboost-dev ``` ### Build Komodo diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index b01a3bf1d..4841eb981 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -3276,7 +3276,7 @@ UniValue dilithium_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params } else return(cclib_error(result,"need to have exactly 2 params sendtxid, scriptPubKey")); } -int64_t dilithium_inputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,uint256 pubtxid,int64_t total,int32_t maxinputs,char *cmpaddr) +int64_t dilithium_inputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,uint256 destpubtxid,int64_t total,int32_t maxinputs,char *cmpaddr) { char coinaddr[64]; int64_t threshold,nValue,price,totalinputs = 0; uint256 checktxid,txid,hashBlock; std::vector origpubkey,tmpsig; CTransaction vintx; int32_t vout,numvouts,n = 0; std::vector voutpubtxids; std::vector > unspentOutputs; @@ -3294,7 +3294,7 @@ int64_t dilithium_inputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPu { if ( (nValue= IsCClibvout(cp,vintx,vout,cmpaddr)) > DILITHIUM_TXFEE && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 ) { - if ( (dilithium_Qsendopretdecode(checktxid,tmpsig,voutpubtxids,vintx.vout[numvouts-1].scriptPubKey) == 'Q' || dilithium_sendopretdecode(checktxid,vintx.vout[numvouts-1].scriptPubKey) == 'x') && desttxid == checktxid ) + if ( (dilithium_Qsendopretdecode(checktxid,tmpsig,voutpubtxids,vintx.vout[numvouts-1].scriptPubKey) == 'Q' || dilithium_sendopretdecode(checktxid,vintx.vout[numvouts-1].scriptPubKey) == 'x') && destpubtxid == checktxid ) { if ( total != 0 && maxinputs != 0 ) mtx.vin.push_back(CTxIn(txid,vout,CScript())); diff --git a/src/cc/makerogue b/src/cc/makerogue index 51caef6e2..f1f1452c0 100755 --- a/src/cc/makerogue +++ b/src/cc/makerogue @@ -1,5 +1,6 @@ #!/bin/sh cd rogue; +make clean; if [ "$HOST" = "x86_64-w64-mingw32" ]; then echo building rogue.exe... diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 6cc51e04b..90045f083 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -118,22 +118,22 @@ int32_t roguefname(char *fname,uint64_t seed,int32_t counter) return(0); } -#ifdef test -int32_t flushkeystrokes(struct rogue_state *rs,int32_t waitflag) +int32_t flushkeystrokes_local(struct rogue_state *rs,int32_t waitflag) { +#ifndef BUILD_ROGUE char fname[1024]; FILE *fp; int32_t i,retflag = -1; + rs->counter++; roguefname(fname,rs->seed,rs->counter); if ( (fp= fopen(fname,"wb")) != 0 ) { if ( fwrite(rs->buffered,1,rs->num,fp) == rs->num ) { - rs->counter++; rs->num = 0; retflag = 0; fclose(fp); if ( (fp= fopen("savefile","wb")) != 0 ) { - save_file(rs,fp,0); + //save_file(rs,fp,0); if ( 0 && (fp= fopen("savefile","rb")) != 0 ) { for (i=0; i<0x150; i++) @@ -149,8 +149,10 @@ int32_t flushkeystrokes(struct rogue_state *rs,int32_t waitflag) } else fprintf(stderr,"error writing (%s)\n",fname); } else fprintf(stderr,"error creating (%s)\n",fname); return(retflag); -} #else + return(0); +#endif +} #ifdef BUILD_ROGUE // stubs for inside daemon @@ -174,9 +176,10 @@ int32_t flushkeystrokes(struct rogue_state *rs,int32_t waitflag) //rs->keytxid = rogue_progress(rs,waitflag,rs->seed,&rs->buffered[rs->lastnum],rs->num - rs->lastnum); //rs->lastnum = rs->num; rogue_progress(rs,waitflag,rs->seed,rs->buffered,rs->num); + flushkeystrokes_local(rs,waitflag); memset(rs->buffered,0,sizeof(rs->buffered)); - rs->num = 0; - rs->counter++; + //rs->num = 0; + //rs->counter++; } return(0); } @@ -241,7 +244,6 @@ int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t nu free(rs); return(n); } -#endif long get_filesize(FILE *fp) { diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 00fe4c842..93eb22dc8 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1084,8 +1084,8 @@ int32_t rogue_playerdata_validate(int64_t *cashoutp,uint256 &playertxid,struct C if ( P.amulet != 0 ) mult *= 5; dungeonlevel = P.dungeonlevel; - if ( P.amulet != 0 && dungeonlevel < 21 ) - dungeonlevel = 21; + if ( P.amulet != 0 && dungeonlevel < 26 ) + dungeonlevel = 26; *cashoutp = (uint64_t)P.gold * P.gold * mult * dungeonlevel; if ( newdata == playerdata ) { @@ -1447,9 +1447,14 @@ UniValue rogue_setname(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) { - CScript scriptPubKey; std::vector vopret; uint8_t *script,e,f,funcid,tokentx=0; int32_t i,maxplayers,decoded=0,regslot,ind,err,dispflag,gameheight,score,numvouts; CTransaction vintx,gametx; CPubKey pk; uint256 hashBlock,gametxid,txid,tokenid,batontxid,playertxid,ptxid; int64_t buyin,cashout; std::vector playerdata,keystrokes; std::string symbol,pname; - if ( strcmp(ASSETCHAINS_SYMBOL,"ROGUE") == 0 && height < 21274 ) - return(true); + CScript scriptPubKey; std::vector vopret; uint8_t *script,e,f,funcid,tokentx=0; int32_t i,maxplayers,enabled = 0,decoded=0,regslot,ind,err,dispflag,gameheight,score,numvouts; CTransaction vintx,gametx; CPubKey pk; uint256 hashBlock,gametxid,txid,tokenid,batontxid,playertxid,ptxid; int64_t buyin,cashout; std::vector playerdata,keystrokes; std::string symbol,pname; + if ( strcmp(ASSETCHAINS_SYMBOL,"ROGUE") == 0 ) + { + if (height < 21274 ) + return(true); + else if ( height > 50000 ) + enabled = 1; + } else enabled = 1; if ( (numvouts= tx.vout.size()) > 1 ) { txid = tx.GetHash(); @@ -1549,6 +1554,8 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C strcpy(laststr,cashstr); fprintf(stderr,"%s\n",cashstr); } + if ( enabled != 0 && tx.vout[2].nValue != cashout ) + return eval->Invalid("mismatched cashout amount"); } } if ( funcid == 'Q' ) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index dbea7ba12..b846ba9d1 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -2012,10 +2012,13 @@ int64_t komodo_checkcommission(CBlock *pblock,int32_t height) { script = (uint8_t *)&pblock->vtx[0].vout[1].scriptPubKey[0]; scriptlen = (int32_t)pblock->vtx[0].vout[1].scriptPubKey.size(); - //int32_t i; - //for (i=0; ivtx[0].vout[1].nValue/COIN); + if ( 0 ) + { + int32_t i; + for (i=0; ivtx[0].vout[1].nValue/COIN); + } if ( ASSETCHAINS_SCRIPTPUB.size() > 1 ) { if ( ASSETCHAINS_SCRIPTPUB.size()/2 == scriptlen && scriptlen < sizeof(scripthex) ) @@ -2031,7 +2034,13 @@ int64_t komodo_checkcommission(CBlock *pblock,int32_t height) matched = 25; if ( matched == 0 ) { - fprintf(stderr," payment to wrong pubkey scriptlen.%d, scriptpub[%d] checktoshis.%llu\n",scriptlen,(int32_t)ASSETCHAINS_SCRIPTPUB.size()/2,(long long)checktoshis); + if ( 0 && ASSETCHAINS_SCRIPTPUB.size() > 1 ) + { + int32_t i; + for (i=0; iGetBlockPos(), GetSizeOfCompactSize(block.vtx.size())); @@ -3490,9 +3493,18 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin txdata.emplace_back(tx); + valueout = tx.GetValueOut(); + if ( KOMODO_BIT63SET(valueout) != 0 ) + return state.DoS(100, error("ConnectBlock(): GetValueOut too big"),REJECT_INVALID,"tx valueout is too big"); + prevsum = voutsum; + voutsum += valueout; + if ( KOMODO_BIT63SET(voutsum) != 0 ) + return state.DoS(100, error("ConnectBlock(): voutsum too big"),REJECT_INVALID,"tx valueout is too big"); + else if ( voutsum < prevsum ) + return state.DoS(100, error("ConnectBlock(): voutsum less after adding valueout"),REJECT_INVALID,"tx valueout is too big"); if (!tx.IsCoinBase()) { - nFees += view.GetValueIn(chainActive.LastTip()->GetHeight(),&interest,tx,chainActive.LastTip()->nTime) - tx.GetValueOut(); + nFees += view.GetValueIn(chainActive.LastTip()->GetHeight(),&interest,tx,chainActive.LastTip()->nTime) - valueout; sum += interest; std::vector vChecks;