Dice status
This commit is contained in:
@@ -5238,11 +5238,11 @@ UniValue dicebet(const UniValue& params, bool fHelp)
|
||||
return(result);
|
||||
}
|
||||
|
||||
UniValue dicewinner(const UniValue& params, bool fHelp)
|
||||
UniValue dicefinish(const UniValue& params, bool fHelp)
|
||||
{
|
||||
UniValue result(UniValue::VOBJ); char *name; uint256 fundingtxid,bettxid; uint64_t amount; std::string hex; int32_t r;
|
||||
if ( fHelp || params.size() != 3 )
|
||||
throw runtime_error("dicewinner name fundingtxid bettxid\n");
|
||||
throw runtime_error("dicefinish name fundingtxid bettxid\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");
|
||||
const CKeyStore& keystore = *pwalletMain;
|
||||
@@ -5250,20 +5250,20 @@ UniValue dicewinner(const UniValue& params, bool fHelp)
|
||||
name = (char *)params[0].get_str().c_str();
|
||||
fundingtxid = Parseuint256((char *)params[1].get_str().c_str());
|
||||
bettxid = Parseuint256((char *)params[2].get_str().c_str());
|
||||
hex = DiceWinLoseTimeout(&r,0,name,fundingtxid,bettxid,1);
|
||||
hex = DiceBetFinish(&r,0,name,fundingtxid,bettxid,1);
|
||||
if ( hex.size() > 0 )
|
||||
{
|
||||
result.push_back(Pair("result", "success"));
|
||||
result.push_back(Pair("hex", hex));
|
||||
} else result.push_back(Pair("error", "couldnt create dicewinner transaction"));
|
||||
} else result.push_back(Pair("error", "couldnt create dicefinish transaction"));
|
||||
return(result);
|
||||
}
|
||||
|
||||
UniValue diceloser(const UniValue& params, bool fHelp)
|
||||
UniValue dicestatus(const UniValue& params, bool fHelp)
|
||||
{
|
||||
UniValue result(UniValue::VOBJ); char *name; uint256 fundingtxid,bettxid; uint64_t amount; std::string hex; int32_t r;
|
||||
UniValue result(UniValue::VOBJ); char *name; uint256 fundingtxid,bettxid; uint64_t amount; std::string status; int32_t r; double winnings;
|
||||
if ( fHelp || params.size() != 3 )
|
||||
throw runtime_error("diceloser name fundingtxid bettxid\n");
|
||||
throw runtime_error("dicestatus name fundingtxid bettxid\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");
|
||||
const CKeyStore& keystore = *pwalletMain;
|
||||
@@ -5271,33 +5271,13 @@ UniValue diceloser(const UniValue& params, bool fHelp)
|
||||
name = (char *)params[0].get_str().c_str();
|
||||
fundingtxid = Parseuint256((char *)params[1].get_str().c_str());
|
||||
bettxid = Parseuint256((char *)params[2].get_str().c_str());
|
||||
hex = DiceWinLoseTimeout(&r,0,name,fundingtxid,bettxid,-1);
|
||||
if ( hex.size() > 0 )
|
||||
winnings = DiceStatus(&r,0,name,fundingtxid,bettxid);
|
||||
result.push_back(Pair("result", "success"));
|
||||
if ( winnings != 0. )
|
||||
{
|
||||
result.push_back(Pair("result", "success"));
|
||||
result.push_back(Pair("hex", hex));
|
||||
} else result.push_back(Pair("error", "couldnt create diceloser transaction"));
|
||||
return(result);
|
||||
}
|
||||
|
||||
UniValue dicetimeout(const UniValue& params, bool fHelp)
|
||||
{
|
||||
UniValue result(UniValue::VOBJ); char *name; uint256 fundingtxid,bettxid; uint64_t amount; std::string hex; int32_t r;
|
||||
if ( fHelp || params.size() != 3 )
|
||||
throw runtime_error("dicetimeout name fundingtxid bettxid\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");
|
||||
const CKeyStore& keystore = *pwalletMain;
|
||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||
name = (char *)params[0].get_str().c_str();
|
||||
fundingtxid = Parseuint256((char *)params[1].get_str().c_str());
|
||||
bettxid = Parseuint256((char *)params[2].get_str().c_str());
|
||||
hex = DiceWinLoseTimeout(&r,0,name,fundingtxid,bettxid,0);
|
||||
if ( hex.size() > 0 )
|
||||
{
|
||||
result.push_back(Pair("result", "success"));
|
||||
result.push_back(Pair("hex", hex));
|
||||
} else result.push_back(Pair("error", "couldnt create dicetimeout transaction"));
|
||||
result.push_back(Pair("status", "win"));
|
||||
result.push_back(Pair("won", winnings));
|
||||
} else result.push_back(Pair("status", "loss"));
|
||||
return(result);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user