remove dice, channels, lotto

This commit is contained in:
Duke
2024-01-11 22:30:50 -05:00
parent 2a713aeba2
commit 657bb1e25e
11 changed files with 6 additions and 3524 deletions

View File

@@ -6092,11 +6092,8 @@ int32_t hush_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33, void *pT
#include "../cc/CCfaucet.h"
#include "../cc/CCassets.h"
#include "../cc/CCrewards.h"
#include "../cc/CCdice.h"
#include "../cc/CCfsm.h"
#include "../cc/CCauction.h"
#include "../cc/CClotto.h"
#include "../cc/CCchannels.h"
#include "../cc/CCOracles.h"
#include "../cc/CCPrices.h"
#include "../cc/CCHeir.h"
@@ -6260,19 +6257,6 @@ UniValue setpubkey(const UniValue& params, bool fHelp, const CPubKey& mypk)
return result;
}
UniValue channelsaddress(const UniValue& params, bool fHelp, const CPubKey& mypk)
{
UniValue result(UniValue::VOBJ); struct CCcontract_info *cp,C; std::vector<unsigned char> pubkey;
cp = CCinit(&C,EVAL_CHANNELS);
if ( fHelp || params.size() != 1 )
throw runtime_error("channelsaddress pubkey\n");
if ( ensure_CCrequirements(cp->evalcode) < 0 )
throw runtime_error(CC_REQUIREMENTS_MSG);
pubkey = ParseHex(params[0].get_str().c_str());
return(CCaddress(cp,(char *)"Channels",pubkey));
}
UniValue cclibaddress(const UniValue& params, bool fHelp, const CPubKey& mypk)
{
struct CCcontract_info *cp,C; std::vector<unsigned char> pubkey; uint8_t evalcode = EVAL_FIRSTUSER;
@@ -6497,19 +6481,6 @@ UniValue heiraddress(const UniValue& params, bool fHelp, const CPubKey& mypk)
return(CCaddress(cp,(char *)"Heir",pubkey));
}
UniValue lottoaddress(const UniValue& params, bool fHelp, const CPubKey& mypk)
{
struct CCcontract_info *cp,C; std::vector<unsigned char> pubkey;
cp = CCinit(&C,EVAL_LOTTO);
if ( fHelp || params.size() > 1 )
throw runtime_error("lottoaddress [pubkey]\n");
if ( ensure_CCrequirements(cp->evalcode) < 0 )
throw runtime_error(CC_REQUIREMENTS_MSG);
if ( params.size() == 1 )
pubkey = ParseHex(params[0].get_str().c_str());
return(CCaddress(cp,(char *)"Lotto",pubkey));
}
UniValue FSMaddress(const UniValue& params, bool fHelp, const CPubKey& mypk)
{
struct CCcontract_info *cp,C; std::vector<unsigned char> pubkey;
@@ -6536,19 +6507,6 @@ UniValue auctionaddress(const UniValue& params, bool fHelp, const CPubKey& mypk)
return(CCaddress(cp,(char *)"Auction",pubkey));
}
UniValue diceaddress(const UniValue& params, bool fHelp, const CPubKey& mypk)
{
struct CCcontract_info *cp,C; std::vector<unsigned char> pubkey;
cp = CCinit(&C,EVAL_DICE);
if ( fHelp || params.size() > 1 )
throw runtime_error("diceaddress [pubkey]\n");
if ( ensure_CCrequirements(cp->evalcode) < 0 )
throw runtime_error(CC_REQUIREMENTS_MSG);
if ( params.size() == 1 )
pubkey = ParseHex(params[0].get_str().c_str());
return(CCaddress(cp,(char *)"Dice",pubkey));
}
UniValue faucetaddress(const UniValue& params, bool fHelp, const CPubKey& mypk)
{
struct CCcontract_info *cp,C; std::vector<unsigned char> pubkey;
@@ -6603,118 +6561,6 @@ UniValue tokenaddress(const UniValue& params, bool fHelp, const CPubKey& mypk)
return(CCaddress(cp,(char *)"Tokens", pubkey));
}
UniValue channelslist(const UniValue& params, bool fHelp, const CPubKey& mypk)
{
if ( fHelp || params.size() > 0 )
throw runtime_error("channelslist\n");
if ( ensure_CCrequirements(EVAL_CHANNELS) < 0 )
throw runtime_error(CC_REQUIREMENTS_MSG);
return(ChannelsList(mypk));
}
UniValue channelsinfo(const UniValue& params, bool fHelp, const CPubKey& mypk)
{
uint256 opentxid;
if ( fHelp || params.size() > 1 )
throw runtime_error("channelsinfo [opentxid]\n");
if ( ensure_CCrequirements(EVAL_CHANNELS) < 0 )
throw runtime_error(CC_REQUIREMENTS_MSG);
opentxid=zeroid;
if (params.size() > 0 && !params[0].isNull() && !params[0].get_str().empty())
opentxid = Parseuint256((char *)params[0].get_str().c_str());
return(ChannelsInfo(mypk,opentxid));
}
UniValue channelsopen(const UniValue& params, bool fHelp, const CPubKey& mypk)
{
UniValue result(UniValue::VOBJ); int32_t numpayments; int64_t payment; std::vector<unsigned char> destpub; struct CCcontract_info *cp,C;
uint256 tokenid=zeroid;
cp = CCinit(&C,EVAL_CHANNELS);
if ( fHelp || params.size() < 3 || params.size() > 4)
throw runtime_error("channelsopen destpubkey numpayments payment [tokenid]\n");
if ( ensure_CCrequirements(EVAL_CHANNELS) < 0 )
throw runtime_error(CC_REQUIREMENTS_MSG);
Lock2NSPV(mypk);
destpub = ParseHex(params[0].get_str().c_str());
numpayments = atoi(params[1].get_str().c_str());
payment = atol(params[2].get_str().c_str());
if (params.size()==4)
{
tokenid=Parseuint256((char *)params[3].get_str().c_str());
}
result = ChannelOpen(mypk,0,pubkey2pk(destpub),numpayments,payment,tokenid);
if ( result[JSON_HEXTX].getValStr().size() > 0 )
{
result.push_back(Pair("result", "success"));
}
Unlock2NSPV(mypk);
return(result);
}
UniValue channelspayment(const UniValue& params, bool fHelp, const CPubKey& mypk)
{
UniValue result(UniValue::VOBJ); struct CCcontract_info *cp,C; uint256 opentxid,secret=zeroid; int32_t n; int64_t amount;
cp = CCinit(&C,EVAL_CHANNELS);
if ( fHelp || params.size() < 2 || params.size() >3 )
throw runtime_error("channelspayment opentxid amount [secret]\n");
if ( ensure_CCrequirements(EVAL_CHANNELS) < 0 )
throw runtime_error(CC_REQUIREMENTS_MSG);
Lock2NSPV(mypk);
opentxid = Parseuint256((char *)params[0].get_str().c_str());
amount = atoi((char *)params[1].get_str().c_str());
if (params.size() > 2 && !params[2].isNull() && !params[2].get_str().empty())
{
secret = Parseuint256((char *)params[2].get_str().c_str());
}
result = ChannelPayment(mypk,0,opentxid,amount,secret);
if ( result[JSON_HEXTX].getValStr().size() > 0 )
{
result.push_back(Pair("result", "success"));
}
Unlock2NSPV(mypk);
return(result);
}
UniValue channelsclose(const UniValue& params, bool fHelp, const CPubKey& mypk)
{
UniValue result(UniValue::VOBJ); struct CCcontract_info *cp,C; uint256 opentxid;
cp = CCinit(&C,EVAL_CHANNELS);
if ( fHelp || params.size() != 1 )
throw runtime_error("channelsclose opentxid\n");
if ( ensure_CCrequirements(EVAL_CHANNELS) < 0 )
throw runtime_error(CC_REQUIREMENTS_MSG);
Lock2NSPV(mypk);
opentxid = Parseuint256((char *)params[0].get_str().c_str());
result = ChannelClose(mypk,0,opentxid);
if ( result[JSON_HEXTX].getValStr().size() > 0 )
{
result.push_back(Pair("result", "success"));
}
Unlock2NSPV(mypk);
return(result);
}
UniValue channelsrefund(const UniValue& params, bool fHelp, const CPubKey& mypk)
{
UniValue result(UniValue::VOBJ); struct CCcontract_info *cp,C; uint256 opentxid,closetxid;
cp = CCinit(&C,EVAL_CHANNELS);
if ( fHelp || params.size() != 2 )
throw runtime_error("channelsrefund opentxid closetxid\n");
if ( ensure_CCrequirements(EVAL_CHANNELS) < 0 )
throw runtime_error(CC_REQUIREMENTS_MSG);
Lock2NSPV(mypk);
opentxid = Parseuint256((char *)params[0].get_str().c_str());
closetxid = Parseuint256((char *)params[1].get_str().c_str());
result = ChannelRefund(mypk,0,opentxid,closetxid);
if ( result[JSON_HEXTX].getValStr().size() > 0 )
{
result.push_back(Pair("result", "success"));
}
Unlock2NSPV(mypk);
return(result);
}
UniValue rewardscreatefunding(const UniValue& params, bool fHelp, const CPubKey& mypk)
{
UniValue result(UniValue::VOBJ); char *name; int64_t funds,APR,minseconds,maxseconds,mindeposit; std::string hex;
@@ -7179,204 +7025,6 @@ UniValue faucetget(const UniValue& params, bool fHelp, const CPubKey& mypk)
return(result);
}
UniValue dicefund(const UniValue& params, bool fHelp, const CPubKey& mypk)
{
UniValue result(UniValue::VOBJ); int64_t funds,minbet,maxbet,maxodds,timeoutblocks; std::string hex; char *name;
if ( fHelp || params.size() != 6 )
throw runtime_error("dicefund name funds minbet maxbet maxodds timeoutblocks\n");
if ( ensure_CCrequirements(EVAL_DICE) < 0 )
throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet);
name = (char *)params[0].get_str().c_str();
funds = atof(params[1].get_str().c_str()) * COIN + 0.00000000499999;
minbet = atof(params[2].get_str().c_str()) * COIN + 0.00000000499999;
maxbet = atof(params[3].get_str().c_str()) * COIN + 0.00000000499999;
maxodds = atol(params[4].get_str().c_str());
timeoutblocks = atol(params[5].get_str().c_str());
if (!VALID_PLAN_NAME(name)) {
ERR_RESULT(strprintf("Plan name can be at most %d ASCII characters",PLAN_NAME_MAX));
return(result);
}
hex = DiceCreateFunding(0,name,funds,minbet,maxbet,maxodds,timeoutblocks);
if (CCerror != "") {
ERR_RESULT(CCerror);
} else if ( hex.size() > 0 ) {
result.push_back(Pair("result", "success"));
result.push_back(Pair("hex", hex));
} else {
ERR_RESULT( "couldnt create dice funding transaction");
}
return(result);
}
UniValue diceaddfunds(const UniValue& params, bool fHelp, const CPubKey& mypk)
{
UniValue result(UniValue::VOBJ); char *name; uint256 fundingtxid; int64_t amount; std::string hex;
if ( fHelp || params.size() != 3 )
throw runtime_error("diceaddfunds name fundingtxid amount\n");
if ( ensure_CCrequirements(EVAL_DICE) < 0 )
throw runtime_error(CC_REQUIREMENTS_MSG);
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());
amount = atof(params[2].get_str().c_str()) * COIN + 0.00000000499999;
if (!VALID_PLAN_NAME(name)) {
ERR_RESULT(strprintf("Plan name can be at most %d ASCII characters",PLAN_NAME_MAX));
return(result);
}
if ( amount > 0 ) {
hex = DiceAddfunding(0,name,fundingtxid,amount);
if (CCerror != "") {
ERR_RESULT(CCerror);
} else if ( hex.size() > 0 ) {
result.push_back(Pair("result", "success"));
result.push_back(Pair("hex", hex));
} else ERR_RESULT("couldnt create dice addfunding transaction");
} else ERR_RESULT("amount must be positive");
return(result);
}
UniValue dicebet(const UniValue& params, bool fHelp, const CPubKey& mypk)
{
UniValue result(UniValue::VOBJ); std::string hex,error; uint256 fundingtxid; int64_t amount,odds; char *name;
if ( fHelp || params.size() != 4 )
throw runtime_error("dicebet name fundingtxid amount odds\n");
if ( ensure_CCrequirements(EVAL_DICE) < 0 )
throw runtime_error(CC_REQUIREMENTS_MSG);
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());
amount = atof(params[2].get_str().c_str()) * COIN + 0.00000000499999;
odds = atol(params[3].get_str().c_str());
if (!VALID_PLAN_NAME(name)) {
ERR_RESULT(strprintf("Plan name can be at most %d ASCII characters",PLAN_NAME_MAX));
return(result);
}
if (amount > 0 && odds > 0) {
hex = DiceBet(0,name,fundingtxid,amount,odds);
RETURN_IF_ERROR(CCerror);
if ( hex.size() > 0 )
{
result.push_back(Pair("result", "success"));
result.push_back(Pair("hex", hex));
}
} else {
ERR_RESULT("amount and odds must be positive");
}
return(result);
}
UniValue dicefinish(const UniValue& params, bool fHelp, const CPubKey& mypk)
{
UniValue result(UniValue::VOBJ); uint8_t funcid; char *name; uint256 entropyused,fundingtxid,bettxid; std::string hex; int32_t r,entropyvout;
if ( fHelp || params.size() != 3 )
throw runtime_error("dicefinish name fundingtxid bettxid\n");
if ( ensure_CCrequirements(EVAL_DICE) < 0 )
throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet);
name = (char *)params[0].get_str().c_str();
if (!VALID_PLAN_NAME(name)) {
ERR_RESULT(strprintf("Plan name can be at most %d ASCII characters",PLAN_NAME_MAX));
return(result);
}
fundingtxid = Parseuint256((char *)params[1].get_str().c_str());
bettxid = Parseuint256((char *)params[2].get_str().c_str());
hex = DiceBetFinish(funcid,entropyused,entropyvout,&r,0,name,fundingtxid,bettxid,1,zeroid,-1);
if ( CCerror != "" )
{
ERR_RESULT(CCerror);
} else if ( hex.size() > 0 )
{
result.push_back(Pair("result", "success"));
result.push_back(Pair("hex", hex));
if ( funcid != 0 )
{
char funcidstr[2];
funcidstr[0] = funcid;
funcidstr[1] = 0;
result.push_back(Pair("funcid", funcidstr));
}
} else ERR_RESULT( "couldnt create dicefinish transaction");
return(result);
}
UniValue dicestatus(const UniValue& params, bool fHelp, const CPubKey& mypk)
{
UniValue result(UniValue::VOBJ); char *name; uint256 fundingtxid,bettxid; std::string status,error; double winnings;
if ( fHelp || (params.size() != 2 && params.size() != 3) )
throw runtime_error("dicestatus name fundingtxid bettxid\n");
if ( ensure_CCrequirements(EVAL_DICE) < 0 )
throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet);
name = (char *)params[0].get_str().c_str();
if (!VALID_PLAN_NAME(name)) {
ERR_RESULT(strprintf("Plan name can be at most %d ASCII characters",PLAN_NAME_MAX));
return(result);
}
fundingtxid = Parseuint256((char *)params[1].get_str().c_str());
memset(&bettxid,0,sizeof(bettxid));
if ( params.size() == 3 )
bettxid = Parseuint256((char *)params[2].get_str().c_str());
winnings = DiceStatus(0,name,fundingtxid,bettxid);
RETURN_IF_ERROR(CCerror);
result.push_back(Pair("result", "success"));
if ( winnings >= 0. )
{
if ( winnings > 0. )
{
if ( params.size() == 3 )
{
int64_t val;
val = winnings * COIN + 0.00000000499999;
result.push_back(Pair("status", "win"));
result.push_back(Pair("won", ValueFromAmount(val)));
}
else
{
result.push_back(Pair("status", "finalized"));
result.push_back(Pair("n", (int64_t)winnings));
}
}
else
{
if ( params.size() == 3 )
result.push_back(Pair("status", "loss"));
else result.push_back(Pair("status", "no pending bets"));
}
} else result.push_back(Pair("status", "bet still pending"));
return(result);
}
UniValue dicelist(const UniValue& params, bool fHelp, const CPubKey& mypk)
{
if ( fHelp || params.size() > 0 )
throw runtime_error("dicelist\n");
if ( ensure_CCrequirements(EVAL_DICE) < 0 )
throw runtime_error(CC_REQUIREMENTS_MSG);
return(DiceList());
}
UniValue diceinfo(const UniValue& params, bool fHelp, const CPubKey& mypk)
{
uint256 fundingtxid;
if ( fHelp || params.size() != 1 )
throw runtime_error("diceinfo fundingtxid\n");
if ( ensure_CCrequirements(EVAL_DICE) < 0 )
throw runtime_error(CC_REQUIREMENTS_MSG);
fundingtxid = Parseuint256((char *)params[0].get_str().c_str());
return(DiceInfo(fundingtxid));
}
UniValue tokenlist(const UniValue& params, bool fHelp, const CPubKey& mypk)
{
uint256 tokenid;