|
|
@ -6102,7 +6102,6 @@ int32_t hush_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33, void *pT |
|
|
|
#include "../cc/CCPrices.h" |
|
|
|
#include "../cc/CCHeir.h" |
|
|
|
#include "../cc/CCPayments.h" |
|
|
|
#include "../cc/CCPegs.h" |
|
|
|
|
|
|
|
int32_t ensure_CCrequirements(uint8_t evalcode) { |
|
|
|
CCerror = ""; |
|
|
@ -6474,19 +6473,6 @@ UniValue oraclesaddress(const UniValue& params, bool fHelp, const CPubKey& mypk) |
|
|
|
return(CCaddress(cp,(char *)"Oracles",pubkey)); |
|
|
|
} |
|
|
|
|
|
|
|
UniValue pegsaddress(const UniValue& params, bool fHelp, const CPubKey& mypk) |
|
|
|
{ |
|
|
|
struct CCcontract_info *cp,C; std::vector<unsigned char> pubkey; |
|
|
|
cp = CCinit(&C,EVAL_PEGS); |
|
|
|
if ( fHelp || params.size() > 1 ) |
|
|
|
throw runtime_error("pegssaddress [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 *)"Pegs",pubkey)); |
|
|
|
} |
|
|
|
|
|
|
|
UniValue paymentsaddress(const UniValue& params, bool fHelp, const CPubKey& mypk) |
|
|
|
{ |
|
|
|
struct CCcontract_info *cp,C; std::vector<unsigned char> pubkey; |
|
|
@ -8381,192 +8367,6 @@ UniValue heirlist(const UniValue& params, bool fHelp, const CPubKey& mypk) |
|
|
|
return (HeirList()); |
|
|
|
} |
|
|
|
|
|
|
|
UniValue pegscreate(const UniValue& params, bool fHelp, const CPubKey& mypk) |
|
|
|
{ |
|
|
|
UniValue result(UniValue::VOBJ); int32_t i; std::vector<uint256> txids; |
|
|
|
uint8_t N; 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(CC_REQUIREMENTS_MSG); |
|
|
|
const CKeyStore& keystore = *pwalletMain; |
|
|
|
Lock2NSPV(mypk); |
|
|
|
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 ) |
|
|
|
{ |
|
|
|
Unlock2NSPV(mypk); |
|
|
|
throw runtime_error("not enough parameters for N pegscreate\n"); |
|
|
|
} |
|
|
|
for (i=0; i<N; i++) |
|
|
|
{ |
|
|
|
txid = Parseuint256(params[i+2].get_str().c_str()); |
|
|
|
txids.push_back(txid); |
|
|
|
} |
|
|
|
result = PegsCreate(mypk,0,amount,txids); |
|
|
|
if ( result[JSON_HEXTX].getValStr().size() > 0 ) |
|
|
|
{ |
|
|
|
result.push_back(Pair("result", "success")); |
|
|
|
} |
|
|
|
Unlock2NSPV(mypk); |
|
|
|
return(result); |
|
|
|
} |
|
|
|
|
|
|
|
UniValue pegsfund(const UniValue& params, bool fHelp, const CPubKey& mypk) |
|
|
|
{ |
|
|
|
UniValue result(UniValue::VOBJ); 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(CC_REQUIREMENTS_MSG); |
|
|
|
const CKeyStore& keystore = *pwalletMain; |
|
|
|
Lock2NSPV(mypk); |
|
|
|
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; |
|
|
|
result = PegsFund(mypk,0,pegstxid,tokenid,amount); |
|
|
|
if ( result[JSON_HEXTX].getValStr().size() > 0 ) |
|
|
|
{ |
|
|
|
result.push_back(Pair("result", "success")); |
|
|
|
} |
|
|
|
Unlock2NSPV(mypk); |
|
|
|
return(result); |
|
|
|
} |
|
|
|
|
|
|
|
UniValue pegsget(const UniValue& params, bool fHelp, const CPubKey& mypk) |
|
|
|
{ |
|
|
|
UniValue result(UniValue::VOBJ); 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(CC_REQUIREMENTS_MSG); |
|
|
|
Lock2NSPV(mypk); |
|
|
|
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; |
|
|
|
result = PegsGet(mypk,0,pegstxid,tokenid,amount); |
|
|
|
if ( result[JSON_HEXTX].getValStr().size() > 0 ) |
|
|
|
{ |
|
|
|
result.push_back(Pair("result", "success")); |
|
|
|
} |
|
|
|
Unlock2NSPV(mypk); |
|
|
|
return(result); |
|
|
|
} |
|
|
|
|
|
|
|
UniValue pegsredeem(const UniValue& params, bool fHelp, const CPubKey& mypk) |
|
|
|
{ |
|
|
|
UniValue result(UniValue::VOBJ); uint256 pegstxid,tokenid; int64_t amount; |
|
|
|
|
|
|
|
if ( fHelp || params.size()!=2) |
|
|
|
throw runtime_error("pegsredeem pegstxid tokenid\n"); |
|
|
|
if ( ensure_CCrequirements(EVAL_PEGS) < 0 ) |
|
|
|
throw runtime_error(CC_REQUIREMENTS_MSG); |
|
|
|
Lock2NSPV(mypk); |
|
|
|
pegstxid = Parseuint256(params[0].get_str().c_str()); |
|
|
|
tokenid = Parseuint256(params[1].get_str().c_str()); |
|
|
|
result = PegsRedeem(mypk,0,pegstxid,tokenid); |
|
|
|
if ( result[JSON_HEXTX].getValStr().size() > 0 ) |
|
|
|
{ |
|
|
|
result.push_back(Pair("result", "success")); |
|
|
|
} |
|
|
|
Unlock2NSPV(mypk); |
|
|
|
return(result); |
|
|
|
} |
|
|
|
|
|
|
|
UniValue pegsliquidate(const UniValue& params, bool fHelp, const CPubKey& mypk) |
|
|
|
{ |
|
|
|
UniValue result(UniValue::VOBJ); 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(CC_REQUIREMENTS_MSG); |
|
|
|
Lock2NSPV(mypk); |
|
|
|
pegstxid = Parseuint256(params[0].get_str().c_str()); |
|
|
|
tokenid = Parseuint256(params[1].get_str().c_str()); |
|
|
|
accounttxid = Parseuint256(params[2].get_str().c_str()); |
|
|
|
result = PegsLiquidate(mypk,0,pegstxid,tokenid,accounttxid); |
|
|
|
if ( result[JSON_HEXTX].getValStr().size() > 0 ) |
|
|
|
{ |
|
|
|
result.push_back(Pair("result", "success")); |
|
|
|
} |
|
|
|
Unlock2NSPV(mypk); |
|
|
|
return(result); |
|
|
|
} |
|
|
|
|
|
|
|
UniValue pegsexchange(const UniValue& params, bool fHelp, const CPubKey& mypk) |
|
|
|
{ |
|
|
|
UniValue result(UniValue::VOBJ); uint256 pegstxid,tokenid,accounttxid; int64_t amount; |
|
|
|
|
|
|
|
if ( fHelp || params.size()!=3) |
|
|
|
throw runtime_error("pegsexchange pegstxid tokenid amount\n"); |
|
|
|
if ( ensure_CCrequirements(EVAL_PEGS) < 0 ) |
|
|
|
throw runtime_error(CC_REQUIREMENTS_MSG); |
|
|
|
Lock2NSPV(mypk); |
|
|
|
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; |
|
|
|
result = PegsExchange(mypk,0,pegstxid,tokenid,amount); |
|
|
|
if ( result[JSON_HEXTX].getValStr().size() > 0 ) |
|
|
|
{ |
|
|
|
result.push_back(Pair("result", "success")); |
|
|
|
} |
|
|
|
Unlock2NSPV(mypk); |
|
|
|
return(result); |
|
|
|
} |
|
|
|
|
|
|
|
UniValue pegsaccounthistory(const UniValue& params, bool fHelp, const CPubKey& mypk) |
|
|
|
{ |
|
|
|
uint256 pegstxid; |
|
|
|
|
|
|
|
if ( fHelp || params.size() != 1 ) |
|
|
|
throw runtime_error("pegsaccounthistory pegstxid\n"); |
|
|
|
if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) |
|
|
|
throw runtime_error(CC_REQUIREMENTS_MSG); |
|
|
|
pegstxid = Parseuint256((char *)params[0].get_str().c_str()); |
|
|
|
return(PegsAccountHistory(mypk,pegstxid)); |
|
|
|
} |
|
|
|
|
|
|
|
UniValue pegsaccountinfo(const UniValue& params, bool fHelp, const CPubKey& mypk) |
|
|
|
{ |
|
|
|
uint256 pegstxid; |
|
|
|
|
|
|
|
if ( fHelp || params.size() != 1 ) |
|
|
|
throw runtime_error("pegsaccountinfo pegstxid\n"); |
|
|
|
if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) |
|
|
|
throw runtime_error(CC_REQUIREMENTS_MSG); |
|
|
|
pegstxid = Parseuint256((char *)params[0].get_str().c_str()); |
|
|
|
return(PegsAccountInfo(mypk,pegstxid)); |
|
|
|
} |
|
|
|
|
|
|
|
UniValue pegsworstaccounts(const UniValue& params, bool fHelp, const CPubKey& mypk) |
|
|
|
{ |
|
|
|
uint256 pegstxid; |
|
|
|
|
|
|
|
if ( fHelp || params.size() != 1 ) |
|
|
|
throw runtime_error("pegsworstaccounts pegstxid\n"); |
|
|
|
if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) |
|
|
|
throw runtime_error(CC_REQUIREMENTS_MSG); |
|
|
|
pegstxid = Parseuint256((char *)params[0].get_str().c_str()); |
|
|
|
return(PegsWorstAccounts(pegstxid)); |
|
|
|
} |
|
|
|
|
|
|
|
UniValue pegsinfo(const UniValue& params, bool fHelp, const CPubKey& mypk) |
|
|
|
{ |
|
|
|
uint256 pegstxid; |
|
|
|
|
|
|
|
if ( fHelp || params.size() != 1 ) |
|
|
|
throw runtime_error("pegsinfo pegstxid\n"); |
|
|
|
if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) |
|
|
|
throw runtime_error(CC_REQUIREMENTS_MSG); |
|
|
|
pegstxid = Parseuint256((char *)params[0].get_str().c_str()); |
|
|
|
return(PegsInfo(pegstxid)); |
|
|
|
} |
|
|
|
|
|
|
|
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); |
|
|
|