|
|
@ -6486,19 +6486,6 @@ UniValue paymentsaddress(const UniValue& params, bool fHelp, const CPubKey& mypk |
|
|
|
return(CCaddress(cp,(char *)"Payments",pubkey)); |
|
|
|
} |
|
|
|
|
|
|
|
UniValue gatewaysaddress(const UniValue& params, bool fHelp, const CPubKey& mypk) |
|
|
|
{ |
|
|
|
struct CCcontract_info *cp,C; std::vector<unsigned char> pubkey; |
|
|
|
cp = CCinit(&C,EVAL_GATEWAYS); |
|
|
|
if ( fHelp || params.size() > 1 ) |
|
|
|
throw runtime_error("gatewaysaddress [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 *)"Gateways",pubkey)); |
|
|
|
} |
|
|
|
|
|
|
|
UniValue heiraddress(const UniValue& params, bool fHelp, const CPubKey& mypk) |
|
|
|
{ |
|
|
|
struct CCcontract_info *cp,C; std::vector<unsigned char> pubkey; |
|
|
@ -6617,19 +6604,6 @@ UniValue tokenaddress(const UniValue& params, bool fHelp, const CPubKey& mypk) |
|
|
|
return(CCaddress(cp,(char *)"Tokens", pubkey)); |
|
|
|
} |
|
|
|
|
|
|
|
UniValue importgatewayaddress(const UniValue& params, bool fHelp, const CPubKey& mypk) |
|
|
|
{ |
|
|
|
struct CCcontract_info *cp,C; std::vector<unsigned char> pubkey; |
|
|
|
cp = CCinit(&C,EVAL_IMPORTGATEWAY); |
|
|
|
if ( fHelp || params.size() > 1 ) |
|
|
|
throw runtime_error("importgatewayddress [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 *)"ImportGateway", pubkey)); |
|
|
|
} |
|
|
|
|
|
|
|
UniValue channelslist(const UniValue& params, bool fHelp, const CPubKey& mypk) |
|
|
|
{ |
|
|
|
if ( fHelp || params.size() > 0 ) |
|
|
@ -6929,297 +6903,7 @@ UniValue rewardsinfo(const UniValue& params, bool fHelp, const CPubKey& mypk) |
|
|
|
return(RewardsInfo(fundingtxid)); |
|
|
|
} |
|
|
|
|
|
|
|
UniValue gatewayslist(const UniValue& params, bool fHelp, const CPubKey& mypk) |
|
|
|
{ |
|
|
|
if ( fHelp || params.size() > 0 ) |
|
|
|
throw runtime_error("gatewayslist\n"); |
|
|
|
if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) |
|
|
|
throw runtime_error(CC_REQUIREMENTS_MSG); |
|
|
|
const CKeyStore& keystore = *pwalletMain; |
|
|
|
return(GatewaysList()); |
|
|
|
} |
|
|
|
|
|
|
|
UniValue gatewaysexternaladdress(const UniValue& params, bool fHelp, const CPubKey& mypk) |
|
|
|
{ |
|
|
|
uint256 bindtxid; CPubKey pubkey; |
|
|
|
|
|
|
|
if ( fHelp || params.size() != 2) |
|
|
|
throw runtime_error("gatewaysexternaladdress bindtxid pubkey\n"); |
|
|
|
if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) |
|
|
|
throw runtime_error(CC_REQUIREMENTS_MSG); |
|
|
|
bindtxid = Parseuint256((char *)params[0].get_str().c_str()); |
|
|
|
pubkey = ParseHex(params[1].get_str().c_str()); |
|
|
|
return(GatewaysExternalAddress(bindtxid,pubkey)); |
|
|
|
} |
|
|
|
|
|
|
|
UniValue gatewaysdumpprivkey(const UniValue& params, bool fHelp, const CPubKey& mypk) |
|
|
|
{ |
|
|
|
uint256 bindtxid; |
|
|
|
|
|
|
|
if ( fHelp || params.size() != 2) |
|
|
|
throw runtime_error("gatewaysdumpprivkey bindtxid address\n"); |
|
|
|
if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) |
|
|
|
throw runtime_error(CC_REQUIREMENTS_MSG); |
|
|
|
bindtxid = Parseuint256((char *)params[0].get_str().c_str()); |
|
|
|
std::string strAddress = params[1].get_str(); |
|
|
|
CTxDestination dest = DecodeDestination(strAddress); |
|
|
|
if (!IsValidDestination(dest)) { |
|
|
|
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid transparent address"); |
|
|
|
} |
|
|
|
const CKeyID *keyID = boost::get<CKeyID>(&dest); |
|
|
|
if (!keyID) { |
|
|
|
throw JSONRPCError(RPC_TYPE_ERROR, "Address does not refer to a key"); |
|
|
|
} |
|
|
|
CKey vchSecret; |
|
|
|
if (!pwalletMain->GetKey(*keyID, vchSecret)) { |
|
|
|
throw JSONRPCError(RPC_WALLET_ERROR, "Private key for address " + strAddress + " is not known"); |
|
|
|
} |
|
|
|
return(GatewaysDumpPrivKey(bindtxid,vchSecret)); |
|
|
|
} |
|
|
|
|
|
|
|
UniValue gatewaysinfo(const UniValue& params, bool fHelp, const CPubKey& mypk) |
|
|
|
{ |
|
|
|
uint256 txid; |
|
|
|
if ( fHelp || params.size() != 1 ) |
|
|
|
throw runtime_error("gatewaysinfo bindtxid\n"); |
|
|
|
if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) |
|
|
|
throw runtime_error(CC_REQUIREMENTS_MSG); |
|
|
|
txid = Parseuint256((char *)params[0].get_str().c_str()); |
|
|
|
return(GatewaysInfo(txid)); |
|
|
|
} |
|
|
|
|
|
|
|
UniValue gatewaysbind(const UniValue& params, bool fHelp, const CPubKey& mypk) |
|
|
|
{ |
|
|
|
UniValue result(UniValue::VOBJ); uint256 tokenid,oracletxid; int32_t i; int64_t totalsupply; std::vector<CPubKey> pubkeys; |
|
|
|
uint8_t M,N,p1,p2,p3,p4=0; std::string coin; std::vector<unsigned char> pubkey; |
|
|
|
|
|
|
|
if ( fHelp || params.size() < 10 ) |
|
|
|
throw runtime_error("gatewaysbind tokenid oracletxid coin tokensupply M N pubkey(s) pubtype p2shtype wiftype [taddr]\n"); |
|
|
|
if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) |
|
|
|
throw runtime_error(CC_REQUIREMENTS_MSG); |
|
|
|
Lock2NSPV(mypk); |
|
|
|
tokenid = Parseuint256((char *)params[0].get_str().c_str()); |
|
|
|
oracletxid = Parseuint256((char *)params[1].get_str().c_str()); |
|
|
|
coin = params[2].get_str(); |
|
|
|
totalsupply = atol((char *)params[3].get_str().c_str()); |
|
|
|
M = atoi((char *)params[4].get_str().c_str()); |
|
|
|
N = atoi((char *)params[5].get_str().c_str()); |
|
|
|
if ( M > N || N == 0 || N > 15 || totalsupply < COIN/100 || tokenid == zeroid ) |
|
|
|
{ |
|
|
|
Unlock2NSPV(mypk); |
|
|
|
throw runtime_error("illegal M or N > 15 or tokensupply or invalid tokenid\n"); |
|
|
|
} |
|
|
|
if ( params.size() < 6+N+3 ) |
|
|
|
{ |
|
|
|
Unlock2NSPV(mypk); |
|
|
|
throw runtime_error("not enough parameters for N pubkeys\n"); |
|
|
|
} |
|
|
|
for (i=0; i<N; i++) |
|
|
|
{ |
|
|
|
pubkey = ParseHex(params[6+i].get_str().c_str()); |
|
|
|
if (pubkey.size()!= 33) |
|
|
|
{ |
|
|
|
Unlock2NSPV(mypk); |
|
|
|
throw runtime_error("invalid destination pubkey"); |
|
|
|
} |
|
|
|
pubkeys.push_back(pubkey2pk(pubkey)); |
|
|
|
} |
|
|
|
p1 = atoi((char *)params[6+N].get_str().c_str()); |
|
|
|
p2 = atoi((char *)params[6+N+1].get_str().c_str()); |
|
|
|
p3 = atoi((char *)params[6+N+2].get_str().c_str()); |
|
|
|
if (params.size() == 9+N+1) p4 = atoi((char *)params[9+N].get_str().c_str()); |
|
|
|
result = GatewaysBind(mypk,0,coin,tokenid,totalsupply,oracletxid,M,N,pubkeys,p1,p2,p3,p4); |
|
|
|
if ( result[JSON_HEXTX].getValStr().size() > 0 ) |
|
|
|
{ |
|
|
|
result.push_back(Pair("result", "success")); |
|
|
|
} |
|
|
|
Unlock2NSPV(mypk); |
|
|
|
return(result); |
|
|
|
} |
|
|
|
|
|
|
|
UniValue gatewaysdeposit(const UniValue& params, bool fHelp, const CPubKey& mypk) |
|
|
|
{ |
|
|
|
UniValue result(UniValue::VOBJ); int32_t i,claimvout,height; int64_t amount; std::string coin,deposithex; uint256 bindtxid,cointxid; std::vector<uint8_t>proof,destpub,pubkey; |
|
|
|
if ( fHelp || params.size() != 9 ) |
|
|
|
throw runtime_error("gatewaysdeposit bindtxid height coin cointxid claimvout deposithex proof destpub amount\n"); |
|
|
|
if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) |
|
|
|
throw runtime_error(CC_REQUIREMENTS_MSG); |
|
|
|
Lock2NSPV(mypk); |
|
|
|
bindtxid = Parseuint256((char *)params[0].get_str().c_str()); |
|
|
|
height = atoi((char *)params[1].get_str().c_str()); |
|
|
|
coin = params[2].get_str(); |
|
|
|
cointxid = Parseuint256((char *)params[3].get_str().c_str()); |
|
|
|
claimvout = atoi((char *)params[4].get_str().c_str()); |
|
|
|
deposithex = params[5].get_str(); |
|
|
|
proof = ParseHex(params[6].get_str()); |
|
|
|
destpub = ParseHex(params[7].get_str()); |
|
|
|
amount = atof((char *)params[8].get_str().c_str()) * COIN + 0.00000000499999; |
|
|
|
if ( amount <= 0 || claimvout < 0 ) |
|
|
|
{ |
|
|
|
Unlock2NSPV(mypk); |
|
|
|
throw runtime_error("invalid param: amount, numpks or claimvout\n"); |
|
|
|
} |
|
|
|
if (destpub.size()!= 33) |
|
|
|
{ |
|
|
|
Unlock2NSPV(mypk); |
|
|
|
throw runtime_error("invalid destination pubkey"); |
|
|
|
} |
|
|
|
result = GatewaysDeposit(mypk,0,bindtxid,height,coin,cointxid,claimvout,deposithex,proof,pubkey2pk(destpub),amount); |
|
|
|
if ( result[JSON_HEXTX].getValStr().size() > 0 ) |
|
|
|
{ |
|
|
|
result.push_back(Pair("result", "success")); |
|
|
|
} |
|
|
|
Unlock2NSPV(mypk); |
|
|
|
return(result); |
|
|
|
} |
|
|
|
|
|
|
|
UniValue gatewaysclaim(const UniValue& params, bool fHelp, const CPubKey& mypk) |
|
|
|
{ |
|
|
|
UniValue result(UniValue::VOBJ); std::string coin; uint256 bindtxid,deposittxid; std::vector<uint8_t>destpub; int64_t amount; |
|
|
|
if ( fHelp || params.size() != 5 ) |
|
|
|
throw runtime_error("gatewaysclaim bindtxid coin deposittxid destpub amount\n"); |
|
|
|
if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) |
|
|
|
throw runtime_error(CC_REQUIREMENTS_MSG); |
|
|
|
Lock2NSPV(mypk); |
|
|
|
bindtxid = Parseuint256((char *)params[0].get_str().c_str()); |
|
|
|
coin = params[1].get_str(); |
|
|
|
deposittxid = Parseuint256((char *)params[2].get_str().c_str()); |
|
|
|
destpub = ParseHex(params[3].get_str()); |
|
|
|
amount = atof((char *)params[4].get_str().c_str()) * COIN + 0.00000000499999; |
|
|
|
if (destpub.size()!= 33) |
|
|
|
{ |
|
|
|
Unlock2NSPV(mypk); |
|
|
|
throw runtime_error("invalid destination pubkey"); |
|
|
|
} |
|
|
|
result = GatewaysClaim(mypk,0,bindtxid,coin,deposittxid,pubkey2pk(destpub),amount); |
|
|
|
if ( result[JSON_HEXTX].getValStr().size() > 0 ) |
|
|
|
{ |
|
|
|
result.push_back(Pair("result", "success")); |
|
|
|
} |
|
|
|
Unlock2NSPV(mypk); |
|
|
|
return(result); |
|
|
|
} |
|
|
|
|
|
|
|
UniValue gatewayswithdraw(const UniValue& params, bool fHelp, const CPubKey& mypk) |
|
|
|
{ |
|
|
|
UniValue result(UniValue::VOBJ); uint256 bindtxid; int64_t amount; std::string coin; std::vector<uint8_t> withdrawpub; |
|
|
|
if ( fHelp || params.size() != 4 ) |
|
|
|
throw runtime_error("gatewayswithdraw bindtxid coin withdrawpub amount\n"); |
|
|
|
if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) |
|
|
|
throw runtime_error(CC_REQUIREMENTS_MSG); |
|
|
|
Lock2NSPV(mypk); |
|
|
|
bindtxid = Parseuint256((char *)params[0].get_str().c_str()); |
|
|
|
coin = params[1].get_str(); |
|
|
|
withdrawpub = ParseHex(params[2].get_str()); |
|
|
|
amount = atof((char *)params[3].get_str().c_str()) * COIN + 0.00000000499999; |
|
|
|
if (withdrawpub.size()!= 33) |
|
|
|
{ |
|
|
|
Unlock2NSPV(mypk); |
|
|
|
throw runtime_error("invalid destination pubkey"); |
|
|
|
} |
|
|
|
result = GatewaysWithdraw(mypk,0,bindtxid,coin,pubkey2pk(withdrawpub),amount); |
|
|
|
if ( result[JSON_HEXTX].getValStr().size() > 0 ) |
|
|
|
{ |
|
|
|
result.push_back(Pair("result", "success")); |
|
|
|
} |
|
|
|
Lock2NSPV(mypk); |
|
|
|
return(result); |
|
|
|
} |
|
|
|
|
|
|
|
UniValue gatewayspartialsign(const UniValue& params, bool fHelp, const CPubKey& mypk) |
|
|
|
{ |
|
|
|
UniValue result(UniValue::VOBJ); std::string coin,parthex; uint256 txid; |
|
|
|
if ( fHelp || params.size() != 3 ) |
|
|
|
throw runtime_error("gatewayspartialsign txidaddr refcoin hex\n"); |
|
|
|
if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) |
|
|
|
throw runtime_error(CC_REQUIREMENTS_MSG); |
|
|
|
Lock2NSPV(mypk); |
|
|
|
txid = Parseuint256((char *)params[0].get_str().c_str()); |
|
|
|
coin = params[1].get_str(); |
|
|
|
parthex = params[2].get_str(); |
|
|
|
result = GatewaysPartialSign(mypk,0,txid,coin,parthex); |
|
|
|
if ( result[JSON_HEXTX].getValStr().size() > 0 ) |
|
|
|
{ |
|
|
|
result.push_back(Pair("result", "success")); |
|
|
|
} |
|
|
|
Unlock2NSPV(mypk); |
|
|
|
return(result); |
|
|
|
} |
|
|
|
|
|
|
|
UniValue gatewayscompletesigning(const UniValue& params, bool fHelp, const CPubKey& mypk) |
|
|
|
{ |
|
|
|
UniValue result(UniValue::VOBJ); uint256 withdrawtxid; std::string txhex,coin; |
|
|
|
if ( fHelp || params.size() != 3 ) |
|
|
|
throw runtime_error("gatewayscompletesigning withdrawtxid coin hex\n"); |
|
|
|
if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) |
|
|
|
throw runtime_error(CC_REQUIREMENTS_MSG); |
|
|
|
Lock2NSPV(mypk); |
|
|
|
withdrawtxid = Parseuint256((char *)params[0].get_str().c_str()); |
|
|
|
coin = params[1].get_str(); |
|
|
|
txhex = params[2].get_str(); |
|
|
|
result = GatewaysCompleteSigning(mypk,0,withdrawtxid,coin,txhex); |
|
|
|
if ( result[JSON_HEXTX].getValStr().size() > 0 ) |
|
|
|
{ |
|
|
|
result.push_back(Pair("result", "success")); |
|
|
|
} |
|
|
|
Unlock2NSPV(mypk); |
|
|
|
return(result); |
|
|
|
} |
|
|
|
|
|
|
|
UniValue gatewaysmarkdone(const UniValue& params, bool fHelp, const CPubKey& mypk) |
|
|
|
{ |
|
|
|
UniValue result(UniValue::VOBJ); uint256 completetxid; std::string coin; |
|
|
|
if ( fHelp || params.size() != 2 ) |
|
|
|
throw runtime_error("gatewaysmarkdone completesigningtx coin\n"); |
|
|
|
if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) |
|
|
|
throw runtime_error(CC_REQUIREMENTS_MSG); |
|
|
|
Lock2NSPV(mypk); |
|
|
|
completetxid = Parseuint256((char *)params[0].get_str().c_str()); |
|
|
|
coin = params[1].get_str(); |
|
|
|
result = GatewaysMarkDone(mypk,0,completetxid,coin); |
|
|
|
if ( result[JSON_HEXTX].getValStr().size() > 0 ) |
|
|
|
{ |
|
|
|
result.push_back(Pair("result", "success")); |
|
|
|
} |
|
|
|
Unlock2NSPV(mypk); |
|
|
|
return(result); |
|
|
|
} |
|
|
|
|
|
|
|
UniValue gatewayspendingdeposits(const UniValue& params, bool fHelp, const CPubKey& mypk) |
|
|
|
{ |
|
|
|
uint256 bindtxid; std::string coin; |
|
|
|
if ( fHelp || params.size() != 2 ) |
|
|
|
throw runtime_error("gatewayspendingdeposits bindtxid coin\n"); |
|
|
|
if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) |
|
|
|
throw runtime_error(CC_REQUIREMENTS_MSG); |
|
|
|
bindtxid = Parseuint256((char *)params[0].get_str().c_str()); |
|
|
|
coin = params[1].get_str(); |
|
|
|
return(GatewaysPendingDeposits(mypk,bindtxid,coin)); |
|
|
|
} |
|
|
|
|
|
|
|
UniValue gatewayspendingwithdraws(const UniValue& params, bool fHelp, const CPubKey& mypk) |
|
|
|
{ |
|
|
|
uint256 bindtxid; std::string coin; |
|
|
|
if ( fHelp || params.size() != 2 ) |
|
|
|
throw runtime_error("gatewayspendingwithdraws bindtxid coin\n"); |
|
|
|
if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) |
|
|
|
throw runtime_error(CC_REQUIREMENTS_MSG); |
|
|
|
bindtxid = Parseuint256((char *)params[0].get_str().c_str()); |
|
|
|
coin = params[1].get_str(); |
|
|
|
return(GatewaysPendingWithdraws(mypk,bindtxid,coin)); |
|
|
|
} |
|
|
|
|
|
|
|
UniValue gatewaysprocessed(const UniValue& params, bool fHelp, const CPubKey& mypk) |
|
|
|
{ |
|
|
|
uint256 bindtxid; std::string coin; |
|
|
|
if ( fHelp || params.size() != 2 ) |
|
|
|
throw runtime_error("gatewaysprocessed bindtxid coin\n"); |
|
|
|
if ( ensure_CCrequirements(EVAL_GATEWAYS) < 0 ) |
|
|
|
throw runtime_error(CC_REQUIREMENTS_MSG); |
|
|
|
bindtxid = Parseuint256((char *)params[0].get_str().c_str()); |
|
|
|
coin = params[1].get_str(); |
|
|
|
return(GatewaysProcessedWithdraws(mypk,bindtxid,coin)); |
|
|
|
} |
|
|
|
|
|
|
|
UniValue oracleslist(const UniValue& params, bool fHelp, const CPubKey& mypk) |
|
|
|
{ |
|
|
|