diff --git a/src/cc/CCdice.h b/src/cc/CCdice.h index 8f76108dd..14d08596a 100644 --- a/src/cc/CCdice.h +++ b/src/cc/CCdice.h @@ -25,5 +25,7 @@ bool DiceValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx); std::string DiceCreateFunding(uint64_t txfee,char *planstr,int64_t funds,int64_t minbet,int64_t maxbet,int64_t maxodds,int64_t forfeitblocks); std::string DiceAddfunding(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t amount); +UniValue DiceInfo(uint256 diceid); +UniValue DiceList(); #endif diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 2b596c446..0e6669964 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -423,7 +423,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; CPubKey mypk,dicepk; CScript opret; uint64_t sbits; int64_t funding,minbet,maxbet,maxodds,forfeitblocks; struct CCcontract_info *cp,C; - if ( bet < 0 ) + if ( bet < 0 || odds < 1 ) { fprintf(stderr,"negative parameter error\n"); return(0); diff --git a/src/rpcserver.cpp b/src/rpcserver.cpp index 0330c8939..580a050c3 100644 --- a/src/rpcserver.cpp +++ b/src/rpcserver.cpp @@ -368,6 +368,8 @@ static const CRPCCommand vRPCCommands[] = { "faucet", "faucetaddress", &faucetaddress, true }, /* dice */ + { "dice", "dicelist", &dicelist, true }, + { "dice", "diceinfo", &diceinfo, true }, { "dice", "dicefund", &dicefund, true }, { "dice", "diceaddfunds", &diceaddfunds, true }, { "dice", "dicebet", &dicebet, true }, diff --git a/src/rpcserver.h b/src/rpcserver.h index c0e29020e..665ae5023 100644 --- a/src/rpcserver.h +++ b/src/rpcserver.h @@ -234,7 +234,8 @@ extern UniValue rewardsaddfunding(const UniValue& params, bool fHelp); extern UniValue rewardslock(const UniValue& params, bool fHelp); extern UniValue rewardsunlock(const UniValue& params, bool fHelp); extern UniValue diceaddress(const UniValue& params, bool fHelp); -extern UniValue dicefund(const UniValue& params, bool fHelp); +extern UniValue dicelist(const UniValue& params, bool fHelp); +extern UniValue diceinfo(const UniValue& params, bool fHelp); extern UniValue diceaddfunds(const UniValue& params, bool fHelp); extern UniValue dicebet(const UniValue& params, bool fHelp); extern UniValue lottoaddress(const UniValue& params, bool fHelp); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 653add7a9..71451cd2f 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5054,6 +5054,27 @@ UniValue rewardsunlock(const UniValue& params, bool fHelp) return(result); } +UniValue rewardslist(const UniValue& params, bool fHelp) +{ + uint256 tokenid; + if ( fHelp || params.size() > 0 ) + throw runtime_error("rewardslist\n"); + if ( ensure_CCrequirements() < 0 ) + throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + return(RewardsList()); +} + +UniValue rewardsinfo(const UniValue& params, bool fHelp) +{ + uint256 fundingtxid; + if ( fHelp || params.size() != 1 ) + throw runtime_error("rewardsinfo fundingtxid\n"); + if ( ensure_CCrequirements() < 0 ) + throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + fundingtxid = Parseuint256((char *)params[0].get_str().c_str()); + return(RewardsInfo(fundingtxid)); +} + UniValue faucetfund(const UniValue& params, bool fHelp) { UniValue result(UniValue::VOBJ); uint64_t funds; std::string hex; @@ -5148,25 +5169,25 @@ UniValue dicebet(const UniValue& params, bool fHelp) return(result); } -UniValue rewardslist(const UniValue& params, bool fHelp) +UniValue dicelist(const UniValue& params, bool fHelp) { uint256 tokenid; if ( fHelp || params.size() > 0 ) - throw runtime_error("rewardslist\n"); + throw runtime_error("dicelist\n"); if ( ensure_CCrequirements() < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); - return(RewardsList()); + return(DiceList()); } -UniValue rewardsinfo(const UniValue& params, bool fHelp) +UniValue diceinfo(const UniValue& params, bool fHelp) { uint256 fundingtxid; if ( fHelp || params.size() != 1 ) - throw runtime_error("rewardsinfo fundingtxid\n"); + throw runtime_error("diceinfo fundingtxid\n"); if ( ensure_CCrequirements() < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); fundingtxid = Parseuint256((char *)params[0].get_str().c_str()); - return(RewardsInfo(fundingtxid)); + return(DiceInfo(fundingtxid)); } UniValue tokenlist(const UniValue& params, bool fHelp)