From ebe7e27ada2b5d17cda14007c262a2323df62342 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 3 Aug 2018 01:51:05 -1100 Subject: [PATCH 1/2] Fix timeout claim --- src/cc/dice.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 02eb99a58..5d9aa328d 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -897,7 +897,7 @@ std::string DiceBet(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t bet std::string DiceBetFinish(int32_t *resultp,uint64_t txfee,char *planstr,uint256 fundingtxid,uint256 bettxid,int32_t winlosetimeout) { - CMutableTransaction mtx; CScript scriptPubKey,fundingPubKey; CTransaction betTx,entropyTx; uint256 hentropyproof,entropytxid,hashBlock,bettorentropy,entropy,hentropy; CPubKey mypk,dicepk,fundingpk; struct CCcontract_info *cp,C; int64_t inputs,CCchange=0,odds,fundsneeded,minbet,maxbet,maxodds,timeoutblocks; uint8_t funcid; int32_t iswin=0; uint64_t entropyval,sbits; + CMutableTransaction mtx; CScript scriptPubKey,fundingPubKey; CTransaction betTx,entropyTx; uint256 hentropyproof,entropytxid,hashBlock,bettorentropy,entropy,hentropy; CPubKey mypk,dicepk,fundingpk; struct CCcontract_info *cp,C; int64_t inputs,CCchange=0,odds,fundsneeded,minbet,maxbet,maxodds,timeoutblocks; uint8_t funcid=0; int32_t iswin=0; uint64_t entropyval,sbits; *resultp = 0; //char str[65]; fprintf(stderr,"DiceBetFinish.%s %s\n",planstr,uint256_str(str,bettxid)); if ( (cp= Diceinit(fundingPubKey,fundingtxid,&C,planstr,txfee,mypk,dicepk,sbits,minbet,maxbet,maxodds,timeoutblocks)) == 0 ) @@ -952,7 +952,8 @@ std::string DiceBetFinish(int32_t *resultp,uint64_t txfee,char *planstr,uint256 } if ( iswin > 0 ) { - funcid = 'W'; + if ( funcid != 'T' ) + funcid = 'W'; odds = (betTx.vout[2].nValue - txfee); if ( odds < 1 || odds > maxodds ) { From 99c090d95e338367216646ef17ef18d61a0434ce Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 3 Aug 2018 03:07:01 -1100 Subject: [PATCH 2/2] Fix edge case for maxodds --- src/cc/dice.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 5d9aa328d..c5e8ecf88 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -458,7 +458,7 @@ bool DiceValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction &tx) return eval->Invalid("vout[0] != entropy nValue for bet"); else if ( ConstrainVout(tx.vout[1],1,cp->unspendableCCaddr,0) == 0 ) return eval->Invalid("vout[1] constrain violation for bet"); - else if ( tx.vout[2].nValue >= txfee+maxodds || tx.vout[2].nValue < txfee ) + else if ( tx.vout[2].nValue > txfee+maxodds || tx.vout[2].nValue < txfee ) return eval->Invalid("vout[2] nValue violation for bet"); else if ( eval->GetTxUnconfirmed(vinTx.vin[0].prevout.hash,vinofvinTx,hashBlock) == 0 || vinofvinTx.vout.size() < 1 ) return eval->Invalid("always should find vinofvin.0, but didnt for bet");