Constrain dice vins to be for exact plan
This commit is contained in:
@@ -313,18 +313,21 @@ uint256 DiceGetEntropy(CTransaction tx,uint8_t reffuncid)
|
|||||||
else return(zeroid);
|
else return(zeroid);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t IsDicevout(struct CCcontract_info *cp,const CTransaction& tx,int32_t v)
|
uint64_t IsDicevout(struct CCcontract_info *cp,const CTransaction& tx,int32_t v,uint64_t refsbits,uint256 reffundingtxid)
|
||||||
{
|
{
|
||||||
char destaddr[64];
|
char destaddr[64]; uint8_t funcid; uint64_t sbits; uint256 fundingtxid,hash,proof;
|
||||||
if ( tx.vout[v].scriptPubKey.IsPayToCryptoCondition() != 0 )
|
if ( tx.vout[v].scriptPubKey.IsPayToCryptoCondition() != 0 )
|
||||||
{
|
{
|
||||||
if ( Getscriptaddress(destaddr,tx.vout[v].scriptPubKey) > 0 && strcmp(destaddr,cp->unspendableCCaddr) == 0 )
|
if ( Getscriptaddress(destaddr,tx.vout[v].scriptPubKey) > 0 && strcmp(destaddr,cp->unspendableCCaddr) == 0 )
|
||||||
return(tx.vout[v].nValue);
|
{
|
||||||
|
if ( (numvouts= tx.vout.size()) > 0 && (funcid= DecodeDiceOpRet(tx.GetHash(),tx.vout[numvouts-1].scriptPubKey,sbits,fundingtxid,hash,proof)) != 0 && sbits == refsbits && ((funcid == 'F' && tx.GetHash() == reffundingtxid) || fundingtxid == reffundingtxid) )
|
||||||
|
return(tx.vout[v].nValue);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t DiceAmounts(uint64_t &inputs,uint64_t &outputs,struct CCcontract_info *cp,Eval *eval,const CTransaction &tx)
|
int64_t DiceAmounts(uint64_t &inputs,uint64_t &outputs,struct CCcontract_info *cp,Eval *eval,const CTransaction &tx,uint64_t refsbits,uint256 reffundingtxid)
|
||||||
{
|
{
|
||||||
CTransaction vinTx; uint256 hashBlock; int32_t i,numvins,numvouts; uint64_t assetoshis;
|
CTransaction vinTx; uint256 hashBlock; int32_t i,numvins,numvouts; uint64_t assetoshis;
|
||||||
numvins = tx.vin.size();
|
numvins = tx.vin.size();
|
||||||
@@ -338,7 +341,7 @@ int64_t DiceAmounts(uint64_t &inputs,uint64_t &outputs,struct CCcontract_info *c
|
|||||||
return eval->Invalid("always should find vin, but didnt");
|
return eval->Invalid("always should find vin, but didnt");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( (assetoshis= IsDicevout(cp,vinTx,tx.vin[i].prevout.n)) != 0 )
|
if ( (assetoshis= IsDicevout(cp,vinTx,tx.vin[i].prevout.n,refsbits,reffundingtxid)) != 0 )
|
||||||
inputs += assetoshis;
|
inputs += assetoshis;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -346,7 +349,7 @@ int64_t DiceAmounts(uint64_t &inputs,uint64_t &outputs,struct CCcontract_info *c
|
|||||||
for (i=0; i<numvouts; i++)
|
for (i=0; i<numvouts; i++)
|
||||||
{
|
{
|
||||||
//fprintf(stderr,"i.%d of numvouts.%d\n",i,numvouts);
|
//fprintf(stderr,"i.%d of numvouts.%d\n",i,numvouts);
|
||||||
if ( (assetoshis= IsDicevout(cp,tx,i)) != 0 )
|
if ( (assetoshis= IsDicevout(cp,tx,i,refsbits,reffundingtxid)) != 0 )
|
||||||
outputs += assetoshis;
|
outputs += assetoshis;
|
||||||
}
|
}
|
||||||
return(inputs - outputs);
|
return(inputs - outputs);
|
||||||
@@ -497,7 +500,7 @@ bool DiceValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction &tx)
|
|||||||
//vin.3+: funding CC vout.0 from 'F', 'E', 'W', 'L' or 'T'
|
//vin.3+: funding CC vout.0 from 'F', 'E', 'W', 'L' or 'T'
|
||||||
//vout.1: tag to owner address for entropy funds
|
//vout.1: tag to owner address for entropy funds
|
||||||
preventCCvouts = 1;
|
preventCCvouts = 1;
|
||||||
DiceAmounts(inputs,outputs,cp,eval,tx);
|
DiceAmounts(inputs,outputs,cp,eval,tx,sbits,fundingtxid);
|
||||||
if ( IsCCInput(tx.vin[1].scriptSig) == 0 || IsCCInput(tx.vin[2].scriptSig) == 0 )
|
if ( IsCCInput(tx.vin[1].scriptSig) == 0 || IsCCInput(tx.vin[2].scriptSig) == 0 )
|
||||||
return eval->Invalid("vin0 or vin1 normal vin for bet");
|
return eval->Invalid("vin0 or vin1 normal vin for bet");
|
||||||
else if ( tx.vin[1].prevout.hash != tx.vin[2].prevout.hash )
|
else if ( tx.vin[1].prevout.hash != tx.vin[2].prevout.hash )
|
||||||
@@ -630,7 +633,7 @@ int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbit
|
|||||||
{
|
{
|
||||||
if ( (funcid == 'F' && reffundingtxid == txid) || reffundingtxid == fundingtxid )
|
if ( (funcid == 'F' && reffundingtxid == txid) || reffundingtxid == fundingtxid )
|
||||||
{
|
{
|
||||||
if ( refsbits == sbits && (nValue= IsDicevout(cp,tx,vout)) > 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);
|
fprintf(stderr,"%s.(%c %.8f) ",uint256_str(str,txid),funcid,(double)nValue/COIN);
|
||||||
if ( funcid != 'F' && funcid != 'T' )
|
if ( funcid != 'F' && funcid != 'T' )
|
||||||
|
|||||||
Reference in New Issue
Block a user