From bc3419f06d1ef275149940031b900f2c54d9c2be Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 20 Aug 2018 02:26:42 -1100 Subject: [PATCH 1/5] Revert --- src/cc/dice.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index e8d0678ce..263b644ad 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -255,9 +255,14 @@ uint64_t DiceCalc(int64_t bet,int64_t odds,int64_t minbet,int64_t maxbet,int64_t winnings = 0; if ( odds > 1 ) { + { // old way + bettor = (bettor / arith_uint256(odds)); + if ( bettor >= house ) + winnings = bet * (odds+1); + return(winnings); + } if ( odds > 9999 ) // shouldnt happen return(0); - //bettor = (bettor / arith_uint256(odds)); endiancpy(buf,(uint8_t *)&house,32); endiancpy(&buf[32],(uint8_t *)&bettor,32); vcalc_sha256(0,(uint8_t *)&_hash,buf,64); From d930ed4f2e17faf5404051738e053c7bb3fdfc13 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 20 Aug 2018 02:27:11 -1100 Subject: [PATCH 2/5] Unrevert --- src/cc/dice.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 263b644ad..b3115ab8f 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -255,6 +255,7 @@ uint64_t DiceCalc(int64_t bet,int64_t odds,int64_t minbet,int64_t maxbet,int64_t winnings = 0; if ( odds > 1 ) { + if ( 0 ) { // old way bettor = (bettor / arith_uint256(odds)); if ( bettor >= house ) From 33f4e4925cdf9d048fc92c4748a94552af940dac Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 20 Aug 2018 08:32:00 -1100 Subject: [PATCH 3/5] Fix maxodds check --- src/cc/dice.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index b3115ab8f..03529b0ed 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -855,7 +855,7 @@ UniValue DiceList() std::string DiceCreateFunding(uint64_t txfee,char *planstr,int64_t funds,int64_t minbet,int64_t maxbet,int64_t maxodds,int64_t timeoutblocks) { CMutableTransaction mtx; uint256 zero; CScript fundingPubKey; CPubKey mypk,dicepk; int64_t a,b,c,d; uint64_t sbits; struct CCcontract_info *cp,C; - if ( funds < 0 || minbet < 0 || maxbet < 0 || maxodds < 1 || timeoutblocks < 0 || timeoutblocks > 1440 ) + if ( funds < 0 || minbet < 0 || maxbet < 0 || maxodds < 1 || maxodds > 9999 || timeoutblocks < 0 || timeoutblocks > 1440 ) { fprintf(stderr,"negative parameter error\n"); return(""); @@ -877,13 +877,18 @@ std::string DiceCreateFunding(uint64_t txfee,char *planstr,int64_t funds,int64_t std::string DiceAddfunding(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t amount) { CMutableTransaction mtx; CScript fundingPubKey,scriptPubKey; uint256 entropy,hentropy; CPubKey mypk,dicepk; uint64_t sbits; struct CCcontract_info *cp,C; int64_t minbet,maxbet,maxodds,timeoutblocks; - if ( amount < 0 || maxodds < 1 || maxodds > 9999 ) + if ( amount < 0 || maxodds < 1 ) { - fprintf(stderr,"negative parameter or invalid maxodds error (limit 9999)\n"); + fprintf(stderr,"negative parameter\n"); return(""); } if ( (cp= Diceinit(fundingPubKey,fundingtxid,&C,planstr,txfee,mypk,dicepk,sbits,minbet,maxbet,maxodds,timeoutblocks)) == 0 ) return(""); + if ( maxodds > 9999 ) + { + fprintf(stderr,"maxodds.%llu error (limit 9999)\n",(long long)maxodds); + return(""); + } scriptPubKey = CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG; if ( 0 ) { From e222a19d4b9bb42a3cd0df7875b69c5fd968e003 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 20 Aug 2018 08:46:12 -1100 Subject: [PATCH 4/5] Fix maxodds check --- src/cc/dice.cpp | 7 +------ src/main.cpp | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 03529b0ed..8da052c86 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -877,18 +877,13 @@ std::string DiceCreateFunding(uint64_t txfee,char *planstr,int64_t funds,int64_t std::string DiceAddfunding(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t amount) { CMutableTransaction mtx; CScript fundingPubKey,scriptPubKey; uint256 entropy,hentropy; CPubKey mypk,dicepk; uint64_t sbits; struct CCcontract_info *cp,C; int64_t minbet,maxbet,maxodds,timeoutblocks; - if ( amount < 0 || maxodds < 1 ) + if ( amount < 0 ) { fprintf(stderr,"negative parameter\n"); return(""); } if ( (cp= Diceinit(fundingPubKey,fundingtxid,&C,planstr,txfee,mypk,dicepk,sbits,minbet,maxbet,maxodds,timeoutblocks)) == 0 ) return(""); - if ( maxodds > 9999 ) - { - fprintf(stderr,"maxodds.%llu error (limit 9999)\n",(long long)maxodds); - return(""); - } scriptPubKey = CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG; if ( 0 ) { diff --git a/src/main.cpp b/src/main.cpp index 51e53a742..47d5fb017 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4185,7 +4185,7 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C } if ( rejects == 0 || rejects == lastrejects ) break; - fprintf(stderr,"addtomempool for CC checking: n.%d rejects.%d last.%d\n",(int32_t)block.vtx.size(),rejects,lastrejects); + fprintf(stderr,"addtomempool ht.%d for CC checking: n.%d rejects.%d last.%d\n",height,(int32_t)block.vtx.size(),rejects,lastrejects); lastrejects = rejects; rejects = 0; } From 38b5d53f015a320b23853afc1d1f378495b20b36 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 20 Aug 2018 21:41:20 -1100 Subject: [PATCH 5/5] +print --- src/main.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 47d5fb017..548ce2011 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4184,7 +4184,11 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C rejects++; } if ( rejects == 0 || rejects == lastrejects ) + { + if ( lastrejects != 0 ) + fprintf(stderr,"lastrejects.%d -> all tx in mempool\n",lastrejects); break; + } fprintf(stderr,"addtomempool ht.%d for CC checking: n.%d rejects.%d last.%d\n",height,(int32_t)block.vtx.size(),rejects,lastrejects); lastrejects = rejects; rejects = 0;