Merge branch 'FSM' into jl777

This commit is contained in:
jl777
2019-07-08 17:56:27 -11:00
22 changed files with 1582 additions and 89 deletions

View File

@@ -5355,6 +5355,7 @@ int32_t verus_staked(CBlock *pBlock, CMutableTransaction &txNew, uint32_t &nBits
#include "../cc/CCHeir.h"
#include "../cc/CCMarmara.h"
#include "../cc/CCPayments.h"
#include "../cc/CCPegs.h"
int32_t ensure_CCrequirements(uint8_t evalcode)
{
@@ -7992,8 +7993,206 @@ UniValue heirlist(const UniValue& params, bool fHelp)
return (HeirList());
}
UniValue pegscreate(const UniValue& params, bool fHelp)
{
UniValue result(UniValue::VOBJ); int32_t i; std::vector<uint256> txids;
uint8_t N; std::string hex; uint256 txid; int64_t amount;
if ( fHelp || params.size()<3)
throw runtime_error("pegscreate amount N bindtxid1 [bindtxid2 ...]\n");
if ( ensure_CCrequirements(EVAL_PEGS) < 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);
amount = atof((char *)params[0].get_str().c_str()) * COIN + 0.00000000499999;
N = atoi((char *)params[1].get_str().c_str());
if ( params.size() < N+1 )
throw runtime_error("not enough parameters for N gatewaysbind\n");
for (i=0; i<N; i++)
{
txid = Parseuint256(params[i+2].get_str().c_str());
txids.push_back(txid);
}
hex = PegsCreate(0,amount,txids);
RETURN_IF_ERROR(CCerror);
if ( hex.size() > 0 )
{
result.push_back(Pair("result", "success"));
result.push_back(Pair("hex", hex));
} else ERR_RESULT("couldnt pegscreate");
return(result);
}
UniValue pegsfund(const UniValue& params, bool fHelp)
{
UniValue result(UniValue::VOBJ); std::string hex; uint256 pegstxid,tokenid; int64_t amount;
if ( fHelp || params.size()!=3)
throw runtime_error("pegsfund pegstxid tokenid amount\n");
if ( ensure_CCrequirements(EVAL_PEGS) < 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);
pegstxid = Parseuint256(params[0].get_str().c_str());
tokenid = Parseuint256(params[1].get_str().c_str());
amount = atof((char *)params[2].get_str().c_str()) * COIN + 0.00000000499999;
hex = PegsFund(0,pegstxid,tokenid,amount);
RETURN_IF_ERROR(CCerror);
if ( hex.size() > 0 )
{
result.push_back(Pair("result", "success"));
result.push_back(Pair("hex", hex));
} else ERR_RESULT("couldnt pegsfund");
return(result);
}
UniValue pegsget(const UniValue& params, bool fHelp)
{
UniValue result(UniValue::VOBJ); std::string hex; uint256 pegstxid,tokenid; int64_t amount;
if ( fHelp || params.size()!=3)
throw runtime_error("pegsget pegstxid tokenid amount\n");
if ( ensure_CCrequirements(EVAL_PEGS) < 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);
pegstxid = Parseuint256(params[0].get_str().c_str());
tokenid = Parseuint256(params[1].get_str().c_str());
amount = atof((char *)params[2].get_str().c_str()) * COIN + 0.00000000499999;
hex = PegsGet(0,pegstxid,tokenid,amount);
RETURN_IF_ERROR(CCerror);
if ( hex.size() > 0 )
{
result.push_back(Pair("result", "success"));
result.push_back(Pair("hex", hex));
} else ERR_RESULT("couldnt pegsget");
return(result);
}
UniValue pegsredeem(const UniValue& params, bool fHelp)
{
UniValue result(UniValue::VOBJ); std::string hex; uint256 pegstxid,tokenid; int64_t amount;
if ( fHelp || params.size()!=2)
throw runtime_error("pegsredem pegstxid tokenid\n");
if ( ensure_CCrequirements(EVAL_PEGS) < 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);
pegstxid = Parseuint256(params[0].get_str().c_str());
tokenid = Parseuint256(params[1].get_str().c_str());
hex = PegsRedeem(0,pegstxid,tokenid);
RETURN_IF_ERROR(CCerror);
if ( hex.size() > 0 )
{
result.push_back(Pair("result", "success"));
result.push_back(Pair("hex", hex));
} else ERR_RESULT("couldnt pegsredeem");
return(result);
}
UniValue pegsliquidate(const UniValue& params, bool fHelp)
{
UniValue result(UniValue::VOBJ); std::string hex; uint256 pegstxid,tokenid,accounttxid;
if ( fHelp || params.size()!=3)
throw runtime_error("pegsliquidate pegstxid tokenid accounttxid\n");
if ( ensure_CCrequirements(EVAL_PEGS) < 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);
pegstxid = Parseuint256(params[0].get_str().c_str());
tokenid = Parseuint256(params[1].get_str().c_str());
accounttxid = Parseuint256(params[2].get_str().c_str());
hex = PegsLiquidate(0,pegstxid,tokenid,accounttxid);
RETURN_IF_ERROR(CCerror);
if ( hex.size() > 0 )
{
result.push_back(Pair("result", "success"));
result.push_back(Pair("hex", hex));
} else ERR_RESULT("couldnt pegsliquidate");
return(result);
}
UniValue pegsexchange(const UniValue& params, bool fHelp)
{
UniValue result(UniValue::VOBJ); std::string hex; uint256 pegstxid,tokenid,accounttxid; int64_t amount;
if ( fHelp || params.size()!=3)
throw runtime_error("pegsliquidate pegstxid tokenid accounttxid\n");
if ( ensure_CCrequirements(EVAL_PEGS) < 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);
pegstxid = Parseuint256(params[0].get_str().c_str());
tokenid = Parseuint256(params[1].get_str().c_str());
amount = atof((char *)params[2].get_str().c_str()) * COIN + 0.00000000499999;
hex = PegsExchange(0,pegstxid,tokenid,amount);
RETURN_IF_ERROR(CCerror);
if ( hex.size() > 0 )
{
result.push_back(Pair("result", "success"));
result.push_back(Pair("hex", hex));
} else ERR_RESULT("couldnt pegsliquidate");
return(result);
}
UniValue pegsaccounthistory(const UniValue& params, bool fHelp)
{
uint256 pegstxid;
if ( fHelp || params.size() != 1 )
throw runtime_error("pegsaccounthistory pegstxid\n");
if ( ensure_CCrequirements(EVAL_GATEWAYS) < 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);
pegstxid = Parseuint256((char *)params[0].get_str().c_str());
return(PegsAccountHistory(pegstxid));
}
UniValue pegsaccountinfo(const UniValue& params, bool fHelp)
{
uint256 pegstxid;
if ( fHelp || params.size() != 1 )
throw runtime_error("pegsaccountinfo pegstxid\n");
if ( ensure_CCrequirements(EVAL_GATEWAYS) < 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);
pegstxid = Parseuint256((char *)params[0].get_str().c_str());
return(PegsAccountInfo(pegstxid));
}
UniValue pegsworstaccounts(const UniValue& params, bool fHelp)
{
uint256 pegstxid;
if ( fHelp || params.size() != 1 )
throw runtime_error("pegsworstaccounts pegstxid\n");
if ( ensure_CCrequirements(EVAL_GATEWAYS) < 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);
pegstxid = Parseuint256((char *)params[0].get_str().c_str());
return(PegsWorstAccounts(pegstxid));
}
UniValue pegsinfo(const UniValue& params, bool fHelp)
{
uint256 pegstxid;
if ( fHelp || params.size() != 1 )
throw runtime_error("pegsinfo pegstxid\n");
if ( ensure_CCrequirements(EVAL_GATEWAYS) < 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);
pegstxid = Parseuint256((char *)params[0].get_str().c_str());
return(PegsInfo(pegstxid));
}
extern UniValue dumpprivkey(const UniValue& params, bool fHelp); // in rpcdump.cpp
extern UniValue convertpassphrase(const UniValue& params, bool fHelp);