@ -322,7 +322,7 @@ void dicefinish_delete(struct dicefinish_info *ptr)
void * dicefinish ( void * _ptr )
{
std : : vector < uint8_t > mypk ; struct CC_info * cp , C ; char name [ 32 ] , coinaddr [ 64 ] , CCaddr [ 64 ] ; std : : string res ; int32_t newht , newblock , entropyvout , numblocks , lastheight = 0 , vin0_needed , i , n , m , num , iter , result ; struct dicefinish_info * ptr , * tmp ; uint32_t now ; struct dicefinish_utxo * utxos ; uint256 hashBlock , entropyused ; CPubKey dicepk ; CTransaction betTx , finishTx , tx ;
std : : vector < uint8_t > mypk ; struct CCcontract _info * cp , C ; char name [ 32 ] , coinaddr [ 64 ] , CCaddr [ 64 ] ; std : : string res ; int32_t newht , newblock , entropyvout , numblocks , lastheight = 0 , vin0_needed , i , n , m , num , iter , result ; struct dicefinish_info * ptr , * tmp ; uint32_t now ; struct dicefinish_utxo * utxos ; uint256 hashBlock , entropyused ; CPubKey dicepk ; CTransaction betTx , finishTx , tx ;
mypk = Mypubkey ( ) ;
pubkey2addr ( coinaddr , mypk . data ( ) ) ;
cp = CCinit ( & C , EVAL_DICE ) ;
@ -735,7 +735,7 @@ uint256 DiceGetEntropy(CTransaction tx,uint8_t reffuncid)
else return ( zeroid ) ;
}
uint64_t IsDicevout ( struct CC_info * cp , const CTransaction & tx , int32_t v , uint64_t refsbits , uint256 reffundingtxid )
uint64_t IsDicevout ( struct CCcontract _info * cp , const CTransaction & tx , int32_t v , uint64_t refsbits , uint256 reffundingtxid )
{
char destaddr [ 64 ] ; uint8_t funcid ; int32_t numvouts ; uint64_t sbits ; uint256 fundingtxid , hash , proof ;
if ( tx . vout [ v ] . scriptPubKey . IsPayToCryptoCondition ( ) ! = 0 )
@ -749,7 +749,7 @@ uint64_t IsDicevout(struct CC_info *cp,const CTransaction& tx,int32_t v,uint64_t
return ( 0 ) ;
}
int64_t DiceAmounts ( uint64_t & inputs , uint64_t & outputs , struct CC_info * cp , Eval * eval , const CTransaction & tx , uint64_t refsbits , uint256 reffundingtxid )
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 ;
numvins = tx . vin . size ( ) ;
@ -834,7 +834,7 @@ bool DiceVerifyTimeout(CTransaction &betTx,int32_t timeoutblocks)
return ( numblocks > = timeoutblocks ) ;
}
bool DiceValidate ( struct CC_info * cp , Eval * eval , const CTransaction & tx , uint32_t nIn )
bool DiceValidate ( struct CCcontract _info * cp , Eval * eval , const CTransaction & tx , uint32_t nIn )
{
uint256 txid , fundingtxid , vinfundingtxid , vinhentropy , vinproof , hashBlock , hash , proof , entropy ; int64_t minbet , maxbet , maxodds , timeoutblocks , odds , winnings ; uint64_t vinsbits , refsbits = 0 , sbits , amount , inputs , outputs , txfee = 10000 ; int32_t numvins , entropyvout , numvouts , preventCCvins , preventCCvouts , i , iswin ; uint8_t funcid ; CScript fundingPubKey ; CTransaction fundingTx , vinTx , vinofvinTx ; char CCaddr [ 64 ] ;
numvins = tx . vin . size ( ) ;
@ -1046,7 +1046,7 @@ bool DiceValidate(struct CC_info *cp,Eval *eval,const CTransaction &tx, uint32_t
return ( true ) ;
}
uint64_t AddDiceInputs ( struct CC_info * cp , CMutableTransaction & mtx , CPubKey pk , uint64_t total , int32_t maxinputs , uint64_t refsbits , uint256 reffundingtxid )
uint64_t AddDiceInputs ( struct CCcontract _info * cp , CMutableTransaction & mtx , CPubKey pk , uint64_t total , int32_t maxinputs , uint64_t refsbits , uint256 reffundingtxid )
{
char coinaddr [ 64 ] , str [ 65 ] ; uint64_t threshold , sbits , nValue , totalinputs = 0 ; uint256 txid , hash , proof , hashBlock , fundingtxid ; CTransaction tx ; int32_t j , vout , n = 0 ; uint8_t funcid ;
std : : vector < std : : pair < CAddressUnspentKey , CAddressUnspentValue > > unspentOutputs ;
@ -1095,7 +1095,7 @@ uint64_t AddDiceInputs(struct CC_info *cp,CMutableTransaction &mtx,CPubKey pk,ui
return ( totalinputs ) ;
}
int64_t DicePlanFunds ( uint64_t & entropyval , uint256 & entropytxid , uint64_t refsbits , struct CC_info * cp , CPubKey dicepk , uint256 reffundingtxid , int32_t & entropytxs , bool random )
int64_t DicePlanFunds ( uint64_t & entropyval , uint256 & entropytxid , uint64_t refsbits , struct CCcontract _info * cp , CPubKey dicepk , uint256 reffundingtxid , int32_t & entropytxs , bool random )
{
char coinaddr [ 64 ] , str [ 65 ] ; uint64_t sbits ; int64_t nValue , sum , totalinputs = 0 ; uint256 hash , txid , proof , hashBlock , fundingtxid ; CScript fundingPubKey ; CTransaction tx , vinTx ; int32_t vout , first = 0 , n = 0 , i = 0 , pendingbets = 0 ; uint8_t funcid ;
std : : vector < std : : pair < CAddressUnspentKey , CAddressUnspentValue > > unspentOutputs ;
@ -1215,7 +1215,7 @@ int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbit
}
}
bool DicePlanExists ( CScript & fundingPubKey , uint256 & fundingtxid , struct CC_info * cp , uint64_t refsbits , CPubKey dicepk , int64_t & minbet , int64_t & maxbet , int64_t & maxodds , int64_t & timeoutblocks )
bool DicePlanExists ( CScript & fundingPubKey , uint256 & fundingtxid , struct CCcontract _info * cp , uint64_t refsbits , CPubKey dicepk , int64_t & minbet , int64_t & maxbet , int64_t & maxodds , int64_t & timeoutblocks )
{
char CCaddr [ 64 ] ; uint64_t sbits = 0 ; uint256 txid , hashBlock ; CTransaction tx ;
std : : vector < std : : pair < CAddressIndexKey , CAmount > > txids ;
@ -1256,9 +1256,9 @@ bool DicePlanExists(CScript &fundingPubKey,uint256 &fundingtxid,struct CC_info *
return ( false ) ;
}
struct CC_info * Diceinit ( CScript & fundingPubKey , uint256 reffundingtxid , struct CC_info * C , char * planstr , uint64_t & txfee , CPubKey & mypk , CPubKey & dicepk , uint64_t & sbits , int64_t & minbet , int64_t & maxbet , int64_t & maxodds , int64_t & timeoutblocks )
struct CCcontract _info * Diceinit ( CScript & fundingPubKey , uint256 reffundingtxid , struct CCcontract _info * C , char * planstr , uint64_t & txfee , CPubKey & mypk , CPubKey & dicepk , uint64_t & sbits , int64_t & minbet , int64_t & maxbet , int64_t & maxodds , int64_t & timeoutblocks )
{
struct CC_info * cp ; int32_t cmpflag ;
struct CCcontract _info * cp ; int32_t cmpflag ;
cp = CCinit ( C , EVAL_DICE ) ;
if ( txfee = = 0 )
txfee = 10000 ;
@ -1278,7 +1278,7 @@ struct CC_info *Diceinit(CScript &fundingPubKey,uint256 reffundingtxid,struct CC
UniValue DiceInfo ( uint256 diceid )
{
UniValue result ( UniValue : : VOBJ ) ; CPubKey dicepk ; uint256 hashBlock , entropytxid ; CTransaction vintx ; int64_t minbet , maxbet , maxodds , timeoutblocks ; uint64_t sbits , funding , entropyval ; char str [ 67 ] , numstr [ 65 ] ; struct CC_info * cp , C ;
UniValue result ( UniValue : : VOBJ ) ; CPubKey dicepk ; uint256 hashBlock , entropytxid ; CTransaction vintx ; int64_t minbet , maxbet , maxodds , timeoutblocks ; uint64_t sbits , funding , entropyval ; char str [ 67 ] , numstr [ 65 ] ; struct CCcontract _info * cp , C ;
if ( myGetTransaction ( diceid , vintx , hashBlock ) = = 0 )
{
fprintf ( stderr , " cant find fundingtxid \n " ) ;
@ -1314,7 +1314,7 @@ UniValue DiceInfo(uint256 diceid)
UniValue DiceList ( )
{
UniValue result ( UniValue : : VARR ) ; std : : vector < std : : pair < CAddressIndexKey , CAmount > > addressIndex ; struct CC_info * cp , C ; uint256 txid , hashBlock ; CTransaction vintx ; uint64_t sbits ; int64_t minbet , maxbet , maxodds , timeoutblocks ; char str [ 65 ] ;
UniValue result ( UniValue : : VARR ) ; std : : vector < std : : pair < CAddressIndexKey , CAmount > > addressIndex ; struct CCcontract _info * cp , C ; uint256 txid , hashBlock ; CTransaction vintx ; uint64_t sbits ; int64_t minbet , maxbet , maxodds , timeoutblocks ; char str [ 65 ] ;
cp = CCinit ( & C , EVAL_DICE ) ;
SetCCtxids ( addressIndex , cp - > normaladdr ) ;
for ( std : : vector < std : : pair < CAddressIndexKey , CAmount > > : : const_iterator it = addressIndex . begin ( ) ; it ! = addressIndex . end ( ) ; it + + )
@ -1334,7 +1334,7 @@ UniValue DiceList()
std : : string DiceCreateFunding ( uint64_t txfee , char * planstr , int64_t funds , int64_t minbet , int64_t maxbet , int64_t maxodds , int64_t timeoutblocks )
{
CMutableTransaction mtx = CreateNewContextualCMutableTransaction ( Params ( ) . GetConsensus ( ) , komodo_nextheight ( ) ) ;
uint256 zero ; CScript fundingPubKey ; CPubKey mypk , dicepk ; int64_t a , b , c , d ; uint64_t sbits ; struct CC_info * cp , C ;
uint256 zero ; CScript fundingPubKey ; CPubKey mypk , dicepk ; int64_t a , b , c , d ; uint64_t sbits ; struct CCcontract _info * cp , C ;
if ( funds < 0 | | minbet < 0 | | maxbet < 0 | | maxodds < 1 | | maxodds > 9999 | | timeoutblocks < 0 | | timeoutblocks > 1440 )
{
CCerror = " invalid parameter error " ;
@ -1369,7 +1369,7 @@ std::string DiceCreateFunding(uint64_t txfee,char *planstr,int64_t funds,int64_t
std : : string DiceAddfunding ( uint64_t txfee , char * planstr , uint256 fundingtxid , int64_t amount )
{
CMutableTransaction mtx = CreateNewContextualCMutableTransaction ( Params ( ) . GetConsensus ( ) , komodo_nextheight ( ) ) ;
CScript fundingPubKey , scriptPubKey ; uint256 entropy , hentropy ; CPubKey mypk , dicepk ; uint64_t sbits ; struct CC_info * cp , C ; int64_t minbet , maxbet , maxodds , timeoutblocks ;
CScript fundingPubKey , scriptPubKey ; uint256 entropy , hentropy ; CPubKey mypk , dicepk ; uint64_t sbits ; struct CCcontract _info * cp , C ; int64_t minbet , maxbet , maxodds , timeoutblocks ;
if ( amount < 0 )
{
CCerror = " amount must be positive " ;
@ -1413,7 +1413,7 @@ std::string DiceAddfunding(uint64_t txfee,char *planstr,uint256 fundingtxid,int6
std : : string DiceBet ( uint64_t txfee , char * planstr , uint256 fundingtxid , int64_t bet , int32_t odds )
{
CMutableTransaction mtx = CreateNewContextualCMutableTransaction ( Params ( ) . GetConsensus ( ) , komodo_nextheight ( ) ) ;
CScript fundingPubKey ; CPubKey mypk , dicepk ; uint64_t sbits , entropyval , entropyval2 ; int64_t funding , minbet , maxbet , maxodds , timeoutblocks ; uint256 entropytxid , entropytxid2 , entropy , hentropy ; struct CC_info * cp , C ;
CScript fundingPubKey ; CPubKey mypk , dicepk ; uint64_t sbits , entropyval , entropyval2 ; int64_t funding , minbet , maxbet , maxodds , timeoutblocks ; uint256 entropytxid , entropytxid2 , entropy , hentropy ; struct CCcontract _info * cp , C ;
if ( bet < 0 )
{
CCerror = " bet must be positive " ;
@ -1472,7 +1472,7 @@ std::string DiceBet(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t bet
std : : string DiceBetFinish ( uint8_t & funcid , uint256 & entropyused , int32_t & entropyvout , int32_t * resultp , uint64_t txfee , char * planstr , uint256 fundingtxid , uint256 bettxid , int32_t winlosetimeout , uint256 vin0txid , int32_t vin0vout )
{
CMutableTransaction savemtx , mtx = CreateNewContextualCMutableTransaction ( Params ( ) . GetConsensus ( ) , komodo_nextheight ( ) ) ;
CScript scriptPubKey , fundingPubKey ; CTransaction oldbetTx , betTx , entropyTx ; uint256 hentropyproof , entropytxid , hashBlock , bettorentropy , entropy , hentropy , oldbettxid ; CPubKey mypk , dicepk , fundingpk ; struct CC_info * cp , C ; int64_t inputs = 0 , CCchange = 0 , odds , fundsneeded , minbet , maxbet , maxodds , timeoutblocks ; int32_t oldentropyvout , retval = 0 , iswin = 0 ; uint64_t entropyval , sbits ;
CScript scriptPubKey , fundingPubKey ; CTransaction oldbetTx , betTx , entropyTx ; uint256 hentropyproof , entropytxid , hashBlock , bettorentropy , entropy , hentropy , oldbettxid ; CPubKey mypk , dicepk , fundingpk ; struct CCcontract _info * cp , C ; int64_t inputs = 0 , CCchange = 0 , odds , fundsneeded , minbet , maxbet , maxodds , timeoutblocks ; int32_t oldentropyvout , retval = 0 , iswin = 0 ; uint64_t entropyval , sbits ;
entropyused = zeroid ;
* resultp = 0 ;
funcid = 0 ;
@ -1653,7 +1653,7 @@ static uint256 dealer0_fundingtxid;
void * dealer0_loop ( void * _arg )
{
char * planstr = ( char * ) _arg ;
CTransaction tx , * entropytxs , entropytx ; CPubKey mypk , dicepk ; uint64_t entropyval ; uint256 hashBlock , entropytxid , txid ; int32_t height , lastht , numentropytxs , i , n , m , num ; CScript fundingPubKey ; struct CC_info * cp , C ; char coinaddr [ 64 ] ; std : : string res ; int64_t minbet , maxbet , maxodds , timeoutblocks ; uint64_t refsbits , txfee = 10000 ;
CTransaction tx , * entropytxs , entropytx ; CPubKey mypk , dicepk ; uint64_t entropyval ; uint256 hashBlock , entropytxid , txid ; int32_t height , lastht , numentropytxs , i , n , m , num ; CScript fundingPubKey ; struct CCcontract _info * cp , C ; char coinaddr [ 64 ] ; std : : string res ; int64_t minbet , maxbet , maxodds , timeoutblocks ; uint64_t refsbits , txfee = 10000 ;
if ( ( cp = Diceinit ( fundingPubKey , dealer0_fundingtxid , & C , planstr , txfee , mypk , dicepk , refsbits , minbet , maxbet , maxodds , timeoutblocks ) ) = = 0 )
{
fprintf ( stderr , " error initializing dealer0_loop \n " ) ;
@ -1749,7 +1749,7 @@ void *dealer0_loop(void *_arg)
double DiceStatus ( uint64_t txfee , char * planstr , uint256 fundingtxid , uint256 bettxid )
{
static int32_t didinit ; static char _planstr [ 64 ] ;
CScript fundingPubKey , scriptPubKey ; CTransaction spenttx , betTx , entropyTx ; uint256 hentropyproof , entropyused , hash , proof , txid , hashBlock , spenttxid , bettorentropy ; CPubKey mypk , dicepk , fundingpk ; struct CC_info * cp , C ; int32_t i , entropyvout , flag , win , num , loss , duplicate = 0 , result , iswin , vout , n = 0 ; int64_t minbet , maxbet , maxodds , timeoutblocks , sum = 0 ; uint64_t sbits , refsbits ; char coinaddr [ 64 ] ; std : : string res ; uint8_t funcid ;
CScript fundingPubKey , scriptPubKey ; CTransaction spenttx , betTx , entropyTx ; uint256 hentropyproof , entropyused , hash , proof , txid , hashBlock , spenttxid , bettorentropy ; CPubKey mypk , dicepk , fundingpk ; struct CCcontract _info * cp , C ; int32_t i , entropyvout , flag , win , num , loss , duplicate = 0 , result , iswin , vout , n = 0 ; int64_t minbet , maxbet , maxodds , timeoutblocks , sum = 0 ; uint64_t sbits , refsbits ; char coinaddr [ 64 ] ; std : : string res ; uint8_t funcid ;
if ( ( cp = Diceinit ( fundingPubKey , fundingtxid , & C , planstr , txfee , mypk , dicepk , refsbits , minbet , maxbet , maxodds , timeoutblocks ) ) = = 0 )
{
CCerror = " Diceinit error in status, is your transaction confirmed? " ;