remove cc payments and rewards
This commit is contained in:
@@ -6091,13 +6091,11 @@ 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/CCfsm.h"
|
||||
#include "../cc/CCauction.h"
|
||||
#include "../cc/CCOracles.h"
|
||||
#include "../cc/CCPrices.h"
|
||||
#include "../cc/CCHeir.h"
|
||||
#include "../cc/CCPayments.h"
|
||||
|
||||
int32_t ensure_CCrequirements(uint8_t evalcode) {
|
||||
CCerror = "";
|
||||
@@ -6326,123 +6324,6 @@ UniValue cclib(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
return(CClib(cp,method,jsonstr));
|
||||
}
|
||||
|
||||
UniValue payments_release(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
{
|
||||
struct CCcontract_info *cp,C;
|
||||
if ( fHelp || params.size() != 1 )
|
||||
throw runtime_error("paymentsrelease \"[%22createtxid%22,amount,(skipminimum)]\"\n");
|
||||
if ( ensure_CCrequirements(EVAL_PAYMENTS) < 0 )
|
||||
throw runtime_error(CC_REQUIREMENTS_MSG);
|
||||
const CKeyStore& keystore = *pwalletMain;
|
||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||
cp = CCinit(&C,EVAL_PAYMENTS);
|
||||
return(PaymentsRelease(cp,(char *)params[0].get_str().c_str()));
|
||||
}
|
||||
|
||||
UniValue payments_fund(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
{
|
||||
struct CCcontract_info *cp,C;
|
||||
if ( fHelp || params.size() != 1 )
|
||||
throw runtime_error("paymentsfund \"[%22createtxid%22,amount(,useopret)]\"\n");
|
||||
if ( ensure_CCrequirements(EVAL_PAYMENTS) < 0 )
|
||||
throw runtime_error(CC_REQUIREMENTS_MSG);
|
||||
const CKeyStore& keystore = *pwalletMain;
|
||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||
cp = CCinit(&C,EVAL_PAYMENTS);
|
||||
return(PaymentsFund(cp,(char *)params[0].get_str().c_str()));
|
||||
}
|
||||
|
||||
UniValue payments_merge(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
{
|
||||
struct CCcontract_info *cp,C;
|
||||
if ( fHelp || params.size() != 1 )
|
||||
throw runtime_error("paymentsmerge \"[%22createtxid%22]\"\n");
|
||||
if ( ensure_CCrequirements(EVAL_PAYMENTS) < 0 )
|
||||
throw runtime_error(CC_REQUIREMENTS_MSG);
|
||||
const CKeyStore& keystore = *pwalletMain;
|
||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||
cp = CCinit(&C,EVAL_PAYMENTS);
|
||||
return(PaymentsMerge(cp,(char *)params[0].get_str().c_str()));
|
||||
}
|
||||
|
||||
UniValue payments_txidopret(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
{
|
||||
struct CCcontract_info *cp,C;
|
||||
if ( fHelp || params.size() != 1 )
|
||||
throw runtime_error("paymentstxidopret \"[allocation,%22scriptPubKey%22(,%22destopret%22)]\"\n");
|
||||
if ( ensure_CCrequirements(EVAL_PAYMENTS) < 0 )
|
||||
throw runtime_error(CC_REQUIREMENTS_MSG);
|
||||
const CKeyStore& keystore = *pwalletMain;
|
||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||
cp = CCinit(&C,EVAL_PAYMENTS);
|
||||
return(PaymentsTxidopret(cp,(char *)params[0].get_str().c_str()));
|
||||
}
|
||||
|
||||
UniValue payments_create(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
{
|
||||
struct CCcontract_info *cp,C;
|
||||
if ( fHelp || params.size() != 1 )
|
||||
throw runtime_error("paymentscreate \"[lockedblocks,minamount,%22paytxid0%22,...,%22paytxidN%22]\"\n");
|
||||
if ( ensure_CCrequirements(EVAL_PAYMENTS) < 0 )
|
||||
throw runtime_error(CC_REQUIREMENTS_MSG);
|
||||
const CKeyStore& keystore = *pwalletMain;
|
||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||
cp = CCinit(&C,EVAL_PAYMENTS);
|
||||
return(PaymentsCreate(cp,(char *)params[0].get_str().c_str()));
|
||||
}
|
||||
|
||||
UniValue payments_airdrop(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
{
|
||||
struct CCcontract_info *cp,C;
|
||||
if ( fHelp || params.size() != 1 )
|
||||
throw runtime_error("paymentsairdrop \"[lockedblocks,minamount,mintoaddress,top,bottom,fixedFlag,%22excludeAddress%22,...,%22excludeAddressN%22]\"\n");
|
||||
if ( ensure_CCrequirements(EVAL_PAYMENTS) < 0 )
|
||||
throw runtime_error(CC_REQUIREMENTS_MSG);
|
||||
const CKeyStore& keystore = *pwalletMain;
|
||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||
cp = CCinit(&C,EVAL_PAYMENTS);
|
||||
return(PaymentsAirdrop(cp,(char *)params[0].get_str().c_str()));
|
||||
}
|
||||
|
||||
UniValue payments_airdroptokens(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
{
|
||||
struct CCcontract_info *cp,C;
|
||||
if ( fHelp || params.size() != 1 )
|
||||
throw runtime_error("payments_airdroptokens \"[%22tokenid%22,lockedblocks,minamount,mintoaddress,top,bottom,fixedFlag,%22excludePubKey%22,...,%22excludePubKeyN%22]\"\n");
|
||||
if ( ensure_CCrequirements(EVAL_PAYMENTS) < 0 )
|
||||
throw runtime_error(CC_REQUIREMENTS_MSG);
|
||||
const CKeyStore& keystore = *pwalletMain;
|
||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||
cp = CCinit(&C,EVAL_PAYMENTS);
|
||||
return(PaymentsAirdropTokens(cp,(char *)params[0].get_str().c_str()));
|
||||
}
|
||||
|
||||
UniValue payments_info(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
{
|
||||
struct CCcontract_info *cp,C;
|
||||
if ( fHelp || params.size() != 1 )
|
||||
throw runtime_error("paymentsinfo \"[%22createtxid%22]\"\n");
|
||||
if ( ensure_CCrequirements(EVAL_PAYMENTS) < 0 )
|
||||
throw runtime_error(CC_REQUIREMENTS_MSG);
|
||||
const CKeyStore& keystore = *pwalletMain;
|
||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||
cp = CCinit(&C,EVAL_PAYMENTS);
|
||||
return(PaymentsInfo(cp,(char *)params[0].get_str().c_str()));
|
||||
}
|
||||
|
||||
UniValue payments_list(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
{
|
||||
struct CCcontract_info *cp,C;
|
||||
if ( fHelp || params.size() != 0 )
|
||||
throw runtime_error("paymentslist\n");
|
||||
if ( ensure_CCrequirements(EVAL_PAYMENTS) < 0 )
|
||||
throw runtime_error(CC_REQUIREMENTS_MSG);
|
||||
const CKeyStore& keystore = *pwalletMain;
|
||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||
cp = CCinit(&C,EVAL_PAYMENTS);
|
||||
return(PaymentsList(cp,(char *)""));
|
||||
}
|
||||
|
||||
UniValue oraclesaddress(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
{
|
||||
struct CCcontract_info *cp,C; std::vector<unsigned char> pubkey;
|
||||
@@ -6456,19 +6337,6 @@ UniValue oraclesaddress(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
return(CCaddress(cp,(char *)"Oracles",pubkey));
|
||||
}
|
||||
|
||||
UniValue paymentsaddress(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
{
|
||||
struct CCcontract_info *cp,C; std::vector<unsigned char> pubkey;
|
||||
cp = CCinit(&C,EVAL_PAYMENTS);
|
||||
if ( fHelp || params.size() > 1 )
|
||||
throw runtime_error("paymentsaddress [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 *)"Payments",pubkey));
|
||||
}
|
||||
|
||||
UniValue heiraddress(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
{
|
||||
struct CCcontract_info *cp,C; std::vector<unsigned char> pubkey;
|
||||
@@ -6522,19 +6390,6 @@ UniValue faucetaddress(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
return(CCaddress(cp,(char *)"Faucet",pubkey));
|
||||
}
|
||||
|
||||
UniValue rewardsaddress(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
{
|
||||
struct CCcontract_info *cp,C; std::vector<unsigned char> pubkey;
|
||||
cp = CCinit(&C,EVAL_REWARDS);
|
||||
if ( fHelp || params.size() > 1 )
|
||||
throw runtime_error("rewardsaddress [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 *)"Rewards",pubkey));
|
||||
}
|
||||
|
||||
UniValue assetsaddress(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
{
|
||||
struct CCcontract_info *cp, C; std::vector<unsigned char> pubkey;
|
||||
@@ -6561,195 +6416,6 @@ UniValue tokenaddress(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
return(CCaddress(cp,(char *)"Tokens", pubkey));
|
||||
}
|
||||
|
||||
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;
|
||||
if ( fHelp || params.size() > 6 || params.size() < 2 )
|
||||
throw runtime_error("rewardscreatefunding name amount APR mindays maxdays mindeposit\n");
|
||||
if ( ensure_CCrequirements(EVAL_REWARDS) < 0 )
|
||||
throw runtime_error(CC_REQUIREMENTS_MSG);
|
||||
const CKeyStore& keystore = *pwalletMain;
|
||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||
// default to OOT params
|
||||
APR = 5 * COIN;
|
||||
minseconds = maxseconds = 60 * 3600 * 24;
|
||||
mindeposit = 100 * COIN;
|
||||
name = (char *)params[0].get_str().c_str();
|
||||
funds = atof(params[1].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 ( funds <= 0 ) {
|
||||
ERR_RESULT("funds must be positive");
|
||||
return result;
|
||||
}
|
||||
if ( params.size() > 2 )
|
||||
{
|
||||
APR = atof(params[2].get_str().c_str()) * COIN;
|
||||
if ( APR > REWARDSCC_MAXAPR )
|
||||
{
|
||||
ERR_RESULT("25% APR is maximum");
|
||||
return result;
|
||||
}
|
||||
if ( params.size() > 3 )
|
||||
{
|
||||
minseconds = atol(params[3].get_str().c_str()) * 3600 * 24;
|
||||
if ( minseconds < 0 ) {
|
||||
ERR_RESULT("mindays must be non-negative");
|
||||
return result;
|
||||
}
|
||||
if ( params.size() > 4 )
|
||||
{
|
||||
maxseconds = atol(params[4].get_str().c_str()) * 3600 * 24;
|
||||
if ( maxseconds <= 0 ) {
|
||||
ERR_RESULT("maxdays must be positive");
|
||||
return result;
|
||||
}
|
||||
if ( maxseconds < minseconds ) {
|
||||
ERR_RESULT("maxdays must be greater than mindays");
|
||||
return result;
|
||||
}
|
||||
if ( params.size() > 5 )
|
||||
mindeposit = atof(params[5].get_str().c_str()) * COIN + 0.00000000499999;
|
||||
if ( mindeposit <= 0 ) {
|
||||
ERR_RESULT("mindeposit must be positive");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
hex = RewardsCreateFunding(0,name,funds,APR,minseconds,maxseconds,mindeposit);
|
||||
if ( hex.size() > 0 )
|
||||
{
|
||||
result.push_back(Pair("result", "success"));
|
||||
result.push_back(Pair("hex", hex));
|
||||
} else ERR_RESULT("couldnt create rewards funding transaction");
|
||||
return(result);
|
||||
}
|
||||
|
||||
UniValue rewardslock(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("rewardslock name fundingtxid amount\n");
|
||||
if ( ensure_CCrequirements(EVAL_REWARDS) < 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;
|
||||
hex = RewardsLock(0,name,fundingtxid,amount);
|
||||
|
||||
if (!VALID_PLAN_NAME(name)) {
|
||||
ERR_RESULT(strprintf("Plan name can be at most %d ASCII characters",PLAN_NAME_MAX));
|
||||
return(result);
|
||||
}
|
||||
if ( CCerror != "" ){
|
||||
ERR_RESULT(CCerror);
|
||||
} else if ( amount > 0 ) {
|
||||
if ( hex.size() > 0 )
|
||||
{
|
||||
result.push_back(Pair("result", "success"));
|
||||
result.push_back(Pair("hex", hex));
|
||||
} else ERR_RESULT( "couldnt create rewards lock transaction");
|
||||
} else ERR_RESULT("amount must be positive");
|
||||
return(result);
|
||||
}
|
||||
|
||||
UniValue rewardsaddfunding(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("rewardsaddfunding name fundingtxid amount\n");
|
||||
if ( ensure_CCrequirements(EVAL_REWARDS) < 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;
|
||||
hex = RewardsAddfunding(0,name,fundingtxid,amount);
|
||||
|
||||
if (!VALID_PLAN_NAME(name)) {
|
||||
ERR_RESULT(strprintf("Plan name can be at most %d ASCII characters",PLAN_NAME_MAX));
|
||||
return(result);
|
||||
}
|
||||
if (CCerror != "") {
|
||||
ERR_RESULT(CCerror);
|
||||
} else if (amount > 0) {
|
||||
if ( hex.size() > 0 )
|
||||
{
|
||||
result.push_back(Pair("result", "success"));
|
||||
result.push_back(Pair("hex", hex));
|
||||
} else {
|
||||
result.push_back(Pair("result", "error"));
|
||||
result.push_back(Pair("error", "couldnt create rewards addfunding transaction"));
|
||||
}
|
||||
} else {
|
||||
ERR_RESULT("funding amount must be positive");
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
|
||||
UniValue rewardsunlock(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
{
|
||||
UniValue result(UniValue::VOBJ); std::string hex; char *name; uint256 fundingtxid,txid;
|
||||
if ( fHelp || params.size() > 3 || params.size() < 2 )
|
||||
throw runtime_error("rewardsunlock name fundingtxid [txid]\n");
|
||||
if ( ensure_CCrequirements(EVAL_REWARDS) < 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());
|
||||
|
||||
if (!VALID_PLAN_NAME(name)) {
|
||||
ERR_RESULT(strprintf("Plan name can be at most %d ASCII characters",PLAN_NAME_MAX));
|
||||
return(result);
|
||||
}
|
||||
if ( params.size() > 2 )
|
||||
txid = Parseuint256((char *)params[2].get_str().c_str());
|
||||
else memset(&txid,0,sizeof(txid));
|
||||
hex = RewardsUnlock(0,name,fundingtxid,txid);
|
||||
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 rewards unlock transaction");
|
||||
return(result);
|
||||
}
|
||||
|
||||
UniValue rewardslist(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
{
|
||||
if ( fHelp || params.size() > 0 )
|
||||
throw runtime_error("rewardslist\n");
|
||||
if ( ensure_CCrequirements(EVAL_REWARDS) < 0 )
|
||||
throw runtime_error(CC_REQUIREMENTS_MSG);
|
||||
const CKeyStore& keystore = *pwalletMain;
|
||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||
return(RewardsList());
|
||||
}
|
||||
|
||||
UniValue rewardsinfo(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
{
|
||||
uint256 fundingtxid;
|
||||
if ( fHelp || params.size() != 1 )
|
||||
throw runtime_error("rewardsinfo fundingtxid\n");
|
||||
if ( ensure_CCrequirements(EVAL_REWARDS) < 0 )
|
||||
throw runtime_error(CC_REQUIREMENTS_MSG);
|
||||
const CKeyStore& keystore = *pwalletMain;
|
||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||
fundingtxid = Parseuint256((char *)params[0].get_str().c_str());
|
||||
return(RewardsInfo(fundingtxid));
|
||||
}
|
||||
|
||||
|
||||
|
||||
UniValue oracleslist(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
{
|
||||
if ( fHelp || params.size() > 0 )
|
||||
|
||||
Reference in New Issue
Block a user