Test
This commit is contained in:
@@ -1069,7 +1069,6 @@ std::string DiceBetFinish(uint256 &entropyused,int32_t *resultp,uint64_t txfee,c
|
||||
fprintf(stderr,"%s\n", CCerror.c_str() );
|
||||
return("");
|
||||
}
|
||||
fprintf(stderr,"0 ");
|
||||
fundingpk = DiceFundingPk(fundingPubKey);
|
||||
if ( winlosetimeout != 0 ) // must be dealernode
|
||||
{
|
||||
@@ -1080,17 +1079,14 @@ std::string DiceBetFinish(uint256 &entropyused,int32_t *resultp,uint64_t txfee,c
|
||||
winlosetimeout = 0;
|
||||
}
|
||||
}
|
||||
fprintf(stderr,"1 ");
|
||||
if ( AddNormalinputs(mtx,mypk,2*txfee,1) == 0 ) // must be a single vin!!
|
||||
{
|
||||
CCerror = "no txfee inputs for win/lose";
|
||||
fprintf(stderr,"%s\n", CCerror.c_str() );
|
||||
return("");
|
||||
}
|
||||
fprintf(stderr,"2 ");
|
||||
if ( GetTransaction(bettxid,betTx,hashBlock,false) != 0 && GetTransaction(betTx.vin[0].prevout.hash,entropyTx,hashBlock,false) != 0 )
|
||||
{
|
||||
fprintf(stderr,"3 ");
|
||||
entropytxid = betTx.vin[0].prevout.hash;
|
||||
CSpentIndexKey key(bettxid, 0);
|
||||
CSpentIndexValue value;
|
||||
@@ -1102,27 +1098,15 @@ std::string DiceBetFinish(uint256 &entropyused,int32_t *resultp,uint64_t txfee,c
|
||||
fprintf(stderr,"%s\n", CCerror.c_str() );
|
||||
return("");
|
||||
}
|
||||
/*if ( CCtxidvalue(cp->unspendableCCaddr,bettxid,0) != 0 && CCtxidvalue(cp->unspendableCCaddr,bettxid,1) != 0 ) // already confirmed
|
||||
{
|
||||
if ( CCutxovalue(cp->unspendableCCaddr,bettxid,0) == 0 || CCutxovalue(cp->unspendableCCaddr,bettxid,1) == 0 ) // but not unspent -> spent
|
||||
{
|
||||
CCerror = "bettxid already spent";
|
||||
fprintf(stderr,"%s\n", CCerror.c_str() );
|
||||
return("");
|
||||
}
|
||||
}*/
|
||||
fprintf(stderr,"4 ");
|
||||
bettorentropy = DiceGetEntropy(betTx,'B');
|
||||
if ( winlosetimeout == 0 || (iswin= DiceIsWinner(hentropyproof,bettxid,betTx,entropyTx,bettorentropy,sbits,minbet,maxbet,maxodds,timeoutblocks,fundingtxid)) != 0 )
|
||||
{
|
||||
fprintf(stderr,"5 ");
|
||||
if ( myIsutxo_spentinmempool(bettxid,0) != 0 || myIsutxo_spentinmempool(bettxid,1) != 0 )
|
||||
{
|
||||
CCerror = "bettxid already spent in mempool";
|
||||
fprintf(stderr,"%s\n", CCerror.c_str() );
|
||||
return("");
|
||||
}
|
||||
fprintf(stderr,"6 ");
|
||||
if ( winlosetimeout != 0 ) // dealernode
|
||||
{
|
||||
entropyused = hentropyproof;
|
||||
@@ -1137,7 +1121,6 @@ std::string DiceBetFinish(uint256 &entropyused,int32_t *resultp,uint64_t txfee,c
|
||||
funcid = 'W';
|
||||
else funcid = 'L';
|
||||
}
|
||||
fprintf(stderr,"7 ");
|
||||
if ( iswin == winlosetimeout ) // dealernode and normal node paths should always get here
|
||||
{
|
||||
//fprintf(stderr,"iswin.%d matches\n",iswin);
|
||||
@@ -1157,7 +1140,6 @@ std::string DiceBetFinish(uint256 &entropyused,int32_t *resultp,uint64_t txfee,c
|
||||
fprintf(stderr,"set timeout win T\n");
|
||||
}
|
||||
}
|
||||
fprintf(stderr,"8 ");
|
||||
if ( iswin > 0 && funcid != 0 ) // dealernode 'W' or normal node 'T' path
|
||||
{
|
||||
odds = (betTx.vout[2].nValue - txfee);
|
||||
@@ -1193,13 +1175,11 @@ std::string DiceBetFinish(uint256 &entropyused,int32_t *resultp,uint64_t txfee,c
|
||||
mtx.vout.push_back(CTxOut(txfee,fundingPubKey));
|
||||
}
|
||||
//fprintf(stderr,"make tx.%c\n",funcid);
|
||||
fprintf(stderr,"9 ");
|
||||
if ( funcid == 'L' || funcid == 'W' ) // dealernode only
|
||||
hentropy = DiceHashEntropy(entropy,mtx.vin[0].prevout.hash);
|
||||
*resultp = 1;
|
||||
//char str[65],str2[65];
|
||||
//fprintf(stderr,"iswin.%d house entropy %s vs bettor %s\n",iswin,uint256_str(str,hentropyproof),uint256_str(str2,bettorentropy));
|
||||
fprintf(stderr,"z ");
|
||||
return(FinalizeCCTx(0,cp,mtx,fundingpk,txfee,EncodeDiceOpRet(funcid,sbits,fundingtxid,hentropy,hentropyproof)));
|
||||
} else fprintf(stderr,"iswin.%d does not match.%d\n",iswin,winlosetimeout);
|
||||
}
|
||||
@@ -1256,14 +1236,10 @@ double DiceStatus(uint64_t txfee,char *planstr,uint256 fundingtxid,uint256 bettx
|
||||
fprintf(stderr,"status bettxid.%s already spent in mempool\n",txid.GetHex().c_str());
|
||||
continue;
|
||||
}
|
||||
fprintf(stderr,"[");
|
||||
res = DiceBetFinish(entropyused,&result,txfee,planstr,fundingtxid,txid,scriptPubKey == fundingPubKey);
|
||||
fprintf(stderr,"]");
|
||||
if ( result > 0 )
|
||||
{
|
||||
fprintf(stderr,"(");
|
||||
mySenddicetransaction(res,entropyused,txid);
|
||||
fprintf(stderr,")");
|
||||
n++;
|
||||
} else error = res;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user