diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 184466fa4..406d22fb2 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -49,7 +49,10 @@ one other technical note is that komodod has the insight-explorer extensions bui #include extern int32_t KOMODO_CONNECTING,KOMODO_CCACTIVATE; +<<<<<<< HEAD extern uint32_t ASSETCHAINS_CC; +======= +>>>>>>> jl777 #define SMALLVAL 0.000000000000001 union _bits256 { uint8_t bytes[32]; uint16_t ushorts[16]; uint32_t uints[8]; uint64_t ulongs[4]; uint64_t txid; }; diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 88438bad3..dd9322eeb 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -745,20 +745,21 @@ int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbit 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; uint256 txid,hashBlock; CTransaction tx; + char CCaddr[64]; uint64_t sbits=0; uint256 txid,hashBlock; CTransaction tx; std::vector > txids; GetCCaddress(cp,CCaddr,dicepk); SetCCtxids(txids,cp->normaladdr); if ( fundingtxid != zeroid ) // avoid scan unless creating new funding plan { + //fprintf(stderr,"check fundingtxid\n"); if ( GetTransaction(fundingtxid,tx,hashBlock,false) != 0 && tx.vout.size() > 1 && ConstrainVout(tx.vout[0],1,CCaddr,0) != 0 ) { if ( DecodeDiceFundingOpRet(tx.vout[tx.vout.size()-1].scriptPubKey,sbits,minbet,maxbet,maxodds,timeoutblocks) == 'F' && sbits == refsbits ) { fundingPubKey = tx.vout[1].scriptPubKey; return(true); - } - } + } else fprintf(stderr,"error decoding opret or sbits mismatch %llx vs %llx\n",(long long)sbits,(long long)refsbits); + } else fprintf(stderr,"couldnt get funding tx\n"); return(false); } for (std::vector >::const_iterator it=txids.begin(); it!=txids.end(); it++) @@ -797,7 +798,7 @@ struct CCcontract_info *Diceinit(CScript &fundingPubKey,uint256 reffundingtxid,s else cmpflag = 1; if ( DicePlanExists(fundingPubKey,reffundingtxid,cp,sbits,dicepk,minbet,maxbet,maxodds,timeoutblocks) != cmpflag ) { - fprintf(stderr,"Dice plan (%s) already exists cmpflag.%d\n",planstr,cmpflag); + fprintf(stderr,"Dice plan (%s) exists.%d vs cmpflag.%d\n",planstr,!cmpflag,cmpflag); return(0); } return(cp); @@ -865,10 +866,16 @@ std::string DiceCreateFunding(uint64_t txfee,char *planstr,int64_t funds,int64_t fprintf(stderr,"%s\n", CCerror.c_str() ); return(""); } + if ( funds < 100*COIN ) + { + CCerror = "dice plan needs at least 100 coins"; + fprintf(stderr,"%s\n", CCerror.c_str() ); + return(""); + } memset(&zero,0,sizeof(zero)); if ( (cp= Diceinit(fundingPubKey,zero,&C,planstr,txfee,mypk,dicepk,sbits,a,b,c,d)) == 0 ) { - CCerror = "Diceinit error"; + CCerror = "Diceinit error in create funding"; fprintf(stderr,"%s\n", CCerror.c_str() ); return(""); } @@ -966,7 +973,7 @@ std::string DiceBet(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t bet mtx.vout.push_back(MakeCC1vout(cp->evalcode,bet,dicepk)); mtx.vout.push_back(CTxOut(txfee+odds,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeDiceOpRet('B',sbits,fundingtxid,entropy,zeroid))); - } else fprintf(stderr,"cant find enough inputs %.8f note enough for %.8f\n",(double)funding/COIN,(double)bet/COIN); + } else fprintf(stderr,"cant find enough normal inputs for %.8f, plan funding %.8f\n",(double)bet/COIN,(double)funding/COIN); } if ( entropyval == 0 && funding != 0 ) CCerror = "cant find dice entropy inputs"; @@ -983,7 +990,7 @@ std::string DiceBetFinish(int32_t *resultp,uint64_t txfee,char *planstr,uint256 //char str[65]; fprintf(stderr,"DiceBetFinish.%s %s\n",planstr,uint256_str(str,bettxid)); if ( (cp= Diceinit(fundingPubKey,fundingtxid,&C,planstr,txfee,mypk,dicepk,sbits,minbet,maxbet,maxodds,timeoutblocks)) == 0 ) { - CCerror = "Diceinit error"; + CCerror = "Diceinit error in finish"; fprintf(stderr,"%s\n", CCerror.c_str() ); return(""); } @@ -1096,7 +1103,7 @@ double DiceStatus(uint64_t txfee,char *planstr,uint256 fundingtxid,uint256 bettx CScript fundingPubKey,scriptPubKey; CTransaction spenttx,betTx; uint256 hash,proof,txid,hashBlock,spenttxid; CPubKey mypk,dicepk,fundingpk; struct CCcontract_info *cp,C; int32_t i,result,vout,n=0; int64_t minbet,maxbet,maxodds,timeoutblocks; uint64_t sbits; char coinaddr[64]; std::string res; if ( (cp= Diceinit(fundingPubKey,fundingtxid,&C,planstr,txfee,mypk,dicepk,sbits,minbet,maxbet,maxodds,timeoutblocks)) == 0 ) { - CCerror = "Diceinit error"; + CCerror = "Diceinit error in status"; fprintf(stderr,"%s\n", CCerror.c_str() ); return(0.); } diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 65c02479d..b535a7514 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4836,6 +4836,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt int32_t ensure_CCrequirements() { extern uint8_t NOTARY_PUBKEY33[]; + CCerror = ""; if ( NOTARY_PUBKEY33[0] == 0 ) return(-1); else if ( GetBoolArg("-addressindex", DEFAULT_ADDRESSINDEX) == 0 ) @@ -5402,7 +5403,7 @@ UniValue dicebet(const UniValue& params, bool fHelp) { result.push_back(Pair("result", "success")); result.push_back(Pair("hex", hex)); - } else ERR_RESULT("couldnt create dice bet transaction"); + } else ERR_RESULT("couldnt create dice bet transaction. make sure your address has funds"); } else { ERR_RESULT("amount and odds must be positive"); }