diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index 1f893d268..b01a3bf1d 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -3276,9 +3276,9 @@ 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,int64_t total,int32_t maxinputs,char *cmpaddr) +int64_t dilithium_inputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,uint256 pubtxid,int64_t total,int32_t maxinputs,char *cmpaddr) { - char coinaddr[64]; int64_t threshold,nValue,price,totalinputs = 0; uint256 tmptxid,txid,hashBlock; std::vector origpubkey,tmpsig; CTransaction vintx; int32_t vout,numvouts,n = 0; std::vector voutpubtxids; + 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; GetCCaddress(cp,coinaddr,pk); SetCCunspents(unspentOutputs,coinaddr); @@ -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(tmptxid,tmpsig,voutpubtxids,vintx.vout[numvouts-1].scriptPubKey) == 'Q' || dilithium_sendopretdecode(tmptxid,vintx.vout[numvouts-1].scriptPubKey) == 'x' ) + if ( (dilithium_Qsendopretdecode(checktxid,tmpsig,voutpubtxids,vintx.vout[numvouts-1].scriptPubKey) == 'Q' || dilithium_sendopretdecode(checktxid,vintx.vout[numvouts-1].scriptPubKey) == 'x') && desttxid == checktxid ) { if ( total != 0 && maxinputs != 0 ) mtx.vin.push_back(CTxIn(txid,vout,CScript())); @@ -3358,7 +3358,7 @@ UniValue dilithium_Qsend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params } outputsum += amount; } - if ( (inputsum= dilithium_inputs(cp,mtx,mypk,outputsum+txfee,64,myCCaddr)) >= outputsum+txfee ) + if ( (inputsum= dilithium_inputs(cp,mtx,mypk,mypubtxid,outputsum+txfee,64,myCCaddr)) >= outputsum+txfee ) { change = (inputsum - outputsum - txfee); if ( change >= txfee ) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index cc96dfff5..508bf6040 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -593,16 +593,19 @@ int32_t rogue_playersalive(int32_t &openslots,int32_t &numplayers,uint256 gametx numplayers = openslots = 0; if ( komodo_nextheight() <= gameht+ROGUE_MAXKEYSTROKESGAP ) registration_open = 1; + fprintf(stderr,"players alive\n"); for (i=0; i ROGUE_MAXITERATIONS ) break; } + fprintf(stderr,"out of while\n"); if ( txid != zeroid ) { + fprintf(stderr,"get height of %s\n",txid.GetHex().c_str()); if ( myGetTransaction(txid,tx,hashBlock) != 0 && (pindex= komodo_blockindex(hashBlock)) != 0 ) { if ( pindex->GetHeight() <= gameht+ROGUE_MAXKEYSTROKESGAP ) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 859fada99..b94281b02 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -129,7 +129,7 @@ int32_t komodo_baseid(char *origbase) #ifndef SATOSHIDEN #define SATOSHIDEN ((uint64_t)100000000L) #endif -int64_t komodo_current_supply(uint32_t nHeight) +uint64_t komodo_current_supply(uint32_t nHeight) { uint64_t cur_money; int32_t baseid; @@ -264,5 +264,19 @@ int64_t komodo_current_supply(uint32_t nHeight) } } } - return((int64_t)(cur_money + (cur_money * ASSETCHAINS_COMMISSION))); +#define KOMODO_MAXNVALUE (((uint64_t)1 << 63) - 1) +#define KOMODO_BIT63SET(x) ((x) & ((uint64_t)1 << 63)) + + if ( KOMODO_BIT63SET(cur_money) != 0 ) + return(KOMODO_MAXNVALUE); + if ( ASSETCHAINS_COMMISSION != 0 ) + { + uint64_t newval = (cur_money + (cur_money * ASSETCHAINS_COMMISSION)); + if ( KOMODO_BIT63SET(newval) != 0 ) + return(KOMODO_MAXNVALUE); + else if ( newval < curval ) // check for underflow + return(KOMODO_MAXNVALUE); + return(newvalue) + } + return(cur_money); } diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 2fbb782ce..65114c16b 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1562,7 +1562,7 @@ char *argv0names[] = (char *)"MNZ", (char *)"MNZ", (char *)"MNZ", (char *)"MNZ", (char *)"BTCH", (char *)"BTCH", (char *)"BTCH", (char *)"BTCH" }; -int64_t komodo_max_money() +uint64_t komodo_max_money() { return komodo_current_supply(10000000); } @@ -1787,6 +1787,11 @@ void komodo_args(char *argv0) ASSETCHAINS_FOUNDERS = GetArg("-ac_founders",0);// & 1; ASSETCHAINS_FOUNDERS_REWARD = GetArg("-ac_founders_reward",0); ASSETCHAINS_SUPPLY = GetArg("-ac_supply",10); + if ( ASSETCHAINS_SUPPLY > (uint64_t)90*1000*1000000 ) + { + fprintf(stderr,"-ac_supply must be less than 90 billion\n"); + exit(0); + } ASSETCHAINS_COMMISSION = GetArg("-ac_perc",0); ASSETCHAINS_OVERRIDE_PUBKEY = GetArg("-ac_pubkey",""); ASSETCHAINS_SCRIPTPUB = GetArg("-ac_script","");