Clean up dicebet/dicestatus error handling and add new macro to make things easier

This commit is contained in:
Jonathan "Duke" Leto
2018-11-07 13:30:29 -08:00
parent e37833a344
commit d3f0b4269d
3 changed files with 22 additions and 21 deletions

View File

@@ -6168,12 +6168,11 @@ UniValue dicebet(const UniValue& params, bool fHelp)
}
if (amount > 0 && odds > 0) {
hex = DiceBet(0,name,fundingtxid,amount,odds,error);
RETURN_IF_ERROR(CCerror);
if ( hex.size() > 0 )
{
result.push_back(Pair("result", "success"));
result.push_back(Pair("hex", hex));
} else if ( error[0] != 0 ) {
ERR_RESULT(error);
}
} else {
ERR_RESULT("amount and odds must be positive");
@@ -6235,10 +6234,8 @@ UniValue dicestatus(const UniValue& params, bool fHelp)
if ( params.size() == 3 )
bettxid = Parseuint256((char *)params[2].get_str().c_str());
winnings = DiceStatus(0,name,fundingtxid,bettxid,error);
if ( error[0] != 0 ) {
ERR_RESULT(error);
return(result);
}
RETURN_IF_ERROR(CCerror);
result.push_back(Pair("result", "success"));
if ( winnings >= 0. )
{