Browse Source

Delete auction/faucet/heir CC rpcs #381

duke
Duke 4 months ago
parent
commit
bb8a3c57a4
  1. 20
      src/rpc/server.cpp
  2. 11
      src/rpc/server.h
  3. 275
      src/wallet/rpcwallet.cpp

20
src/rpc/server.cpp

@ -376,9 +376,6 @@ static const CRPCCommand vRPCCommands[] =
{ "rawtransactions", "fundrawtransaction", &fundrawtransaction, false },
#endif
// auction
{ "auction", "auctionaddress", &auctionaddress, true },
// fsm
{ "FSM", "FSMaddress", &FSMaddress, true },
{ "FSM", "FSMcreate", &FSMcreate, true },
@ -400,23 +397,6 @@ static const CRPCCommand vRPCCommands[] =
{ "nSPV", "nspv_logout", &nspv_logout, true },
{ "nSPV", "nspv_listccmoduleunspent", &nspv_listccmoduleunspent, true },
// faucet
{ "faucet", "faucetinfo", &faucetinfo, true },
{ "faucet", "faucetfund", &faucetfund, true },
{ "faucet", "faucetget", &faucetget, true },
{ "faucet", "faucetaddress", &faucetaddress, true },
// Heir
{ "heir", "heiraddress", &heiraddress, true },
{ "heir", "heirfund", &heirfund, true },
{ "heir", "heiradd", &heiradd, true },
{ "heir", "heirclaim", &heirclaim, true },
/* { "heir", "heirfundtokens", &heirfundtokens, true },
{ "heir", "heiraddtokens", &heiraddtokens, true },
{ "heir", "heirclaimtokens", &heirclaimtokens, true },*/
{ "heir", "heirinfo", &heirinfo, true },
{ "heir", "heirlist", &heirlist, true },
{ "CClib", "cclibaddress", &cclibaddress, true },
{ "CClib", "cclibinfo", &cclibinfo, true },
{ "CClib", "cclib", &cclib, true },

11
src/rpc/server.h

