Browse Source

Dice list and dice info

metaverse
jl777 6 years ago
parent
commit
c857567a62
  1. 2
      src/cc/CCdice.h
  2. 2
      src/cc/dice.cpp
  3. 2
      src/rpcserver.cpp
  4. 3
      src/rpcserver.h
  5. 33
      src/wallet/rpcwallet.cpp

2
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

2
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);

2
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 },

3
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);

33
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)

Loading…
Cancel
Save