diff --git a/src/assetchains.json b/src/assetchains.json index ca661f441..6451db701 100644 --- a/src/assetchains.json +++ b/src/assetchains.json @@ -188,6 +188,18 @@ ] }, { + "ac_name": "KMDICE", + "ac_supply": "10500000", + "ac_reward": "2500000000", + "ac_halving": "210000", + "ac_cc": "2", + "addressindex": "1", + "spentindex": "1", + "addnode": [ + "144.76.217.232" + ] + }, + { "ac_name": "ZEX", "ac_founders": "1", "ac_reward": "13000000000", diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 2340ff58b..52664023f 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -98,7 +98,7 @@ What is needed is for the dealer node to track the entropy tx that was already b #include "../compat/endian.h" #define MAX_ENTROPYUSED 8192 -#define DICE_MINUTXOS 7777 +#define DICE_MINUTXOS 10000 extern int32_t KOMODO_INSYNC; pthread_mutex_t DICE_MUTEX,DICEREVEALED_MUTEX; @@ -394,18 +394,28 @@ void *dicefinish(void *_ptr) fprintf(stderr,"send refund!\n"); mySenddicetransaction(ptr->rawtx,ptr->entropyused,ptr->entropyvout,ptr->bettxid,ptr->betTx,ptr->funcid,ptr); } + dicefinish_delete(ptr); continue; } } if ( ptr->bettxid_ready != 0 ) { - if ( newblock != 0 && ptr->txid != zeroid ) + if ( now > ptr->bettxid_ready + 2*3600 ) { - CCduration(numblocks,ptr->txid); - //fprintf(stderr,"duration finish txid.%s\n",ptr->txid.GetHex().c_str()); - if ( numblocks == 0 ) - mySenddicetransaction(ptr->rawtx,ptr->entropyused,ptr->entropyvout,ptr->bettxid,ptr->betTx,ptr->funcid,ptr); - else continue; + fprintf(stderr,"purge bettxid_ready %s\n",ptr->bettxid.GetHex().c_str()); + dicefinish_delete(ptr); + continue; + } + else if ( newblock != 0 ) + { + if ( ptr->txid != zeroid ) + { + CCduration(numblocks,ptr->txid); + //fprintf(stderr,"duration finish txid.%s\n",ptr->txid.GetHex().c_str()); + if ( numblocks == 0 ) + mySenddicetransaction(ptr->rawtx,ptr->entropyused,ptr->entropyvout,ptr->bettxid,ptr->betTx,ptr->funcid,ptr); + else continue; + } } if ( ptr->txid == zeroid ) vin0_needed++; @@ -418,7 +428,7 @@ void *dicefinish(void *_ptr) utxos = (struct dicefinish_utxo *)calloc(vin0_needed,sizeof(*utxos)); if ( (n= dicefinish_utxosget(num,utxos,vin0_needed,coinaddr)) > 0 ) { - fprintf(stderr,"iter.%d vin0_needed.%d got %d, num 0.0002 %d\n",iter,vin0_needed,n,num); + //fprintf(stderr,"iter.%d vin0_needed.%d got %d, num 0.0002 %d\n",iter,vin0_needed,n,num); m = 0; DL_FOREACH_SAFE(DICEFINISH_LIST,ptr,tmp) { @@ -472,61 +482,7 @@ void *dicefinish(void *_ptr) } } } - else if ( 0 && newblock != 0 ) - dicefinish_utxosget(num,0,0,coinaddr); free(utxos); - if ( 0 && newblock != 0 && num < DICE_MINUTXOS ) - { - char *cmd = (char *)malloc(100 * 128); - sprintf(cmd,"./komodo-cli -ac_name=%s sendmany \"\" \"{\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002}\"",ASSETCHAINS_SYMBOL,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr); - n = sqrt((DICE_MINUTXOS - num) / 100)*2 + 1; - fprintf(stderr,"num normal 0.0002 utxos.%d < %d -> n.%d\n",num,DICE_MINUTXOS,n); - for (i=0; i 64 && is_hexstr((char *)res.c_str(),0) > 64 ) - { - if ( DecodeHexTx(tx,res) != 0 ) - { - //LOCK(cs_main); - if ( myAddtomempool(tx) != 0 ) - { - fprintf(stderr,"ENTROPY %s: %d of %d, %d\n",tx.GetHash().GetHex().c_str(),i,n,DICE_MINUTXOS - entropytxs); - RelayTransaction(tx); - } else break; - } else break; - } else break; - } - } - } - } } } if ( (newht= KOMODO_INSYNC) == 0 || newht == lastheight ) @@ -1116,11 +1072,12 @@ uint64_t AddDiceInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubK unstringbits(sstr,sbits); if ( sbits == refsbits && (funcid == 'F' && reffundingtxid == txid) || reffundingtxid == fundingtxid ) { - if ( funcid == 'F' || funcid == 'E' || funcid == 'W' || funcid == 'L' || funcid == 'T' ) + if ( funcid == 'R' || funcid == 'F' || funcid == 'E' || funcid == 'W' || funcid == 'L' || funcid == 'T' ) { if ( total != 0 && maxinputs != 0 ) { - fprintf(stderr,"use (%c) %.8f %s %s/v%d\n",funcid,(double)tx.vout[0].nValue/COIN,sstr,uint256_str(str,txid),vout); + if ( funcid == 'R' ) + fprintf(stderr,">>>>>>>>>>>> use (%c) %.8f %s %s/v%d\n",funcid,(double)tx.vout[0].nValue/COIN,sstr,uint256_str(str,txid),vout); mtx.vin.push_back(CTxIn(txid,vout,CScript())); } totalinputs += it->second.satoshis; @@ -1177,7 +1134,7 @@ int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbit if ( (funcid == 'F' && reffundingtxid == txid) || reffundingtxid == fundingtxid ) { //fprintf(stderr,"%d: %s/v%d (%c %.8f) %.8f %.8f\n",n,uint256_str(str,txid),vout,funcid,(double)it->second.satoshis/COIN,(double)totalinputs/COIN,(double)sum/COIN); - if ( (nValue= IsDicevout(cp,tx,vout,refsbits,reffundingtxid)) >= 10000 && (funcid == 'F' || funcid == 'E' || funcid == 'W' || funcid == 'L' || funcid == 'T') ) + if ( (nValue= IsDicevout(cp,tx,vout,refsbits,reffundingtxid)) >= 10000 && (funcid == 'R' || funcid == 'F' || funcid == 'E' || funcid == 'W' || funcid == 'L' || funcid == 'T') ) { if ( funcid == 'L' || funcid == 'W' || funcid == 'E' ) n++; @@ -1241,7 +1198,7 @@ int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbit } } } - else if ( funcid != 'B' ) + else if ( 0 && funcid != 'B' ) fprintf(stderr,"%s %c refsbits.%llx sbits.%llx nValue %.8f\n",uint256_str(str,txid),funcid,(long long)refsbits,(long long)sbits,(double)nValue/COIN); } //else fprintf(stderr,"else case funcid (%c) %d %s vs %s\n",funcid,funcid,uint256_str(str,reffundingtxid),uint256_str(str2,fundingtxid)); } //else fprintf(stderr,"funcid.%d %c skipped %.8f\n",funcid,funcid,(double)tx.vout[vout].nValue/COIN); @@ -1577,7 +1534,8 @@ std::string DiceBetFinish(uint8_t &funcid,uint256 &entropyused,int32_t &entropyv mtx.vin.push_back(CTxIn(bettxid,0,CScript())); mtx.vin.push_back(CTxIn(bettxid,1,CScript())); funcid = 'R'; - mtx.vout.push_back(CTxOut(betTx.vout[0].nValue,fundingPubKey)); + mtx.vout.push_back(MakeCC1vout(cp->evalcode,betTx.vout[0].nValue,dicepk)); + //mtx.vout.push_back(CTxOut(betTx.vout[0].nValue,fundingPubKey)); mtx.vout.push_back(CTxOut(txfee,fundingPubKey)); mtx.vout.push_back(CTxOut(betTx.vout[1].nValue,betTx.vout[2].scriptPubKey)); *resultp = 1; @@ -1677,8 +1635,71 @@ std::string DiceBetFinish(uint8_t &funcid,uint256 &entropyused,int32_t &entropyv return("couldnt find bettx or entropytx"); } +static uint256 dealer0_fundingtxid; +void *dealer0_loop(void *_arg) +{ + char *planstr = (char *)_arg; + CTransaction tx; CPubKey mypk,dicepk; uint64_t entropyval; uint256 entropytxid; int32_t entropytxs,i,n,num; CScript fundingPubKey; struct CCcontract_info *cp,C; char coinaddr[64]; std::string res; int64_t minbet,maxbet,maxodds,timeoutblocks; uint64_t refsbits,txfee = 10000; + if ( (cp= Diceinit(fundingPubKey,dealer0_fundingtxid,&C,planstr,txfee,mypk,dicepk,refsbits,minbet,maxbet,maxodds,timeoutblocks)) == 0 ) + { + fprintf(stderr,"error initializing dealer0_loop\n"); + exit(-1); + } + fprintf(stderr,"dealer0 node running\n"); + while ( 1 ) + { + DicePlanFunds(entropyval,entropytxid,refsbits,cp,dicepk,dealer0_fundingtxid,entropytxs,false); + if ( entropytxs < DICE_MINUTXOS ) + { + n = sqrt(DICE_MINUTXOS - entropytxs) + 10; + for (i=0; i 64 && is_hexstr((char *)res.c_str(),0) > 64 ) + { + if ( DecodeHexTx(tx,res) != 0 ) + { + LOCK(cs_main); + if ( myAddtomempool(tx) != 0 ) + { + fprintf(stderr,"ENTROPY %s: %d of %d, %d\n",tx.GetHash().GetHex().c_str(),i,n,DICE_MINUTXOS - entropytxs); + RelayTransaction(tx); + } else break; + } else break; + } else break; + } + } + pubkey2addr(coinaddr,Mypubkey().data()); + dicefinish_utxosget(num,0,0,coinaddr); + fprintf(stderr,"have %d 0.0002 utxos, need %d\n",num,DICE_MINUTXOS); + if ( num < DICE_MINUTXOS ) // this deadlocks, need to put it in a different thread + { + char *cmd = (char *)malloc(100 * 128); + sprintf(cmd,"./komodo-cli -ac_name=%s sendmany \"\" \"{\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002}\"",ASSETCHAINS_SYMBOL,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr); + n = sqrt((DICE_MINUTXOS - num) / 100)*2 + 1; + fprintf(stderr,"num normal 0.0002 utxos.%d < %d -> n.%d\n",num,DICE_MINUTXOS,n); + for (i=0; i 64 && is_hexstr((char *)res.c_str(),0) > 64 ) - { - if ( DecodeHexTx(tx,res) != 0 ) - { - //LOCK(cs_main); - if ( myAddtomempool(tx) != 0 ) - { - fprintf(stderr,"ENTROPY %s: %d of %d, %d\n",tx.GetHash().GetHex().c_str(),i,n,DICE_MINUTXOS - entropytxs); - RelayTransaction(tx); - } else break; - } else break; - } else break; - } - } - pubkey2addr(coinaddr,Mypubkey().data()); - dicefinish_utxosget(num,0,0,coinaddr); - fprintf(stderr,"have %d 0.0002 utxos, need %d\n",num,DICE_MINUTXOS); - if ( 0 && num < DICE_MINUTXOS ) // this deadlocks, need to put it in a different thread - { - char *cmd = (char *)malloc(100 * 128); - sprintf(cmd,"./komodo-cli -ac_name=%s sendmany \"\" \"{\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002}\"",ASSETCHAINS_SYMBOL,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr); - n = sqrt((DICE_MINUTXOS - num) / 100)*2 + 1; - fprintf(stderr,"num normal 0.0002 utxos.%d < %d -> n.%d\n",num,DICE_MINUTXOS,n); - for (i=0; i 1 ) { - fprintf(stderr,"end.%llu blocks, reward %.8f halving.%llu blocks, decay.%llu perc %.4f%% ac_pub=[%02x...]\n",(long long)ASSETCHAINS_ENDSUBSIDY,dstr(ASSETCHAINS_REWARD),(long long)ASSETCHAINS_HALVING,(long long)ASSETCHAINS_DECAY,dstr(ASSETCHAINS_COMMISSION)*100,ASSETCHAINS_OVERRIDE_PUBKEY33[0]); + fprintf(stderr,"end.%llu blocks, reward %.8f halving.%llu blocks, decay.%llu perc %.4f%% ac_pub=[%02x%02x%02x...]\n",(long long)ASSETCHAINS_ENDSUBSIDY,dstr(ASSETCHAINS_REWARD),(long long)ASSETCHAINS_HALVING,(long long)ASSETCHAINS_DECAY,dstr(ASSETCHAINS_COMMISSION)*100,ASSETCHAINS_OVERRIDE_PUBKEY33[0],ASSETCHAINS_OVERRIDE_PUBKEY33[1],ASSETCHAINS_OVERRIDE_PUBKEY33[2]); extraptr = extrabuf; memcpy(extraptr,ASSETCHAINS_OVERRIDE_PUBKEY33,33), extralen = 33; extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_ENDSUBSIDY),(void *)&ASSETCHAINS_ENDSUBSIDY); @@ -1746,6 +1746,8 @@ void komodo_args(char *argv0) dpowconfs = 0; } else BITCOIND_RPCPORT = GetArg("-rpcport", BaseParams().RPCPort()); KOMODO_DPOWCONFS = GetArg("-dpowconfs",dpowconfs); + if ( ASSETCHAINS_SYMBOL[0] == 0 || strcmp(ASSETCHAINS_SYMBOL,"SUPERNET") == 0 || strcmp(ASSETCHAINS_SYMBOL,"DEX") == 0 || strcmp(ASSETCHAINS_SYMBOL,"COQUI") == 0 || strcmp(ASSETCHAINS_SYMBOL,"PIRATE") == 0 ) + KOMODO_EXTRASATOSHI = 1; } void komodo_nameset(char *symbol,char *dest,char *source) diff --git a/src/main.cpp b/src/main.cpp index 64d48d7ae..4ebe7790e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -56,7 +56,7 @@ using namespace std; CCriticalSection cs_main; extern uint8_t NOTARY_PUBKEY33[33]; -extern int32_t KOMODO_LOADINGBLOCKS,KOMODO_LONGESTCHAIN,KOMODO_INSYNC,KOMODO_CONNECTING; +extern int32_t KOMODO_LOADINGBLOCKS,KOMODO_LONGESTCHAIN,KOMODO_INSYNC,KOMODO_CONNECTING,KOMODO_EXTRASATOSHI; int32_t KOMODO_NEWBLOCKS; int32_t komodo_block2pubkey33(uint8_t *pubkey33,CBlock *block); void komodo_broadcast(CBlock *pblock,int32_t limit); @@ -3137,7 +3137,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin else fprintf(stderr,"checktoshis %.8f numvouts %d\n",dstr(checktoshis),(int32_t)block.vtx[0].vout.size()); } } - if ( block.vtx[0].GetValueOut() > blockReward+1 ) + if ( block.vtx[0].GetValueOut() > blockReward+KOMODO_EXTRASATOSHI ) { if ( ASSETCHAINS_SYMBOL[0] != 0 || pindex->nHeight >= KOMODO_NOTARIES_HEIGHT1 || block.vtx[0].vout[0].nValue > blockReward ) { diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 1d3ff6a1e..20696bd11 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5336,7 +5336,7 @@ UniValue rewardscreatefunding(const UniValue& params, bool fHelp) minseconds = maxseconds = 60 * 3600 * 24; mindeposit = 100 * COIN; name = (char *)params[0].get_str().c_str(); - funds = atof(params[1].get_str().c_str()) * COIN; + funds = atof(params[1].get_str().c_str()) * COIN + 0.00000000499999; if (!VALID_PLAN_NAME(name)) { ERR_RESULT(strprintf("Plan name can be at most %d ASCII characters",PLAN_NAME_MAX)); @@ -5374,7 +5374,7 @@ UniValue rewardscreatefunding(const UniValue& params, bool fHelp) return result; } if ( params.size() > 5 ) - mindeposit = atof(params[5].get_str().c_str()) * COIN; + mindeposit = atof(params[5].get_str().c_str()) * COIN + 0.00000000499999; if ( mindeposit <= 0 ) { ERR_RESULT("mindeposit must be positive"); return result; @@ -5402,7 +5402,7 @@ UniValue rewardslock(const UniValue& params, bool fHelp) LOCK2(cs_main, pwalletMain->cs_wallet); name = (char *)params[0].get_str().c_str(); fundingtxid = Parseuint256((char *)params[1].get_str().c_str()); - amount = atof(params[2].get_str().c_str()) * COIN; + amount = atof(params[2].get_str().c_str()) * COIN + 0.00000000499999; hex = RewardsLock(0,name,fundingtxid,amount); if (!VALID_PLAN_NAME(name)) { @@ -5432,7 +5432,7 @@ UniValue rewardsaddfunding(const UniValue& params, bool fHelp) LOCK2(cs_main, pwalletMain->cs_wallet); name = (char *)params[0].get_str().c_str(); fundingtxid = Parseuint256((char *)params[1].get_str().c_str()); - amount = atof(params[2].get_str().c_str()) * COIN; + amount = atof(params[2].get_str().c_str()) * COIN + 0.00000000499999; hex = RewardsAddfunding(0,name,fundingtxid,amount); if (!VALID_PLAN_NAME(name)) { @@ -5575,7 +5575,7 @@ UniValue gatewaysdeposit(const UniValue& params, bool fHelp) deposithex = params[5].get_str(); proof = ParseHex(params[6].get_str()); destpub = ParseHex(params[7].get_str()); - amount = atof((char *)params[8].get_str().c_str()) * COIN; + amount = atof((char *)params[8].get_str().c_str()) * COIN + 0.00000000499999; if ( amount <= 0 || claimvout < 0 ) throw runtime_error("invalid param: amount, numpks or claimvout\n"); hex = GatewaysDeposit(0,bindtxid,height,coin,cointxid,claimvout,deposithex,proof,pubkey2pk(destpub),amount); @@ -5600,7 +5600,7 @@ UniValue gatewaysclaim(const UniValue& params, bool fHelp) coin = params[1].get_str(); deposittxid = Parseuint256((char *)params[2].get_str().c_str()); destpub = ParseHex(params[3].get_str()); - amount = atof((char *)params[4].get_str().c_str()) * COIN; + amount = atof((char *)params[4].get_str().c_str()) * COIN + 0.00000000499999; hex = GatewaysClaim(0,bindtxid,coin,deposittxid,pubkey2pk(destpub),amount); if ( hex.size() > 0 ) { @@ -5622,7 +5622,7 @@ UniValue gatewayswithdraw(const UniValue& params, bool fHelp) bindtxid = Parseuint256((char *)params[0].get_str().c_str()); coin = params[1].get_str(); withdrawpub = ParseHex(params[2].get_str()); - amount = atof((char *)params[3].get_str().c_str()) * COIN; + amount = atof((char *)params[3].get_str().c_str()) * COIN + 0.00000000499999; hex = GatewaysWithdraw(0,bindtxid,coin,pubkey2pk(withdrawpub),amount); if ( hex.size() > 0 ) { @@ -5730,7 +5730,7 @@ UniValue oraclesregister(const UniValue& params, bool fHelp) LOCK2(cs_main, pwalletMain->cs_wallet); txid = Parseuint256((char *)params[0].get_str().c_str()); if ( (datafee= atol((char *)params[1].get_str().c_str())) == 0 ) - datafee = atof((char *)params[1].get_str().c_str()) * COIN; + datafee = atof((char *)params[1].get_str().c_str()) * COIN + 0.00000000499999; hex = OracleRegister(0,txid,datafee); if ( hex.size() > 0 ) { @@ -5751,7 +5751,7 @@ UniValue oraclessubscribe(const UniValue& params, bool fHelp) LOCK2(cs_main, pwalletMain->cs_wallet); txid = Parseuint256((char *)params[0].get_str().c_str()); pubkey = ParseHex(params[1].get_str().c_str()); - amount = atof((char *)params[2].get_str().c_str()) * COIN; + amount = atof((char *)params[2].get_str().c_str()) * COIN + 0.00000000499999; hex = OracleSubscribe(0,txid,pubkey2pk(pubkey),amount); if ( hex.size() > 0 ) { @@ -5908,7 +5908,7 @@ UniValue faucetfund(const UniValue& params, bool fHelp) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); - funds = atof(params[0].get_str().c_str()) * COIN; + funds = atof(params[0].get_str().c_str()) * COIN + 0.00000000499999; if (funds > 0) { hex = FaucetFund(0,(uint64_t) funds); if ( hex.size() > 0 ) @@ -5973,7 +5973,7 @@ UniValue pricescreate(const UniValue& params, bool fHelp) longtoken = Parseuint256((char *)params[4].get_str().c_str()); shorttoken = Parseuint256((char *)params[5].get_str().c_str()); maxleverage = atol(params[6].get_str().c_str()); - funding = atof(params[7].get_str().c_str()) * COIN; + funding = atof(params[7].get_str().c_str()) * COIN + 0.00000000499999; n = atoi(params[8].get_str().c_str()); if ( n > 0 ) { @@ -6009,7 +6009,7 @@ UniValue pricesaddfunding(const UniValue& params, bool fHelp) LOCK2(cs_main, pwalletMain->cs_wallet); fundingtxid = Parseuint256((char *)params[0].get_str().c_str()); bettoken = Parseuint256((char *)params[1].get_str().c_str()); - amount = atof(params[2].get_str().c_str()) * COIN; + amount = atof(params[2].get_str().c_str()) * COIN + 0.00000000499999; hex = PricesAddFunding(0,bettoken,fundingtxid,amount); if ( hex.size() > 0 ) { @@ -6034,7 +6034,7 @@ UniValue pricesbet(const UniValue& params, bool fHelp) LOCK2(cs_main, pwalletMain->cs_wallet); fundingtxid = Parseuint256((char *)params[0].get_str().c_str()); bettoken = Parseuint256((char *)params[1].get_str().c_str()); - amount = atof(params[2].get_str().c_str()) * COIN; + amount = atof(params[2].get_str().c_str()) * COIN + 0.00000000499999; leverage = atoi(params[3].get_str().c_str()); hex = PricesBet(0,bettoken,fundingtxid,amount,leverage); if ( hex.size() > 0 ) @@ -6097,9 +6097,9 @@ UniValue dicefund(const UniValue& params, bool fHelp) const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); name = (char *)params[0].get_str().c_str(); - funds = atof(params[1].get_str().c_str()) * COIN; - minbet = atof(params[2].get_str().c_str()) * COIN; - maxbet = atof(params[3].get_str().c_str()) * COIN; + funds = atof(params[1].get_str().c_str()) * COIN + 0.00000000499999; + minbet = atof(params[2].get_str().c_str()) * COIN + 0.00000000499999; + maxbet = atof(params[3].get_str().c_str()) * COIN + 0.00000000499999; maxodds = atol(params[4].get_str().c_str()); timeoutblocks = atol(params[5].get_str().c_str()); @@ -6131,7 +6131,7 @@ UniValue diceaddfunds(const UniValue& params, bool fHelp) LOCK2(cs_main, pwalletMain->cs_wallet); name = (char *)params[0].get_str().c_str(); fundingtxid = Parseuint256((char *)params[1].get_str().c_str()); - amount = atof(params[2].get_str().c_str()) * COIN; + amount = atof(params[2].get_str().c_str()) * COIN + 0.00000000499999; if (!VALID_PLAN_NAME(name)) { ERR_RESULT(strprintf("Plan name can be at most %d ASCII characters",PLAN_NAME_MAX)); return(result); @@ -6159,7 +6159,7 @@ UniValue dicebet(const UniValue& params, bool fHelp) LOCK2(cs_main, pwalletMain->cs_wallet); name = (char *)params[0].get_str().c_str(); fundingtxid = Parseuint256((char *)params[1].get_str().c_str()); - amount = atof(params[2].get_str().c_str()) * COIN; + amount = atof(params[2].get_str().c_str()) * COIN + 0.00000000499999; odds = atol(params[3].get_str().c_str()); if (!VALID_PLAN_NAME(name)) { @@ -6348,7 +6348,7 @@ UniValue tokencreate(const UniValue& params, bool fHelp) const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); name = params[0].get_str(); - supply = atof(params[1].get_str().c_str()) * COIN; + supply = atof(params[1].get_str().c_str()) * COIN + 0.00000000499999; if ( name.size() == 0 || name.size() > 32) { ERR_RESULT("Token name must not be empty and up to 32 characters");