try
This commit is contained in:
@@ -545,22 +545,18 @@ bool DiceValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction &tx)
|
|||||||
//vout.1: tag to owner address for entropy funds
|
//vout.1: tag to owner address for entropy funds
|
||||||
preventCCvouts = 1;
|
preventCCvouts = 1;
|
||||||
CBlockIndex block;
|
CBlockIndex block;
|
||||||
|
int skipped = 0;
|
||||||
DiceAmounts(inputs,outputs,cp,eval,tx,sbits,fundingtxid);
|
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 )
|
||||||
return eval->Invalid("vin0 != vin1 prevout.hash for bet");
|
return eval->Invalid("vin0 != vin1 prevout.hash for bet");
|
||||||
else if ( eval->GetTxUnconfirmed(tx.vin[1].prevout.hash,vinTx,hashBlock) == 0 ) {
|
else if ( eval->GetTxUnconfirmed(tx.vin[1].prevout.hash,vinTx,hashBlock) == 0 ) {
|
||||||
int tries = 0;
|
char str[65],str2[65],str3[65];
|
||||||
while ( eval->GetTxUnconfirmed(tx.vin[1].prevout.hash,vinTx,hashBlock) == 0 ) {
|
fprintf(stderr, "txid.%s tx.%s hashBlock.%s\n",uint256_str(str,txid),uint256_str(str2,tx.vin[1].prevout.hash),uint256_str(str3,hashBlock));
|
||||||
tries++;
|
//return eval->Invalid("always should find looking vin.0, but didnt for wlt");
|
||||||
sleep(1);
|
skipped = 1;
|
||||||
char str[65],str2[65],str3[65];
|
}
|
||||||
fprintf(stderr, "txid.%s tx.%s hashBlock.%s\n",uint256_str(str,txid),uint256_str(str2,tx.vin[1].prevout.hash),uint256_str(str3,hashBlock));
|
|
||||||
if ( tries > 10 ) {
|
|
||||||
return eval->Invalid("always should find after 60s of looking vin.0, but didnt for wlt");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (hashBlock.IsNull() || !eval->GetBlock(hashBlock, block))
|
} else if (hashBlock.IsNull() || !eval->GetBlock(hashBlock, block))
|
||||||
return eval->Invalid(" TX not confirmed! always should find vin.0, but didnt for wlt");
|
return eval->Invalid(" TX not confirmed! always should find vin.0, but didnt for wlt");
|
||||||
else if ( vinTx.vout.size() < 3 || DecodeDiceOpRet(tx.vin[1].prevout.hash,vinTx.vout[vinTx.vout.size()-1].scriptPubKey,vinsbits,vinfundingtxid,vinhentropy,vinproof) != 'B' )
|
else if ( vinTx.vout.size() < 3 || DecodeDiceOpRet(tx.vin[1].prevout.hash,vinTx.vout[vinTx.vout.size()-1].scriptPubKey,vinsbits,vinfundingtxid,vinhentropy,vinproof) != 'B' )
|
||||||
@@ -584,27 +580,30 @@ bool DiceValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction &tx)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//vout.0: funding CC change to entropy owner
|
if ( skipped == 0)
|
||||||
//vout.2: normal output to bettor's address
|
|
||||||
//vout.n-1: opreturn 'W' sbits fundingtxid hentropy proof
|
|
||||||
odds = vinTx.vout[2].nValue - txfee;
|
|
||||||
if ( ConstrainVout(tx.vout[0],1,cp->unspendableCCaddr,0) == 0 )
|
|
||||||
return eval->Invalid("vout[0] != inputs-txfee for win/timeout");
|
|
||||||
else if ( tx.vout[2].scriptPubKey != vinTx.vout[2].scriptPubKey )
|
|
||||||
return eval->Invalid("vout[2] scriptPubKey mismatch for win/timeout");
|
|
||||||
else if ( tx.vout[2].nValue != (odds+1)*vinTx.vout[1].nValue )
|
|
||||||
return eval->Invalid("vout[2] payut mismatch for win/timeout");
|
|
||||||
else if ( inputs != (outputs + tx.vout[2].nValue) && inputs != (outputs + tx.vout[2].nValue+txfee) )
|
|
||||||
{
|
{
|
||||||
fprintf(stderr,"inputs %.8f != outputs %.8f + %.8f\n",(double)inputs/COIN,(double)outputs/COIN,(double)tx.vout[2].nValue/COIN);
|
//vout.0: funding CC change to entropy owner
|
||||||
return eval->Invalid("CC funds mismatch for win/timeout");
|
//vout.2: normal output to bettor's address
|
||||||
|
//vout.n-1: opreturn 'W' sbits fundingtxid hentropy proof
|
||||||
|
odds = vinTx.vout[2].nValue - txfee;
|
||||||
|
if ( ConstrainVout(tx.vout[0],1,cp->unspendableCCaddr,0) == 0 )
|
||||||
|
return eval->Invalid("vout[0] != inputs-txfee for win/timeout");
|
||||||
|
else if ( tx.vout[2].scriptPubKey != vinTx.vout[2].scriptPubKey )
|
||||||
|
return eval->Invalid("vout[2] scriptPubKey mismatch for win/timeout");
|
||||||
|
else if ( tx.vout[2].nValue != (odds+1)*vinTx.vout[1].nValue )
|
||||||
|
return eval->Invalid("vout[2] payut mismatch for win/timeout");
|
||||||
|
else if ( inputs != (outputs + tx.vout[2].nValue) && inputs != (outputs + tx.vout[2].nValue+txfee) )
|
||||||
|
{
|
||||||
|
fprintf(stderr,"inputs %.8f != outputs %.8f + %.8f\n",(double)inputs/COIN,(double)outputs/COIN,(double)tx.vout[2].nValue/COIN);
|
||||||
|
return eval->Invalid("CC funds mismatch for win/timeout");
|
||||||
|
}
|
||||||
|
else if ( tx.vout[3].scriptPubKey != fundingPubKey )
|
||||||
|
{
|
||||||
|
if ( tx.vout[3].scriptPubKey.size() == 0 || ((uint8_t *)tx.vout[3].scriptPubKey.data())[0] != 0x6a )
|
||||||
|
return eval->Invalid("vout[3] not send to fundingPubKey for win/timeout");
|
||||||
|
}
|
||||||
|
iswin = (funcid == 'W');
|
||||||
}
|
}
|
||||||
else if ( tx.vout[3].scriptPubKey != fundingPubKey )
|
|
||||||
{
|
|
||||||
if ( tx.vout[3].scriptPubKey.size() == 0 || ((uint8_t *)tx.vout[3].scriptPubKey.data())[0] != 0x6a )
|
|
||||||
return eval->Invalid("vout[3] not send to fundingPubKey for win/timeout");
|
|
||||||
}
|
|
||||||
iswin = (funcid == 'W');
|
|
||||||
}
|
}
|
||||||
if ( iswin != 0 )
|
if ( iswin != 0 )
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user