From 6c7532d1ecdb80048f725fbb0709b3dd2ac59b6d Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Nov 2018 01:43:21 -1100 Subject: [PATCH 01/18] Test --- 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 6d1b5392b..06a843483 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -805,11 +805,12 @@ int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbit { if ( funcid == 'E' && fundingtxid != tx.vin[0].prevout.hash ) { - if ( GetTransaction(tx.vin[0].prevout.hash,vinTx,hashBlock,false) == 0 || vinTx.vin[0].prevout.n < 0 ) + if ( GetTransaction(tx.vin[0].prevout.hash,vinTx,hashBlock,false) == 0 || vinTx.vin.size() == 0 ) { - fprintf(stderr,"cant find entropy vin0 %s or vin0prev %d vouts[%d], iscoinbase.%d\n",uint256_str(str,tx.vin[0].prevout.hash),tx.vin[0].prevout.n,(int32_t)vinTx.vout.size(),(int32_t)vinTx.vin[0].prevout.n); + fprintf(stderr,"cant find entropy vin0 %s or vin0prev %d vouts[%d], iscoinbase.%d\n",uint256_str(str,tx.vin[0].prevout.hash),tx.vin[0].prevout.n,(int32_t)vinTx.vout.size(),(int32_t)vinTx.vin.size()); continue; } + printf("vinsize.%d\n",(int32_t)vinTx.vin.size()); if ( vinTx.vout[tx.vin[0].prevout.n].scriptPubKey != fundingPubKey ) { uint8_t *ptr0,*ptr1; int32_t i; char str[65]; From ef17e6579d9844a1d4afd0bfaa6ead6142956ee2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Nov 2018 01:46:37 -1100 Subject: [PATCH 02/18] Test --- 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 06a843483..117de98b9 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -803,7 +803,7 @@ int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbit //fprintf(stderr,"check first\n"); if ( tx.vout.size() > 1 && fundingPubKey == tx.vout[1].scriptPubKey ) { - if ( funcid == 'E' && fundingtxid != tx.vin[0].prevout.hash ) + if ( fundingtxid != tx.vin[0].prevout.hash ) { if ( GetTransaction(tx.vin[0].prevout.hash,vinTx,hashBlock,false) == 0 || vinTx.vin.size() == 0 ) { From dac41d3209fda980b19b6c3e9824fb24d3ec3c20 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Nov 2018 01:50:08 -1100 Subject: [PATCH 03/18] Test --- src/cc/dice.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 117de98b9..fd9bc37c1 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -803,14 +803,13 @@ int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbit //fprintf(stderr,"check first\n"); if ( tx.vout.size() > 1 && fundingPubKey == tx.vout[1].scriptPubKey ) { - if ( fundingtxid != tx.vin[0].prevout.hash ) + if ( GetTransaction(tx.vin[0].prevout.hash,vinTx,hashBlock,false) == 0 || vinTx.vin.size() == 0 ) + { + fprintf(stderr,"cant find entropy vin0 %s or vin0prev %d vouts[%d], iscoinbase.%d\n",uint256_str(str,tx.vin[0].prevout.hash),tx.vin[0].prevout.n,(int32_t)vinTx.vout.size(),(int32_t)vinTx.vin.size()); + continue; + } + if ( funcid == 'E' && fundingtxid != tx.vin[0].prevout.hash ) { - if ( GetTransaction(tx.vin[0].prevout.hash,vinTx,hashBlock,false) == 0 || vinTx.vin.size() == 0 ) - { - fprintf(stderr,"cant find entropy vin0 %s or vin0prev %d vouts[%d], iscoinbase.%d\n",uint256_str(str,tx.vin[0].prevout.hash),tx.vin[0].prevout.n,(int32_t)vinTx.vout.size(),(int32_t)vinTx.vin.size()); - continue; - } - printf("vinsize.%d\n",(int32_t)vinTx.vin.size()); if ( vinTx.vout[tx.vin[0].prevout.n].scriptPubKey != fundingPubKey ) { uint8_t *ptr0,*ptr1; int32_t i; char str[65]; From d16e3918e3485e519aae9becd43df04bb2d70b5a Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Nov 2018 01:59:34 -1100 Subject: [PATCH 04/18] Test --- src/cc/dice.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index fd9bc37c1..f8cbb74db 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -808,9 +808,9 @@ int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbit fprintf(stderr,"cant find entropy vin0 %s or vin0prev %d vouts[%d], iscoinbase.%d\n",uint256_str(str,tx.vin[0].prevout.hash),tx.vin[0].prevout.n,(int32_t)vinTx.vout.size(),(int32_t)vinTx.vin.size()); continue; } - if ( funcid == 'E' && fundingtxid != tx.vin[0].prevout.hash ) + if ( funcid == 'E' ) { - if ( vinTx.vout[tx.vin[0].prevout.n].scriptPubKey != fundingPubKey ) + if ( fundingtxid != tx.vin[0].prevout.hash && vinTx.vout[tx.vin[0].prevout.n].scriptPubKey != fundingPubKey ) { uint8_t *ptr0,*ptr1; int32_t i; char str[65]; ptr0 = (uint8_t *)vinTx.vout[tx.vin[0].prevout.n].scriptPubKey.data(); @@ -823,7 +823,16 @@ int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbit fprintf(stderr," (%c) entropy vin.%d fundingPubKey mismatch %s\n",funcid,tx.vin[0].prevout.n,uint256_str(str,tx.vin[0].prevout.hash)); continue; } - } //else fprintf(stderr,"not E or is funding\n"); + } + else + { + fprintf(stderr,"txid.%s vinTx.vin[0].prevout.n %d\n",txid.GetHex().c_str(),(int32_t)vinTx.vin[0].prevout.n); + if ( vinTx.vin[0].prevout.n < 0 ) + { + fprintf(stderr,"skip coinbase\n"); + continue; + } + } entropytxid = txid; entropyval = tx.vout[0].nValue; fprintf(stderr,"first.%d entropytxid.%s val %.8f\n",first,txid.GetHex().c_str(),(double)entropyval/COIN); From 47ed5efd3380020449526cc62fa2e29fddf587cc Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Nov 2018 02:06:13 -1100 Subject: [PATCH 05/18] Test --- src/cc/dice.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index f8cbb74db..a6a0a4fd1 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -469,7 +469,7 @@ int64_t DiceAmounts(uint64_t &inputs,uint64_t &outputs,struct CCcontract_info *c return eval->Invalid("always should find vin, but didnt"); else { - if ( (assetoshis= IsDicevout(cp,vinTx,tx.vin[i].prevout.n,refsbits,reffundingtxid)) != 0 ) + if ( (assetoshis= IsDicevout(cp,vinTx,(int32_t)tx.vin[i].prevout.n,refsbits,reffundingtxid)) != 0 ) inputs += assetoshis; } } @@ -587,7 +587,7 @@ bool DiceValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction &tx) return eval->Invalid("always should find vin.0, but didnt for bet"); else if ( vinTx.vout[1].scriptPubKey != fundingPubKey ) return eval->Invalid("entropy tx not fundingPubKey for bet"); - else if ( ConstrainVout(tx.vout[0],1,cp->unspendableCCaddr,vinTx.vout[tx.vin[0].prevout.n].nValue) == 0 ) + else if ( ConstrainVout(tx.vout[0],1,cp->unspendableCCaddr,(int32_t)vinTx.vout[tx.vin[0].prevout.n].nValue) == 0 ) 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"); @@ -598,7 +598,7 @@ bool DiceValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction &tx) else if ( vinTx.vin[0].prevout.hash != fundingtxid ) { //if ( vinofvinTx.vout[1].scriptPubKey != fundingPubKey ) - if ( vinofvinTx.vout[vinTx.vin[0].prevout.n].scriptPubKey != fundingPubKey ) + if ( (int32_t)vinTx.vin[0].prevout.n < 0 || vinofvinTx.vout[vinTx.vin[0].prevout.n].scriptPubKey != fundingPubKey ) { uint8_t *ptr0,*ptr1; int32_t i; char str[65]; fprintf(stderr,"betTx.%s\n",uint256_str(str,txid)); @@ -803,9 +803,9 @@ int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbit //fprintf(stderr,"check first\n"); if ( tx.vout.size() > 1 && fundingPubKey == tx.vout[1].scriptPubKey ) { - if ( GetTransaction(tx.vin[0].prevout.hash,vinTx,hashBlock,false) == 0 || vinTx.vin.size() == 0 ) + if ( GetTransaction(tx.vin[0].prevout.hash,vinTx,hashBlock,false) == 0 || (int32_t)tx.vin[0].prevout.n < 0 ) { - fprintf(stderr,"cant find entropy vin0 %s or vin0prev %d vouts[%d], iscoinbase.%d\n",uint256_str(str,tx.vin[0].prevout.hash),tx.vin[0].prevout.n,(int32_t)vinTx.vout.size(),(int32_t)vinTx.vin.size()); + fprintf(stderr,"cant find entropy vin0 %s or vin0prev %d vouts[%d], iscoinbase.%d\n",uint256_str(str,tx.vin[0].prevout.hash),(int32_t)tx.vin[0].prevout.n,(int32_t)vinTx.vout.size(),(int32_t)vinTx.vin.size()); continue; } if ( funcid == 'E' ) @@ -826,8 +826,8 @@ int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbit } else { - fprintf(stderr,"txid.%s vinTx.vin[0].prevout.n %d\n",txid.GetHex().c_str(),(int32_t)vinTx.vin[0].prevout.n); - if ( vinTx.vin[0].prevout.n < 0 ) + fprintf(stderr,"txid.%s vinTx.vin[0].prevout.n %d %d\n",txid.GetHex().c_str(),(int32_t)vinTx.vin[0].prevout.n,(int32_t)vinTx.vin[0].prevout.n < 0); + if ( (int32_t)vinTx.vin[0].prevout.n < 0 ) { fprintf(stderr,"skip coinbase\n"); continue; From a33d12fcbd1e5f6c3761a48972c596529224ae40 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Nov 2018 02:09:54 -1100 Subject: [PATCH 06/18] Test --- src/cc/dice.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index a6a0a4fd1..1eef3f44f 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -826,10 +826,10 @@ int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbit } else { - fprintf(stderr,"txid.%s vinTx.vin[0].prevout.n %d %d\n",txid.GetHex().c_str(),(int32_t)vinTx.vin[0].prevout.n,(int32_t)vinTx.vin[0].prevout.n < 0); + //fprintf(stderr,"txid.%s vinTx.vin[0].prevout.n %d %d\n",txid.GetHex().c_str(),(int32_t)vinTx.vin[0].prevout.n,(int32_t)vinTx.vin[0].prevout.n < 0); if ( (int32_t)vinTx.vin[0].prevout.n < 0 ) { - fprintf(stderr,"skip coinbase\n"); + //fprintf(stderr,"skip coinbase\n"); continue; } } @@ -1082,8 +1082,8 @@ std::string DiceBet(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t bet return(""); } int32_t entropytxs=0,emptyvar=0; - funding = DicePlanFunds(entropyval,entropytxid,sbits,cp,dicepk,fundingtxid,entropytxs,false); - DicePlanFunds(entropyval,entropytxid,sbits,cp,dicepk,fundingtxid,emptyvar,true); + //funding = DicePlanFunds(entropyval,entropytxid,sbits,cp,dicepk,fundingtxid,entropytxs,false); + funding = DicePlanFunds(entropyval,entropytxid,sbits,cp,dicepk,fundingtxid,emptyvar,true); if ( ( funding >= 2*bet*odds+txfee && entropyval != 0 ) ) { if ( entropytxs < 100 ) { From 385f323d76cb5911ab08bc4bc45e09576004cba5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Nov 2018 02:12:05 -1100 Subject: [PATCH 07/18] Test --- src/cc/dice.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 1eef3f44f..cefb8a2f8 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -1082,8 +1082,8 @@ std::string DiceBet(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t bet return(""); } int32_t entropytxs=0,emptyvar=0; - //funding = DicePlanFunds(entropyval,entropytxid,sbits,cp,dicepk,fundingtxid,entropytxs,false); - funding = DicePlanFunds(entropyval,entropytxid,sbits,cp,dicepk,fundingtxid,emptyvar,true); + funding = DicePlanFunds(entropyval,entropytxid,sbits,cp,dicepk,fundingtxid,entropytxs,false); + DicePlanFunds(entropyval,entropytxid,sbits,cp,dicepk,fundingtxid,emptyvar,true); if ( ( funding >= 2*bet*odds+txfee && entropyval != 0 ) ) { if ( entropytxs < 100 ) { From 77fb34804d56265acec751378c80c5d208349283 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Nov 2018 03:42:31 -1100 Subject: [PATCH 08/18] Test --- src/cc/dice.cpp | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index cefb8a2f8..76715fc0d 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -792,10 +792,10 @@ int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbit { if ( (funcid == 'F' && reffundingtxid == txid) || reffundingtxid == fundingtxid ) { - if ( refsbits == sbits && (nValue= IsDicevout(cp,tx,vout,refsbits,reffundingtxid)) > 10000 && (funcid == 'F' || funcid == 'E' || funcid == 'W' || funcid == 'L' || funcid == 'T') ) + if ( refsbits == sbits && (nValue= IsDicevout(cp,tx,vout,refsbits,reffundingtxid)) >= 10000 && (funcid == 'F' || funcid == 'E' || funcid == 'W' || funcid == 'L' || funcid == 'T') ) { //fprintf(stderr,"%s.(%c %.8f) ",uint256_str(str,txid),funcid,(double)nValue/COIN); - if ( funcid != 'F' && funcid != 'T' ) + if ( funcid == 'L' || funcid == 'W' || funcid == 'E' ) n++; totalinputs += nValue; if ( first == 0 && (funcid == 'E' || funcid == 'W' || funcid == 'L') ) @@ -808,6 +808,11 @@ int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbit fprintf(stderr,"cant find entropy vin0 %s or vin0prev %d vouts[%d], iscoinbase.%d\n",uint256_str(str,tx.vin[0].prevout.hash),(int32_t)tx.vin[0].prevout.n,(int32_t)vinTx.vout.size(),(int32_t)vinTx.vin.size()); continue; } + if ( (int32_t)vinTx.vin[0].prevout.n < 0 ) + { + //fprintf(stderr,"skip coinbase\n"); + continue; + } if ( funcid == 'E' ) { if ( fundingtxid != tx.vin[0].prevout.hash && vinTx.vout[tx.vin[0].prevout.n].scriptPubKey != fundingPubKey ) @@ -824,18 +829,9 @@ int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbit continue; } } - else - { - //fprintf(stderr,"txid.%s vinTx.vin[0].prevout.n %d %d\n",txid.GetHex().c_str(),(int32_t)vinTx.vin[0].prevout.n,(int32_t)vinTx.vin[0].prevout.n < 0); - if ( (int32_t)vinTx.vin[0].prevout.n < 0 ) - { - //fprintf(stderr,"skip coinbase\n"); - continue; - } - } entropytxid = txid; entropyval = tx.vout[0].nValue; - fprintf(stderr,"first.%d entropytxid.%s val %.8f\n",first,txid.GetHex().c_str(),(double)entropyval/COIN); + fprintf(stderr,"funcid.%c first.%d entropytxid.%s val %.8f\n",funcid,first,txid.GetHex().c_str(),(double)entropyval/COIN); first = 1; if (random) { fprintf(stderr, "chosen entropy on loop: %d\n",loops); From c68644d19c2ec93686a47eda6953cbfc677f47dd Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Nov 2018 04:04:05 -1100 Subject: [PATCH 09/18] Test --- src/cc/dice.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 76715fc0d..228404ad8 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -813,19 +813,20 @@ int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbit //fprintf(stderr,"skip coinbase\n"); continue; } - if ( funcid == 'E' ) + //if ( funcid == 'E' ) { - if ( fundingtxid != tx.vin[0].prevout.hash && vinTx.vout[tx.vin[0].prevout.n].scriptPubKey != fundingPubKey ) + //if ( fundingtxid != tx.vin[0].prevout.hash && vinTx.vout[tx.vin[0].prevout.n].scriptPubKey != fundingPubKey ) + if ( fundingtxid != tx.vin[0].prevout.hash && vinTx.vout[1].scriptPubKey != fundingPubKey ) { uint8_t *ptr0,*ptr1; int32_t i; char str[65]; - ptr0 = (uint8_t *)vinTx.vout[tx.vin[0].prevout.n].scriptPubKey.data(); + ptr0 = (uint8_t *)vinTx.vout[1].scriptPubKey.data(); ptr1 = (uint8_t *)fundingPubKey.data(); - for (i=0; i Date: Wed, 7 Nov 2018 04:25:53 -1100 Subject: [PATCH 10/18] Test --- src/cc/dice.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 228404ad8..3c17e9b1f 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -407,6 +407,8 @@ CScript EncodeDiceOpRet(uint8_t funcid,uint64_t sbits,uint256 fundingtxid,uint25 uint8_t DecodeDiceOpRet(uint256 txid,const CScript &scriptPubKey,uint64_t &sbits,uint256 &fundingtxid,uint256 &hash,uint256 &proof) { std::vector vopret; uint8_t *script,e,f,funcid; int64_t minbet,maxbet,maxodds,timeoutblocks; + script = (uint8_t *)scriptPubKey.data(); + fprintf(stderr,"decode %02x %02x %02x\n",script[0],script[1],script[2]); GetOpReturnData(scriptPubKey,vopret); if ( vopret.size() > 2 ) { From bcc7be98b14e36877732afaddd66427ca803f2bd Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Nov 2018 04:31:57 -1100 Subject: [PATCH 11/18] Test --- src/cc/dice.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 3c17e9b1f..142b70e22 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -408,9 +408,9 @@ uint8_t DecodeDiceOpRet(uint256 txid,const CScript &scriptPubKey,uint64_t &sbits { std::vector vopret; uint8_t *script,e,f,funcid; int64_t minbet,maxbet,maxodds,timeoutblocks; script = (uint8_t *)scriptPubKey.data(); - fprintf(stderr,"decode %02x %02x %02x\n",script[0],script[1],script[2]); + //fprintf(stderr,"decode %02x %02x %02x\n",script[0],script[1],script[2]); GetOpReturnData(scriptPubKey,vopret); - if ( vopret.size() > 2 ) + if ( vopret.size() > 2 && script[0] == 0x6a ) { script = (uint8_t *)vopret.data(); if ( script[0] == EVAL_DICE ) From b14d87fa6bd484e98ae5032bb6426bc506a96dbf Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Nov 2018 04:44:32 -1100 Subject: [PATCH 12/18] Auto entropy on dealer dice status --- src/cc/dice.cpp | 54 ++++++++++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 21 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 142b70e22..6001e2702 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -815,22 +815,19 @@ int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbit //fprintf(stderr,"skip coinbase\n"); continue; } - //if ( funcid == 'E' ) + //if ( fundingtxid != tx.vin[0].prevout.hash && vinTx.vout[tx.vin[0].prevout.n].scriptPubKey != fundingPubKey ) + if ( fundingtxid != tx.vin[0].prevout.hash && vinTx.vout[1].scriptPubKey != fundingPubKey ) { - //if ( fundingtxid != tx.vin[0].prevout.hash && vinTx.vout[tx.vin[0].prevout.n].scriptPubKey != fundingPubKey ) - if ( fundingtxid != tx.vin[0].prevout.hash && vinTx.vout[1].scriptPubKey != fundingPubKey ) - { - uint8_t *ptr0,*ptr1; int32_t i; char str[65]; - ptr0 = (uint8_t *)vinTx.vout[1].scriptPubKey.data(); - ptr1 = (uint8_t *)fundingPubKey.data(); - 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\n",tx.GetHash().GetHex().c_str(),i,mintxs - entropytxs); + RelayTransaction(tx); + } + } + } + } } - }*/ + } return(n); } else From e37833a3444ace90990388491af6e06c0592e73b Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Nov 2018 04:52:13 -1100 Subject: [PATCH 13/18] Test --- src/cc/dice.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 6001e2702..dbf49ea10 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -1040,7 +1040,7 @@ std::string DiceAddfunding(uint64_t txfee,char *planstr,uint256 fundingtxid,int6 } if ( scriptPubKey == fundingPubKey ) { - if ( AddNormalinputs(mtx,mypk,amount+2*txfee,60) > 0 ) + if ( AddNormalinputs(mtx,mypk,amount+2*txfee,10) > 0 ) { hentropy = DiceHashEntropy(entropy,mtx.vin[0].prevout.hash); mtx.vout.push_back(MakeCC1vout(cp->evalcode,amount,dicepk)); @@ -1348,9 +1348,9 @@ double DiceStatus(uint64_t txfee,char *planstr,uint256 fundingtxid,uint256 bettx { fprintf(stderr,"ENTROPY %s: %d of %d\n",tx.GetHash().GetHex().c_str(),i,mintxs - entropytxs); RelayTransaction(tx); - } - } - } + } else break; + } else break; + } else break; } } } From 481667776c79a0af97e90405722637801c643050 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Nov 2018 05:12:01 -1100 Subject: [PATCH 14/18] Test --- src/cc/dice.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index dbf49ea10..644ddadde 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -590,7 +590,10 @@ bool DiceValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction &tx) else if ( vinTx.vout[1].scriptPubKey != fundingPubKey ) return eval->Invalid("entropy tx not fundingPubKey for bet"); else if ( ConstrainVout(tx.vout[0],1,cp->unspendableCCaddr,(int32_t)vinTx.vout[tx.vin[0].prevout.n].nValue) == 0 ) + { + fprintf(stderr,"prevout.%d %.8f\n",(int32_t)tx.vin[0].prevout.n,(double)vinTx.vout[tx.vin[0].prevout.n].nValue/COIN); 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 ) From a4cd90f11381a3cf374bc995426108d172c1a2d7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Nov 2018 05:12:54 -1100 Subject: [PATCH 15/18] Test --- 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 644ddadde..3be553873 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -591,7 +591,7 @@ bool DiceValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction &tx) return eval->Invalid("entropy tx not fundingPubKey for bet"); else if ( ConstrainVout(tx.vout[0],1,cp->unspendableCCaddr,(int32_t)vinTx.vout[tx.vin[0].prevout.n].nValue) == 0 ) { - fprintf(stderr,"prevout.%d %.8f\n",(int32_t)tx.vin[0].prevout.n,(double)vinTx.vout[tx.vin[0].prevout.n].nValue/COIN); + fprintf(stderr,"%s prevout.%d %.8f\n",tx.vin[0].prevout.hash.GetHex().c_str(),(int32_t)tx.vin[0].prevout.n,(double)vinTx.vout[tx.vin[0].prevout.n].nValue/COIN); return eval->Invalid("vout[0] != entropy nValue for bet"); } else if ( ConstrainVout(tx.vout[1],1,cp->unspendableCCaddr,0) == 0 ) From ccea0f71143f5fde25f55f52049aa85d2d4fdf2e Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Nov 2018 05:20:05 -1100 Subject: [PATCH 16/18] Int64 != int32 --- 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 3be553873..12f4f8dd6 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -589,7 +589,7 @@ bool DiceValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction &tx) return eval->Invalid("always should find vin.0, but didnt for bet"); else if ( vinTx.vout[1].scriptPubKey != fundingPubKey ) return eval->Invalid("entropy tx not fundingPubKey for bet"); - else if ( ConstrainVout(tx.vout[0],1,cp->unspendableCCaddr,(int32_t)vinTx.vout[tx.vin[0].prevout.n].nValue) == 0 ) + else if ( ConstrainVout(tx.vout[0],1,cp->unspendableCCaddr,(int64_t)vinTx.vout[tx.vin[0].prevout.n].nValue) == 0 ) { fprintf(stderr,"%s prevout.%d %.8f\n",tx.vin[0].prevout.hash.GetHex().c_str(),(int32_t)tx.vin[0].prevout.n,(double)vinTx.vout[tx.vin[0].prevout.n].nValue/COIN); return eval->Invalid("vout[0] != entropy nValue for bet"); From b2004c4a6d2e8237fa34d2ccae8043cf8e241bc4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Nov 2018 06:02:23 -1100 Subject: [PATCH 17/18] Test --- src/cc/dice.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 12f4f8dd6..6e7607360 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -407,10 +407,10 @@ CScript EncodeDiceOpRet(uint8_t funcid,uint64_t sbits,uint256 fundingtxid,uint25 uint8_t DecodeDiceOpRet(uint256 txid,const CScript &scriptPubKey,uint64_t &sbits,uint256 &fundingtxid,uint256 &hash,uint256 &proof) { std::vector vopret; uint8_t *script,e,f,funcid; int64_t minbet,maxbet,maxodds,timeoutblocks; - script = (uint8_t *)scriptPubKey.data(); + //script = (uint8_t *)scriptPubKey.data(); //fprintf(stderr,"decode %02x %02x %02x\n",script[0],script[1],script[2]); GetOpReturnData(scriptPubKey,vopret); - if ( vopret.size() > 2 && script[0] == 0x6a ) + if ( vopret.size() > 2 )//&& script[0] == 0x6a ) { script = (uint8_t *)vopret.data(); if ( script[0] == EVAL_DICE ) @@ -792,14 +792,13 @@ int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbit vout = (int32_t)it->first.index; if ( GetTransaction(txid,tx,hashBlock,false) != 0 && tx.vout[vout].scriptPubKey.IsPayToCryptoCondition() != 0 && myIsutxo_spentinmempool(txid,vout) == 0 ) { - //char str[65],str2[65]; if ( (funcid= DecodeDiceOpRet(txid,tx.vout[tx.vout.size()-1].scriptPubKey,sbits,fundingtxid,hash,proof)) != 0 ) { if ( (funcid == 'F' && reffundingtxid == txid) || reffundingtxid == fundingtxid ) { if ( refsbits == sbits && (nValue= IsDicevout(cp,tx,vout,refsbits,reffundingtxid)) >= 10000 && (funcid == 'F' || funcid == 'E' || funcid == 'W' || funcid == 'L' || funcid == 'T') ) { - //fprintf(stderr,"%s.(%c %.8f) ",uint256_str(str,txid),funcid,(double)nValue/COIN); + fprintf(stderr,"%s.(%c %.8f) ",uint256_str(str,txid),funcid,(double)nValue/COIN); if ( funcid == 'L' || funcid == 'W' || funcid == 'E' ) n++; totalinputs += nValue; From 280a6285f9bab3b06c812f1886c7ec89aed57087 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Nov 2018 06:07:54 -1100 Subject: [PATCH 18/18] Test --- 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 6e7607360..18a104ff3 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -790,6 +790,7 @@ int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbit } txid = it->first.txhash; vout = (int32_t)it->first.index; + fprintf(stderr,"%d: %s.(%c %.8f) total %.8f\n",n,uint256_str(str,txid),funcid,(double)it->second.satoshis/COIN,(double)totalinputs/COIN); if ( GetTransaction(txid,tx,hashBlock,false) != 0 && tx.vout[vout].scriptPubKey.IsPayToCryptoCondition() != 0 && myIsutxo_spentinmempool(txid,vout) == 0 ) { if ( (funcid= DecodeDiceOpRet(txid,tx.vout[tx.vout.size()-1].scriptPubKey,sbits,fundingtxid,hash,proof)) != 0 ) @@ -798,7 +799,6 @@ int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbit { if ( refsbits == sbits && (nValue= IsDicevout(cp,tx,vout,refsbits,reffundingtxid)) >= 10000 && (funcid == 'F' || funcid == 'E' || funcid == 'W' || funcid == 'L' || funcid == 'T') ) { - fprintf(stderr,"%s.(%c %.8f) ",uint256_str(str,txid),funcid,(double)nValue/COIN); if ( funcid == 'L' || funcid == 'W' || funcid == 'E' ) n++; totalinputs += nValue;