@ -238,12 +238,6 @@ extern UniValue estimatefee(const UniValue& params, bool fHelp, const CPubKey& m
extern UniValue estimatepriority(const UniValue& params, bool fHelp, const CPubKey& mypk);
extern UniValue coinsupply(const UniValue& params, bool fHelp, const CPubKey& mypk);
extern UniValue assetsaddress(const UniValue& params, bool fHelp, const CPubKey& mypk);
extern UniValue heiraddress(const UniValue& params, bool fHelp, const CPubKey& mypk);
extern UniValue heirfund(const UniValue& params, bool fHelp, const CPubKey& mypk);
extern UniValue heiradd(const UniValue& params, bool fHelp, const CPubKey& mypk);
extern UniValue heirclaim(const UniValue& params, bool fHelp, const CPubKey& mypk);
extern UniValue heirinfo(const UniValue& params, bool fHelp, const CPubKey& mypk);
extern UniValue heirlist(const UniValue& params, bool fHelp, const CPubKey& mypk);
extern UniValue channelsaddress(const UniValue& params, bool fHelp, const CPubKey& mypk);
extern UniValue cclibaddress(const UniValue& params, bool fHelp, const CPubKey& mypk);
@ -255,15 +249,10 @@ extern UniValue channelsopen(const UniValue& params, bool fHelp, const CPubKey&
extern UniValue channelspayment(const UniValue& params, bool fHelp, const CPubKey& mypk);
extern UniValue channelsclose(const UniValue& params, bool fHelp, const CPubKey& mypk);
extern UniValue channelsrefund(const UniValue& params, bool fHelp, const CPubKey& mypk);
extern UniValue faucetfund(const UniValue& params, bool fHelp, const CPubKey& mypk);
extern UniValue faucetget(const UniValue& params, bool fHelp, const CPubKey& mypk);
extern UniValue faucetaddress(const UniValue& params, bool fHelp, const CPubKey& mypk);
extern UniValue faucetinfo(const UniValue& params, bool fHelp, const CPubKey& mypk);
extern UniValue FSMaddress(const UniValue& params, bool fHelp, const CPubKey& mypk);
extern UniValue FSMcreate(const UniValue& params, bool fHelp, const CPubKey& mypk);
extern UniValue FSMlist(const UniValue& params, bool fHelp, const CPubKey& mypk);
extern UniValue FSMinfo(const UniValue& params, bool fHelp, const CPubKey& mypk);
extern UniValue auctionaddress(const UniValue& params, bool fHelp, const CPubKey& mypk);
extern UniValue getnewaddress(const UniValue& params, bool fHelp, const CPubKey& mypk); // in rpcwallet.cpp
//extern UniValue getnewaddress64(const UniValue& params, bool fHelp, const CPubKey& mypk); // in rpcwallet.cpp

275
src/wallet/rpcwallet.cpp

@ -6092,13 +6092,8 @@ int32_t hush_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33, void *pT
return(siglen);
}
#include "../cc/CCfaucet.h"
#include "../cc/CCassets.h"
#include "../cc/CCfsm.h"
#include "../cc/CCauction.h"
#include "../cc/CCOracles.h"
#include "../cc/CCPrices.h"
#include "../cc/CCHeir.h"
int32_t ensure_CCrequirements(uint8_t evalcode) {
CCerror = "";
@ -6327,18 +6322,6 @@ UniValue cclib(const UniValue& params, bool fHelp, const CPubKey& mypk)
return(CClib(cp,method,jsonstr));
}
UniValue heiraddress(const UniValue& params, bool fHelp, const CPubKey& mypk)
{
struct CCcontract_info *cp,C; std::vector<unsigned char> pubkey;
cp = CCinit(&C,EVAL_HEIR);
if ( fHelp || params.size() > 1 )
throw runtime_error("heiraddress 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 *)"Heir",pubkey));
}
UniValue FSMaddress(const UniValue& params, bool fHelp, const CPubKey& mypk)
{
struct CCcontract_info *cp,C; std::vector<unsigned char> pubkey;
@ -6352,34 +6335,6 @@ UniValue FSMaddress(const UniValue& params, bool fHelp, const CPubKey& mypk)
return(CCaddress(cp,(char *)"FSM",pubkey));
}
UniValue auctionaddress(const UniValue& params, bool fHelp, const CPubKey& mypk)
{
struct CCcontract_info *cp,C; std::vector<unsigned char> pubkey;
cp = CCinit(&C,EVAL_AUCTION);
if ( fHelp || params.size() > 1 )
throw runtime_error("auctionaddress [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 *)"Auction",pubkey));
}
UniValue faucetaddress(const UniValue& params, bool fHelp, const CPubKey& mypk)
{
struct CCcontract_info *cp,C; std::vector<unsigned char> pubkey;
int error;
cp = CCinit(&C,EVAL_FAUCET);
if ( fHelp || params.size() > 1 )
throw runtime_error("faucetaddress [pubkey]\n");
error = ensure_CCrequirements(cp->evalcode);
if ( error < 0 )
throw runtime_error(strprintf("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet. ERR=%d\n", error));
if ( params.size() == 1 )
pubkey = ParseHex(params[0].get_str().c_str());
return(CCaddress(cp,(char *)"Faucet",pubkey));
}
UniValue assetsaddress(const UniValue& params, bool fHelp, const CPubKey& mypk)
{
struct CCcontract_info *cp, C; std::vector<unsigned char> pubkey;
@ -6434,98 +6389,6 @@ UniValue FSMinfo(const UniValue& params, bool fHelp, const CPubKey& mypk)
return(FSMInfo(FSMtxid));
}
UniValue faucetinfo(const UniValue& params, bool fHelp, const CPubKey& mypk)
{
uint256 fundingtxid;
if ( fHelp || params.size() != 0 )
throw runtime_error("faucetinfo\n");
if ( ensure_CCrequirements(EVAL_FAUCET) < 0 )
throw runtime_error(CC_REQUIREMENTS_MSG);
return(FaucetInfo());
}
UniValue faucetfund(const UniValue& params, bool fHelp, const CPubKey& mypk)
{
UniValue result(UniValue::VOBJ); int64_t funds; std::string hex;
if ( fHelp || params.size() != 1 )
throw runtime_error("faucetfund amount\n");
funds = atof(params[0].get_str().c_str()) * COIN + 0.00000000499999;
if ( (0) && HUSH_NSPV_SUPERLITE )
{
char coinaddr[64]; struct CCcontract_info *cp,C; CTxOut v;
cp = CCinit(&C,EVAL_FAUCET);
v = MakeCC1vout(EVAL_FAUCET,funds,GetUnspendable(cp,0));
Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(pubkey2pk(Mypubkey()))) << OP_CHECKSIG);
return(NSPV_spend(coinaddr,(char *)HexStr(v.scriptPubKey.begin()+1,v.scriptPubKey.end()-1).c_str(),funds));
}
if ( ensure_CCrequirements(EVAL_FAUCET) < 0 )
throw runtime_error(CC_REQUIREMENTS_MSG);
//const CKeyStore& keystore = *pwalletMain;
//LOCK2(cs_main, pwalletMain->cs_wallet);
bool lockWallet = false;
if (!mypk.IsValid()) // if mypk is not set then it is a local call, use local wallet in AddNormalInputs
lockWallet = true;
if (funds > 0)
{
if (lockWallet)
{
ENTER_CRITICAL_SECTION(cs_main);
ENTER_CRITICAL_SECTION(pwalletMain->cs_wallet);
}
result = FaucetFund(mypk, 0,(uint64_t) funds);
if (lockWallet)
{
LEAVE_CRITICAL_SECTION(pwalletMain->cs_wallet);
LEAVE_CRITICAL_SECTION(cs_main);
}
if ( result[JSON_HEXTX].getValStr().size() > 0 )
{
result.push_back(Pair("result", "success"));
//result.push_back(Pair("hex", hex));
} else ERR_RESULT("couldnt create faucet funding transaction");
} else ERR_RESULT( "funding amount must be positive");
return(result);
}
UniValue faucetget(const UniValue& params, bool fHelp, const CPubKey& mypk)
{
UniValue result(UniValue::VOBJ); std::string hex;
if ( fHelp || params.size() !=0 )
throw runtime_error("faucetget\n");
if ( ensure_CCrequirements(EVAL_FAUCET) < 0 )
throw runtime_error(CC_REQUIREMENTS_MSG);
bool lockWallet = false;
if (!mypk.IsValid()) // if mypk is not set then it is a local call, use wallet in AddNormalInputs (see check for this there)
lockWallet = true;
//const CKeyStore& keystore = *pwalletMain;
//LOCK2(cs_main, pwalletMain->cs_wallet);
if (lockWallet)
{
// use this instead LOCK2 because we need conditional wallet lock
ENTER_CRITICAL_SECTION(cs_main);
ENTER_CRITICAL_SECTION(pwalletMain->cs_wallet);
}
result = FaucetGet(mypk, 0);
if (lockWallet)
{
LEAVE_CRITICAL_SECTION(pwalletMain->cs_wallet);
LEAVE_CRITICAL_SECTION(cs_main);
}
if (result[JSON_HEXTX].getValStr().size() > 0 ) {
result.push_back(Pair("result", "success"));
//result.push_back(Pair("hex", hex));
} else ERR_RESULT("couldnt create faucet get transaction");
return(result);
}
UniValue getbalance64(const UniValue& params, bool fHelp, const CPubKey& mypk)
{
set<CBitcoinAddress> setAddress; vector<COutput> vecOutputs;
@ -6569,144 +6432,6 @@ UniValue getbalance64(const UniValue& params, bool fHelp, const CPubKey& mypk)
}
// heir contract functions for coins and tokens
UniValue heirfund(const UniValue& params, bool fHelp, const CPubKey& mypk)
{
UniValue result(UniValue::VOBJ);
uint256 tokenid = zeroid;
int64_t amount;
int64_t inactivitytime;
std::string hex;
std::vector<unsigned char> pubkey;
std::string name, memo;
if (!EnsureWalletIsAvailable(fHelp))
return NullUniValue;
if (fHelp || params.size() != 5 && params.size() != 6)
throw runtime_error("heirfund funds heirname heirpubkey inactivitytime memo [tokenid]\n");
if (ensure_CCrequirements(EVAL_HEIR) < 0)
throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet);
if (params.size() == 6) // tokens in satoshis:
amount = atoll(params[0].get_str().c_str());
else { // coins:
amount = 0;
if (!ParseFixedPoint(params[0].get_str(), 8, &amount)) // using ParseFixedPoint instead atof to avoid small round errors
amount = -1; // set error
}
if (amount <= 0) {
result.push_back(Pair("result", "error"));
result.push_back(Pair("error", "incorrect amount"));
return result;
}
name = params[1].get_str();
pubkey = ParseHex(params[2].get_str().c_str());
if (!pubkey2pk(pubkey).IsValid()) {
result.push_back(Pair("result", "error"));
result.push_back(Pair("error", "incorrect pubkey"));
return result;
}
inactivitytime = atoll(params[3].get_str().c_str());
if (inactivitytime <= 0) {
result.push_back(Pair("result", "error"));
result.push_back(Pair("error", "incorrect inactivity time"));
return result;
}
memo = params[4].get_str();
if (params.size() == 6) {
tokenid = Parseuint256((char*)params[5].get_str().c_str());
if (tokenid == zeroid) {
result.push_back(Pair("result", "error"));
result.push_back(Pair("error", "incorrect tokenid"));
return result;
}
}
if( tokenid == zeroid )
result = HeirFundCoinCaller(0, amount, name, pubkey2pk(pubkey), inactivitytime, memo);
else
result = HeirFundTokenCaller(0, amount, name, pubkey2pk(pubkey), inactivitytime, memo, tokenid);
return result;
}
UniValue heiradd(const UniValue& params, bool fHelp, const CPubKey& mypk)
{
UniValue result;
uint256 fundingtxid;
int64_t amount;
int64_t inactivitytime;
std::string hex;
std::vector<unsigned char> pubkey;
std::string name;
if (!EnsureWalletIsAvailable(fHelp))
return NullUniValue;
if (fHelp || params.size() != 2)
throw runtime_error("heiradd funds fundingtxid\n");
if (ensure_CCrequirements(EVAL_HEIR) < 0)
throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet);
std::string strAmount = params[0].get_str();
fundingtxid = Parseuint256((char*)params[1].get_str().c_str());
result = HeirAddCaller(fundingtxid, 0, strAmount);
return result;
}
UniValue heirclaim(const UniValue& params, bool fHelp, const CPubKey& mypk)
{
UniValue result; uint256 fundingtxid;
if (!EnsureWalletIsAvailable(fHelp))
return NullUniValue;
if (fHelp || params.size() != 2)
throw runtime_error("heirclaim funds fundingtxid\n");
if (ensure_CCrequirements(EVAL_HEIR) < 0)
throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet);
std::string strAmount = params[0].get_str();
fundingtxid = Parseuint256((char*)params[1].get_str().c_str());
result = HeirClaimCaller(fundingtxid, 0, strAmount);
return result;
}
UniValue heirinfo(const UniValue& params, bool fHelp, const CPubKey& mypk)
{
uint256 fundingtxid;
if (fHelp || params.size() != 1)
throw runtime_error("heirinfo fundingtxid\n");
if ( ensure_CCrequirements(EVAL_HEIR) < 0 )
throw runtime_error(CC_REQUIREMENTS_MSG);
fundingtxid = Parseuint256((char*)params[0].get_str().c_str());
return (HeirInfo(fundingtxid));
}
UniValue heirlist(const UniValue& params, bool fHelp, const CPubKey& mypk)
{
if (fHelp || params.size() != 0)
throw runtime_error("heirlist\n");
if ( ensure_CCrequirements(EVAL_HEIR) < 0 )
throw runtime_error(CC_REQUIREMENTS_MSG);
return (HeirList());
}
extern UniValue dumpprivkey(const UniValue& params, bool fHelp, const CPubKey& mypk); // in rpcdump.cpp
extern UniValue convertpassphrase(const UniValue& params, bool fHelp, const CPubKey& mypk);
extern UniValue importprivkey(const UniValue& params, bool fHelp, const CPubKey& mypk);

Loading…
Cancel
Save