Merge branch 'duke' into dev
This commit is contained in:
@@ -287,8 +287,6 @@ libbitcoin_server_a_SOURCES = \
|
||||
cc/fsm.cpp \
|
||||
cc/heir.cpp \
|
||||
cc/oracles.cpp \
|
||||
cc/prices.cpp \
|
||||
cc/pegs.cpp \
|
||||
cc/payments.cpp \
|
||||
cc/gateways.cpp \
|
||||
cc/channels.cpp \
|
||||
@@ -471,10 +469,6 @@ if GLIBC_BACK_COMPAT
|
||||
libbitcoin_util_a_SOURCES += compat/glibc_compat.cpp
|
||||
endif
|
||||
|
||||
if ENABLE_TESTS
|
||||
libbitcoin_server_a_SOURCES += rpc/testtransactions.cpp
|
||||
endif
|
||||
|
||||
|
||||
# cli
|
||||
libbitcoin_cli_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
|
||||
@@ -721,7 +715,7 @@ endif
|
||||
$(AM_V_GEN) $(PROTOC) --cpp_out=$(@D) --proto_path=$(abspath $(<D) $<)
|
||||
|
||||
if ENABLE_TESTS
|
||||
include Makefile.test-hush.include
|
||||
#include Makefile.test-hush.include
|
||||
#include Makefile.test.include
|
||||
#include Makefile.gtest.include
|
||||
endif
|
||||
|
||||
@@ -16,24 +16,3 @@
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
#ifndef CC_PEGS_H
|
||||
#define CC_PEGS_H
|
||||
|
||||
#include "CCinclude.h"
|
||||
|
||||
bool PegsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn);
|
||||
|
||||
// CCcustom
|
||||
UniValue PegsCreate(const CPubKey& pk,uint64_t txfee,int64_t amount,std::vector<uint256> bindtxids);
|
||||
UniValue PegsFund(const CPubKey& pk,uint64_t txfee,uint256 pegstxid, uint256 tokenid, int64_t amount);
|
||||
UniValue PegsGet(const CPubKey& pk,uint64_t txfee,uint256 pegstxid, uint256 tokenid, int64_t amount);
|
||||
UniValue PegsRedeem(const CPubKey& pk,uint64_t txfee,uint256 pegstxid, uint256 tokenid);
|
||||
UniValue PegsLiquidate(const CPubKey& pk,uint64_t txfee,uint256 pegstxid, uint256 tokenid, uint256 liquidatetxid);
|
||||
UniValue PegsExchange(const CPubKey& pk,uint64_t txfee,uint256 pegstxid, uint256 tokenid, int64_t amount);
|
||||
UniValue PegsAccountHistory(const CPubKey& pk,uint256 pegstxid);
|
||||
UniValue PegsAccountInfo(const CPubKey& pk,uint256 pegstxid);
|
||||
UniValue PegsWorstAccounts(uint256 pegstxid);
|
||||
UniValue PegsInfo(uint256 pegstxid);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -382,16 +382,16 @@ struct CCcontract_info *CCinit(struct CCcontract_info *cp, uint8_t evalcode)
|
||||
strcpy(cp->normaladdr,PricesNormaladdr);
|
||||
strcpy(cp->CChexstr,PricesCChexstr);
|
||||
memcpy(cp->CCpriv,PricesCCpriv,32);
|
||||
cp->validate = PricesValidate;
|
||||
cp->ismyvin = IsPricesInput;
|
||||
//cp->validate = PricesValidate;
|
||||
//cp->ismyvin = IsPricesInput;
|
||||
break;
|
||||
case EVAL_PEGS:
|
||||
strcpy(cp->unspendableCCaddr,PegsCCaddr);
|
||||
strcpy(cp->normaladdr,PegsNormaladdr);
|
||||
strcpy(cp->CChexstr,PegsCChexstr);
|
||||
memcpy(cp->CCpriv,PegsCCpriv,32);
|
||||
cp->validate = PegsValidate;
|
||||
cp->ismyvin = IsPegsInput;
|
||||
//cp->validate = PegsValidate;
|
||||
//cp->ismyvin = IsPegsInput;
|
||||
break;
|
||||
case EVAL_PAYMENTS:
|
||||
strcpy(cp->unspendableCCaddr,PaymentsCCaddr);
|
||||
|
||||
1287
src/cc/pegs.cpp
1287
src/cc/pegs.cpp
File diff suppressed because it is too large
Load Diff
@@ -1,378 +0,0 @@
|
||||
// Copyright (c) 2016-2023 The Hush developers
|
||||
// Distributed under the GPLv3 software license, see the accompanying
|
||||
// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
|
||||
/******************************************************************************
|
||||
* Copyright © 2014-2019 The SuperNET Developers. *
|
||||
* *
|
||||
* See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at *
|
||||
* the top-level directory of this distribution for the individual copyright *
|
||||
* holder information and the developer policies on copyright and licensing. *
|
||||
* *
|
||||
* Unless otherwise agreed in a custom licensing agreement, no part of the *
|
||||
* SuperNET software, including this file may be copied, modified, propagated *
|
||||
* or distributed except according to the terms contained in the LICENSE file *
|
||||
* *
|
||||
* Removal or modification of this copyright notice is prohibited. *
|
||||
* *
|
||||
*****************************************************************************/
|
||||
//TODO: Finish deleting all this jl777 garbage. This CC will never function
|
||||
|
||||
#include "CCassets.h"
|
||||
#include "CCPrices.h"
|
||||
#include <cstdlib>
|
||||
#include <gmp.h>
|
||||
|
||||
#define IS_CHARINSTR(c, str) (std::string(str).find((char)(c)) != std::string::npos)
|
||||
#define NVOUT_CCMARKER 1
|
||||
#define NVOUT_NORMALMARKER 3
|
||||
|
||||
typedef struct OneBetData {
|
||||
int64_t positionsize;
|
||||
int32_t firstheight;
|
||||
int64_t costbasis;
|
||||
int64_t profits;
|
||||
|
||||
OneBetData() { positionsize = 0; firstheight = 0; costbasis = 0; profits = 0; }
|
||||
} onebetdata;
|
||||
|
||||
typedef struct BetInfo {
|
||||
uint256 txid;
|
||||
int64_t averageCostbasis, firstprice, lastprice, liquidationprice, equity;
|
||||
int64_t exitfee;
|
||||
int32_t lastheight;
|
||||
int16_t leverage;
|
||||
bool isOpen, isRekt;
|
||||
uint256 tokenid;
|
||||
|
||||
std::vector<uint16_t> vecparsed;
|
||||
std::vector<onebetdata> bets;
|
||||
CPubKey pk;
|
||||
|
||||
bool isUp;
|
||||
|
||||
BetInfo() {
|
||||
averageCostbasis = firstprice = lastprice = liquidationprice = equity = 0;
|
||||
lastheight = 0;
|
||||
leverage = 0;
|
||||
exitfee = 0;
|
||||
isOpen = isRekt = isUp = false;
|
||||
}
|
||||
} BetInfo;
|
||||
|
||||
typedef struct MatchedBookTotal {
|
||||
|
||||
int64_t diffLeveragedPosition;
|
||||
|
||||
} MatchedBookTotal;
|
||||
|
||||
typedef struct TotalFund {
|
||||
int64_t totalFund;
|
||||
int64_t totalActiveBets;
|
||||
int64_t totalCashout;
|
||||
int64_t totalRekt;
|
||||
int64_t totalEquity;
|
||||
|
||||
TotalFund() {
|
||||
totalFund = totalActiveBets = totalCashout = totalRekt = totalEquity = 0;
|
||||
}
|
||||
|
||||
} TotalFund;
|
||||
|
||||
int32_t prices_syntheticprofits(int64_t &costbasis, int32_t firstheight, int32_t height, int16_t leverage, std::vector<uint16_t> vec, int64_t positionsize, int64_t &profits, int64_t &outprice);
|
||||
static bool prices_isacceptableamount(const std::vector<uint16_t> &vecparsed, int64_t amount, int16_t leverage);
|
||||
|
||||
// helpers:
|
||||
|
||||
// returns true if there are only digits and no alphas or slashes in 's'
|
||||
inline bool is_weight_str(std::string s) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// start of consensus code
|
||||
|
||||
CScript prices_betopret(CPubKey mypk,int32_t height,int64_t amount,int16_t leverage,int64_t firstprice,std::vector<uint16_t> vec,uint256 tokenid)
|
||||
{
|
||||
CScript opret;
|
||||
opret << OP_RETURN << E_MARSHAL(ss << EVAL_PRICES << 'B' << mypk << height << amount << leverage << firstprice << vec << tokenid);
|
||||
return(opret);
|
||||
}
|
||||
|
||||
uint8_t prices_betopretdecode(CScript scriptPubKey,CPubKey &pk,int32_t &height,int64_t &amount,int16_t &leverage,int64_t &firstprice,std::vector<uint16_t> &vec,uint256 &tokenid)
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
CScript prices_addopret(uint256 bettxid,CPubKey mypk,int64_t amount)
|
||||
{
|
||||
CScript opret;
|
||||
return(opret);
|
||||
}
|
||||
|
||||
uint8_t prices_addopretdecode(CScript scriptPubKey,uint256 &bettxid,CPubKey &pk,int64_t &amount)
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
CScript prices_costbasisopret(uint256 bettxid,CPubKey mypk,int32_t height,int64_t costbasis)
|
||||
{
|
||||
CScript opret;
|
||||
return(opret);
|
||||
}
|
||||
|
||||
uint8_t prices_costbasisopretdecode(CScript scriptPubKey,uint256 &bettxid,CPubKey &pk,int32_t &height,int64_t &costbasis)
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
CScript prices_finalopret(bool isRekt, uint256 bettxid, CPubKey pk, int32_t lastheight, int64_t costbasis, int64_t lastprice, int64_t liquidationprice, int64_t equity, int64_t exitfee, uint32_t nonce)
|
||||
{
|
||||
CScript opret;
|
||||
return(opret);
|
||||
}
|
||||
|
||||
uint8_t prices_finalopretdecode(CScript scriptPubKey, uint256 &bettxid, CPubKey &pk, int32_t &lastheight, int64_t &costbasis, int64_t &lastprice, int64_t &liquidationprice, int64_t &equity, int64_t &exitfee)
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
// price opret basic validation and retrieval
|
||||
static uint8_t PricesCheckOpret(const CTransaction & tx, vscript_t &opret)
|
||||
{
|
||||
return (uint8_t)0;
|
||||
}
|
||||
|
||||
// validate bet tx helper
|
||||
static bool ValidateBetTx(struct CCcontract_info *cp, Eval *eval, const CTransaction & bettx)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// validate add funding tx helper
|
||||
static bool ValidateAddFundingTx(struct CCcontract_info *cp, Eval *eval, const CTransaction & addfundingtx, const CTransaction & vintx)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// validate final tx helper
|
||||
static bool ValidateFinalTx(struct CCcontract_info *cp, Eval *eval, const CTransaction & finaltx, const CTransaction & bettx)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PricesValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
// helper functions for rpc calls in rpcwallet.cpp
|
||||
|
||||
int64_t AddPricesInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, char *destaddr, int64_t total, int32_t maxinputs)
|
||||
{
|
||||
int64_t totalinputs = 0;
|
||||
return(totalinputs);
|
||||
}
|
||||
|
||||
double prices_minmarginpercent(int16_t leverage)
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
|
||||
UniValue prices_rawtxresult(UniValue &result, std::string rawtx, int32_t broadcastflag)
|
||||
{
|
||||
return(result);
|
||||
}
|
||||
|
||||
static std::string prices_getsourceexpression(const std::vector<uint16_t> &vec) {
|
||||
std::string expr;
|
||||
return expr;
|
||||
}
|
||||
|
||||
// helper functions to get synthetic expression reduced:
|
||||
|
||||
// return s true and needed operand count if string is opcode
|
||||
static bool prices_isopcode(const std::string &s, int &need)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// split pair onto two quotes divided by "_"
|
||||
static void prices_splitpair(const std::string &pair, std::string &upperquote, std::string &bottomquote)
|
||||
{
|
||||
}
|
||||
|
||||
// invert pair like BTS_USD -> USD_BTC
|
||||
static std::string prices_invertpair(const std::string &pair)
|
||||
{
|
||||
std::string s;
|
||||
return s;
|
||||
}
|
||||
|
||||
// invert pairs in operation accordingly to "/" operator, convert operator to * or ***
|
||||
static void prices_invertoperation(const std::vector<std::string> &vexpr, int p, std::vector<std::string> &voperation)
|
||||
{
|
||||
}
|
||||
|
||||
// reduce pairs in the operation, change or remove opcode if reduced
|
||||
static int prices_reduceoperands(std::vector<std::string> &voperation)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// substitute reduced operation in vectored expr
|
||||
static void prices_substitutereduced(std::vector<std::string> &vexpr, int p, std::vector<std::string> voperation)
|
||||
{
|
||||
}
|
||||
|
||||
// try to reduce synthetic expression by substituting "BTC_USD, BTC_EUR, 30, /" with "EUR_USD, 30" etc
|
||||
static std::string prices_getreducedexpr(const std::string &expr)
|
||||
{
|
||||
std::string reduced;
|
||||
return reduced;
|
||||
}
|
||||
|
||||
// parse synthetic expression into vector of codes
|
||||
int32_t prices_syntheticvec(std::vector<uint16_t> &vec, std::vector<std::string> synthetic)
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
// calculates price for synthetic expression
|
||||
int64_t prices_syntheticprice(std::vector<uint16_t> vec, int32_t height, int32_t minmax, int16_t leverage)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// calculates costbasis and profit/loss for the bet
|
||||
int32_t prices_syntheticprofits(int64_t &costbasis, int32_t firstheight, int32_t height, int16_t leverage, std::vector<uint16_t> vec, int64_t positionsize, int64_t &profits, int64_t &outprice)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// makes result json object
|
||||
void prices_betjson(UniValue &result, std::vector<OneBetData> bets, int16_t leverage, int32_t endheight, int64_t lastprice)
|
||||
{
|
||||
}
|
||||
|
||||
// retrieves costbasis from a tx spending bettx vout1 (deprecated)
|
||||
int64_t prices_costbasis(CTransaction bettx, uint256 &txidCostbasis)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// enumerates and retrieves added bets, returns the last baton txid
|
||||
int64_t prices_enumaddedbets(uint256 &batontxid, std::vector<OneBetData> &bets, uint256 bettxid)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// pricesbet rpc impl: make betting tx
|
||||
UniValue PricesBet(int64_t txfee, int64_t amount, int16_t leverage, std::vector<std::string> synthetic)
|
||||
{
|
||||
UniValue result(UniValue::VOBJ);
|
||||
return(result);
|
||||
}
|
||||
|
||||
// pricesaddfunding rpc impl: add yet another bet
|
||||
UniValue PricesAddFunding(int64_t txfee, uint256 bettxid, int64_t amount)
|
||||
{
|
||||
UniValue result(UniValue::VOBJ);
|
||||
return(result);
|
||||
}
|
||||
|
||||
// scan chain from the initial bet's first position upto the chain tip and calculate bet's costbasises and profits, breaks if rekt detected
|
||||
int32_t prices_scanchain(std::vector<OneBetData> &bets, int16_t leverage, std::vector<uint16_t> vec, int64_t &lastprice, int32_t &endheight) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// pricescostbasis rpc impl: set cost basis (open price) for the bet (deprecated)
|
||||
UniValue PricesSetcostbasis(int64_t txfee, uint256 bettxid)
|
||||
{
|
||||
UniValue result(UniValue::VOBJ);
|
||||
return(result);
|
||||
}
|
||||
|
||||
|
||||
// pricesaddfunding rpc impl: add yet another bet
|
||||
UniValue PricesRefillFund(int64_t amount)
|
||||
{
|
||||
UniValue result(UniValue::VOBJ);
|
||||
return(result);
|
||||
}
|
||||
|
||||
|
||||
int32_t prices_getbetinfo(uint256 bettxid, BetInfo &betinfo)
|
||||
{
|
||||
return (-420);
|
||||
}
|
||||
|
||||
// pricesrekt rpc: anyone can rekt a bet at some block where losses reached limit, collecting fee
|
||||
UniValue PricesRekt(int64_t txfee, uint256 bettxid, int32_t rektheight)
|
||||
{
|
||||
UniValue result(UniValue::VOBJ);
|
||||
return(result);
|
||||
}
|
||||
|
||||
// pricescashout rpc impl: bettor can cashout hit bet if it is not rekt
|
||||
UniValue PricesCashout(int64_t txfee, uint256 bettxid)
|
||||
{
|
||||
UniValue result(UniValue::VOBJ);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// pricesinfo rpc impl
|
||||
UniValue PricesInfo(uint256 bettxid, int32_t refheight)
|
||||
{
|
||||
UniValue result(UniValue::VOBJ);
|
||||
return(result);
|
||||
}
|
||||
|
||||
// priceslist rpc impl
|
||||
UniValue PricesList(uint32_t filter, CPubKey mypk)
|
||||
{
|
||||
UniValue result(UniValue::VARR);
|
||||
return(result);
|
||||
}
|
||||
|
||||
|
||||
static bool prices_addbookentry(uint256 txid, std::vector<BetInfo> &book)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
static bool prices_ispositionup(const std::vector<uint16_t> &vecparsed, int16_t leverage) {
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool prices_isopposite(BetInfo p1, BetInfo p2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static std::string findMatchedBook(const std::vector<uint16_t> &vecparsed, const std::map<std::string, std::vector<BetInfo> > & bookmatched) {
|
||||
return std::string("");
|
||||
}
|
||||
|
||||
|
||||
void prices_getorderbook(std::map<std::string, std::vector<BetInfo> > & bookmatched, std::map<std::string, MatchedBookTotal> &matchedTotals, TotalFund &fundTotals) {
|
||||
}
|
||||
|
||||
static bool prices_isacceptableamount(const std::vector<uint16_t> &vecparsed, int64_t amount, int16_t leverage) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// walk through uxtos on the global address
|
||||
// calculate the balance:
|
||||
// + rekt positions
|
||||
// = opposite positions
|
||||
// - unbalanced positions
|
||||
UniValue PricesGetOrderbook()
|
||||
{
|
||||
UniValue result(UniValue::VOBJ);
|
||||
return result;
|
||||
}
|
||||
@@ -174,7 +174,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
||||
}
|
||||
} else pk = _pk;
|
||||
|
||||
uint64_t deposits,voutsum=0; int32_t isrealtime,hushheight; uint32_t blocktime; const CChainParams& chainparams = Params();
|
||||
uint32_t blocktime; const CChainParams& chainparams = Params();
|
||||
bool fNotarizationBlock = false; std::vector<int8_t> NotarizationNotaries;
|
||||
|
||||
//fprintf(stderr,"%s: create new block with pubkey=%s\n", __func__, HexStr(pk).c_str());
|
||||
@@ -241,9 +241,6 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
||||
|
||||
//fprintf(stderr,"%s: nHeight=%d, consensusBranchId=%u, proposedTime=%u\n", __func__, nHeight, consensusBranchId, proposedTime);
|
||||
|
||||
voutsum = GetBlockSubsidy(nHeight,consensusParams) + 10000*COIN; // approx fees
|
||||
//fprintf(stderr,"%s: voutsum=%lu\n", __func__, voutsum);
|
||||
|
||||
if (proposedTime == nMedianTimePast)
|
||||
{
|
||||
// too fast or stuck, this addresses the too fast issue, while moving
|
||||
@@ -1058,6 +1055,9 @@ enum RandomXSolverCancelCheck
|
||||
Reason2
|
||||
};
|
||||
|
||||
int GetRandomXInterval() { return GetArg("-ac_randomx_interval",1024); }
|
||||
int GetRandomXBlockLag() { return GetArg("-ac_randomx_lag", 64); }
|
||||
|
||||
#ifdef ENABLE_WALLET
|
||||
void static RandomXMiner(CWallet *pwallet)
|
||||
#else
|
||||
@@ -1076,7 +1076,7 @@ void static RandomXMiner()
|
||||
// Each thread has its own counter
|
||||
unsigned int nExtraNonce = 0;
|
||||
|
||||
uint8_t *script; uint64_t total; int32_t i,j,gpucount=HUSH_MAXGPUCOUNT,notaryid = -1;
|
||||
int32_t gpucount=HUSH_MAXGPUCOUNT;
|
||||
while ( (ASSETCHAIN_INIT == 0 || HUSH_INITDONE == 0) )
|
||||
{
|
||||
sleep(1);
|
||||
@@ -1095,15 +1095,20 @@ void static RandomXMiner()
|
||||
miningTimer.start();
|
||||
|
||||
randomx_flags flags = randomx_get_flags();
|
||||
// TODO: attempt to use large pages and fall back to no large pages
|
||||
// flags |= RANDOMX_FLAG_LARGE_PAGES;
|
||||
flags |= RANDOMX_FLAG_FULL_MEM;
|
||||
//flags |= RANDOMX_FLAG_JIT;
|
||||
randomx_cache *randomxCache = randomx_alloc_cache(flags);
|
||||
randomx_cache *randomxCache = randomx_alloc_cache(flags | RANDOMX_FLAG_LARGE_PAGES | RANDOMX_FLAG_SECURE );
|
||||
if (randomxCache == NULL) {
|
||||
LogPrintf("RandomX cache is null, something is wrong, cannot mine!\n");
|
||||
return;
|
||||
LogPrintf("RandomX cache is null, trying without large pages...\n");
|
||||
randomxCache = randomx_alloc_cache(flags | RANDOMX_FLAG_SECURE);
|
||||
if (randomxCache == NULL) {
|
||||
LogPrintf("RandomX cache is null, trying without secure...\n");
|
||||
}
|
||||
randomxCache = randomx_alloc_cache(flags);
|
||||
if (randomxCache == NULL) {
|
||||
LogPrintf("RandomX cache is null, cannot mine!\n");
|
||||
}
|
||||
}
|
||||
|
||||
rxdebug("%s: created randomx flags + cache\n");
|
||||
randomx_dataset *randomxDataset = randomx_alloc_dataset(flags);
|
||||
rxdebug("%s: created dataset\n");
|
||||
@@ -1126,9 +1131,9 @@ void static RandomXMiner()
|
||||
// With the defaults of 1024 and 64
|
||||
// the key block will change every ~21.3 hours with a 75s block time
|
||||
// and every ~17 hours with the default 60s block time for HSCs
|
||||
int randomxInterval = GetArg("-ac_randomx_interval",1024);
|
||||
static int randomxInterval = GetRandomXInterval();
|
||||
// This lag is 80 mins for 75s blocktime and 64 mins for 60s (default) blocktime for HSCs
|
||||
int randomxBlockLag = GetArg("-ac_randomx_lag", 64);
|
||||
static int randomxBlockLag = GetRandomXBlockLag();
|
||||
randomx_vm *myVM = nullptr;
|
||||
|
||||
try {
|
||||
@@ -1196,14 +1201,27 @@ void static RandomXMiner()
|
||||
rxdebug("%s: initialized cache with keyHeight=%d, randomxBlockKey=%s\n", keyHeight, randomxBlockKey.ToString().c_str());
|
||||
}
|
||||
|
||||
//TODO: this is hardcoded to use 2 threads instead of the number of mining threads
|
||||
rxdebug("%s: initializing dataset with 2 threads\n");
|
||||
std::thread t1(&randomx_init_dataset, randomxDataset, randomxCache, 0, datasetItemCount / 2);
|
||||
std::thread t2(&randomx_init_dataset, randomxDataset, randomxCache, datasetItemCount / 2, datasetItemCount - datasetItemCount / 2);
|
||||
t1.join();
|
||||
t2.join();
|
||||
const int initThreadCount = std::thread::hardware_concurrency();
|
||||
if(initThreadCount > 1) {
|
||||
rxdebug("%s: initializing dataset with %d threads\n", initThreadCount);
|
||||
std::vector<std::thread> threads;
|
||||
uint32_t startItem = 0;
|
||||
auto perThread = datasetItemCount / initThreadCount;
|
||||
auto remainder = datasetItemCount % initThreadCount;
|
||||
for (int i = 0; i < initThreadCount; ++i) {
|
||||
auto count = perThread + (i == initThreadCount - 1 ? remainder : 0);
|
||||
threads.push_back(std::thread(&randomx_init_dataset, randomxDataset, randomxCache, startItem, count));
|
||||
startItem += count;
|
||||
}
|
||||
for (unsigned i = 0; i < threads.size(); ++i) {
|
||||
threads[i].join();
|
||||
}
|
||||
threads.clear();
|
||||
} else {
|
||||
rxdebug("%s: initializing dataset with 1 thread\n");
|
||||
randomx_init_dataset(randomxDataset, randomxCache, 0, datasetItemCount);
|
||||
}
|
||||
|
||||
// randomx_init_dataset(randomxDataset, randomxCache, 0, datasetItemCount);
|
||||
rxdebug("%s: dataset initialized\n");
|
||||
|
||||
myVM = randomx_create_vm(flags, nullptr, randomxDataset);
|
||||
@@ -1250,19 +1268,17 @@ void static RandomXMiner()
|
||||
return;
|
||||
}
|
||||
CBlock *pblock = &pblocktemplate->block;
|
||||
if ( SMART_CHAIN_SYMBOL[0] != 0 )
|
||||
|
||||
if ( ASSETCHAINS_REWARD[0] == 0 && !ASSETCHAINS_LASTERA )
|
||||
{
|
||||
if ( ASSETCHAINS_REWARD[0] == 0 && !ASSETCHAINS_LASTERA )
|
||||
if ( pblock->vtx.size() == 1 && pblock->vtx[0].vout.size() == 1 && Mining_height > ASSETCHAINS_MINHEIGHT )
|
||||
{
|
||||
if ( pblock->vtx.size() == 1 && pblock->vtx[0].vout.size() == 1 && Mining_height > ASSETCHAINS_MINHEIGHT )
|
||||
{
|
||||
static uint32_t counter;
|
||||
if ( counter++ < 10 )
|
||||
fprintf(stderr,"skip generating %s on-demand block, no tx avail\n",SMART_CHAIN_SYMBOL);
|
||||
sleep(10);
|
||||
continue;
|
||||
} else fprintf(stderr,"%s vouts.%d mining.%d vs %d\n",SMART_CHAIN_SYMBOL,(int32_t)pblock->vtx[0].vout.size(),Mining_height,ASSETCHAINS_MINHEIGHT);
|
||||
}
|
||||
static uint32_t counter;
|
||||
if ( counter++ < 10 )
|
||||
fprintf(stderr,"skip generating %s on-demand block, no tx avail\n",SMART_CHAIN_SYMBOL);
|
||||
sleep(10);
|
||||
continue;
|
||||
} else fprintf(stderr,"%s vouts.%d mining.%d vs %d\n",SMART_CHAIN_SYMBOL,(int32_t)pblock->vtx[0].vout.size(),Mining_height,ASSETCHAINS_MINHEIGHT);
|
||||
}
|
||||
rxdebug("%s: incrementing extra nonce\n");
|
||||
IncrementExtraNonce(pblock, pindexPrev, nExtraNonce);
|
||||
|
||||
@@ -356,19 +356,6 @@ static const CRPCCommand vRPCCommands[] =
|
||||
{ "crosschain", "migrate_createnotaryapprovaltransaction", &migrate_createnotaryapprovaltransaction, true },
|
||||
{ "crosschain", "selfimport", &selfimport, true },
|
||||
{ "crosschain", "importdual", &importdual, true },
|
||||
//ImportGateway
|
||||
{ "crosschain", "importgatewayddress", &importgatewayaddress, true },
|
||||
{ "crosschain", "importgatewayinfo", &importgatewayinfo, true },
|
||||
{ "crosschain", "importgatewaybind", &importgatewaybind, true },
|
||||
{ "crosschain", "importgatewaydeposit", &importgatewaydeposit, true },
|
||||
{ "crosschain", "importgatewaywithdraw", &importgatewaywithdraw, true },
|
||||
{ "crosschain", "importgatewaypartialsign", &importgatewaypartialsign, true },
|
||||
{ "crosschain", "importgatewaycompletesigning", &importgatewaycompletesigning, true },
|
||||
{ "crosschain", "importgatewaymarkdone", &importgatewaymarkdone, true },
|
||||
{ "crosschain", "importgatewaypendingwithdraws", &importgatewaypendingwithdraws, true },
|
||||
{ "crosschain", "importgatewayprocessed", &importgatewayprocessed, true },
|
||||
|
||||
|
||||
|
||||
/* Mining */
|
||||
{ "mining", "getblocktemplate", &getblocktemplate, true },
|
||||
@@ -473,9 +460,6 @@ static const CRPCCommand vRPCCommands[] =
|
||||
{ "oracles", "oraclessample", &oraclessample, true },
|
||||
{ "oracles", "oraclessamples", &oraclessamples, true },
|
||||
|
||||
// Pegs
|
||||
{ "pegs", "pegsaddress", &pegsaddress, true },
|
||||
|
||||
// Payments
|
||||
{ "payments", "paymentsaddress", &paymentsaddress, true },
|
||||
{ "payments", "paymentstxidopret", &payments_txidopret, true },
|
||||
@@ -492,23 +476,6 @@ static const CRPCCommand vRPCCommands[] =
|
||||
{ "CClib", "cclibinfo", &cclibinfo, true },
|
||||
{ "CClib", "cclib", &cclib, true },
|
||||
|
||||
// Gateways
|
||||
{ "gateways", "gatewaysaddress", &gatewaysaddress, true },
|
||||
{ "gateways", "gatewayslist", &gatewayslist, true },
|
||||
{ "gateways", "gatewaysexternaladdress", &gatewaysexternaladdress, true },
|
||||
{ "gateways", "gatewaysdumpprivkey", &gatewaysdumpprivkey, true },
|
||||
{ "gateways", "gatewaysinfo", &gatewaysinfo, true },
|
||||
{ "gateways", "gatewaysbind", &gatewaysbind, true },
|
||||
{ "gateways", "gatewaysdeposit", &gatewaysdeposit, true },
|
||||
{ "gateways", "gatewaysclaim", &gatewaysclaim, true },
|
||||
{ "gateways", "gatewayswithdraw", &gatewayswithdraw, true },
|
||||
{ "gateways", "gatewayspartialsign", &gatewayspartialsign, true },
|
||||
{ "gateways", "gatewayscompletesigning", &gatewayscompletesigning, true },
|
||||
{ "gateways", "gatewaysmarkdone", &gatewaysmarkdone, true },
|
||||
{ "gateways", "gatewayspendingdeposits", &gatewayspendingdeposits, true },
|
||||
{ "gateways", "gatewayspendingwithdraws", &gatewayspendingwithdraws, true },
|
||||
{ "gateways", "gatewaysprocessed", &gatewaysprocessed, true },
|
||||
|
||||
// dice
|
||||
{ "dice", "dicelist", &dicelist, true },
|
||||
{ "dice", "diceinfo", &diceinfo, true },
|
||||
@@ -539,18 +506,6 @@ static const CRPCCommand vRPCCommands[] =
|
||||
//{ "tokens", "tokenfillswap", &tokenfillswap, true },
|
||||
{ "tokens", "tokenconvert", &tokenconvert, true },
|
||||
|
||||
// pegs
|
||||
{ "pegs", "pegscreate", &pegscreate, true },
|
||||
{ "pegs", "pegsfund", &pegsfund, true },
|
||||
{ "pegs", "pegsget", &pegsget, true },
|
||||
{ "pegs", "pegsredeem", &pegsredeem, true },
|
||||
{ "pegs", "pegsliquidate", &pegsliquidate, true },
|
||||
{ "pegs", "pegsexchange", &pegsexchange, true },
|
||||
{ "pegs", "pegsaccounthistory", &pegsaccounthistory, true },
|
||||
{ "pegs", "pegsaccountinfo", &pegsaccountinfo, true },
|
||||
{ "pegs", "pegsworstaccounts", &pegsworstaccounts, true },
|
||||
{ "pegs", "pegsinfo", &pegsinfo, true },
|
||||
|
||||
/* Address index */
|
||||
{ "addressindex", "getaddressmempool", &getaddressmempool, true },
|
||||
{ "addressindex", "getaddressutxos", &getaddressutxos, false },
|
||||
|
||||
@@ -270,7 +270,6 @@ extern UniValue oraclessubscribe(const UniValue& params, bool fHelp, const CPubK
|
||||
extern UniValue oraclesdata(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
||||
extern UniValue oraclessample(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
||||
extern UniValue oraclessamples(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
||||
extern UniValue pegsaddress(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
||||
extern UniValue paymentsaddress(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
||||
extern UniValue payments_release(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
||||
extern UniValue payments_fund(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
||||
@@ -285,21 +284,6 @@ extern UniValue payments_list(const UniValue& params, bool fHelp, const CPubKey&
|
||||
extern UniValue cclibaddress(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
||||
extern UniValue cclibinfo(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
||||
extern UniValue cclib(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
||||
extern UniValue gatewaysaddress(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
||||
extern UniValue gatewayslist(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
||||
extern UniValue gatewaysinfo(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
||||
extern UniValue gatewaysdumpprivkey(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
||||
extern UniValue gatewaysexternaladdress(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
||||
extern UniValue gatewaysbind(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
||||
extern UniValue gatewaysdeposit(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
||||
extern UniValue gatewaysclaim(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
||||
extern UniValue gatewayswithdraw(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
||||
extern UniValue gatewayspartialsign(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
||||
extern UniValue gatewayscompletesigning(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
||||
extern UniValue gatewaysmarkdone(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
||||
extern UniValue gatewayspendingdeposits(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
||||
extern UniValue gatewayspendingwithdraws(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
||||
extern UniValue gatewaysprocessed(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
||||
extern UniValue channelslist(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
||||
extern UniValue channelsinfo(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
||||
extern UniValue channelsopen(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
||||
@@ -333,16 +317,6 @@ extern UniValue FSMcreate(const UniValue& params, bool fHelp, const CPubKey& myp
|
||||
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 pegscreate(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
||||
extern UniValue pegsfund(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
||||
extern UniValue pegsget(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
||||
extern UniValue pegsredeem(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
||||
extern UniValue pegsliquidate(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
||||
extern UniValue pegsexchange(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
||||
extern UniValue pegsaccounthistory(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
||||
extern UniValue pegsaccountinfo(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
||||
extern UniValue pegsworstaccounts(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
||||
extern UniValue pegsinfo(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
|
||||
|
||||
@@ -222,7 +222,6 @@ UniValue test_proof(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
return result;
|
||||
}
|
||||
|
||||
extern CScript prices_costbasisopret(uint256 bettxid, CPubKey mypk, int32_t height, int64_t costbasis);
|
||||
UniValue test_pricesmarker(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
{
|
||||
// make fake token tx:
|
||||
@@ -249,21 +248,3 @@ UniValue test_pricesmarker(const UniValue& params, bool fHelp, const CPubKey& my
|
||||
return(FinalizeCCTx(0, cp, mtx, myPubkey, 10000, prices_costbasisopret(bettxid, myPubkey, 100, 100)));
|
||||
}
|
||||
|
||||
|
||||
static const CRPCCommand commands[] =
|
||||
{ // category name actor (function) okSafeMode
|
||||
// --------------------- ------------------------ ----------------------- ----------
|
||||
|
||||
/* Not shown in help */
|
||||
{ "hidden", "test_ac", &test_ac, true },
|
||||
{ "hidden", "test_heirmarker", &test_heirmarker, true },
|
||||
{ "hidden", "test_proof", &test_proof, true },
|
||||
{ "hidden", "test_burntx", &test_burntx, true },
|
||||
{ "hidden", "test_pricesmarker", &test_pricesmarker, true }
|
||||
};
|
||||
|
||||
void RegisterTesttransactionsRPCCommands(CRPCTable &tableRPC)
|
||||
{
|
||||
for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++)
|
||||
tableRPC.appendCommand(commands[vcidx].name, &commands[vcidx]);
|
||||
}
|
||||
|
||||
@@ -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,43 +6473,6 @@ UniValue oraclesaddress(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
return(CCaddress(cp,(char *)"Oracles",pubkey));
|
||||
}
|
||||
|
||||
UniValue pricesaddress(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
{
|
||||
UniValue result(UniValue::VOBJ); struct CCcontract_info *cp,C,*assetscp,C2; std::vector<unsigned char> pubkey; CPubKey pk,planpk,pricespk; char myaddr[64],houseaddr[64],exposureaddr[64];
|
||||
cp = CCinit(&C,EVAL_PRICES);
|
||||
assetscp = CCinit(&C2,EVAL_PRICES);
|
||||
if ( fHelp || params.size() > 1 )
|
||||
throw runtime_error("pricesaddress [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());
|
||||
result = CCaddress(cp,(char *)"Prices",pubkey);
|
||||
if (mypk.IsValid()) pk=mypk;
|
||||
else pk = pubkey2pk(Mypubkey());
|
||||
pricespk = GetUnspendable(cp,0);
|
||||
GetCCaddress(assetscp,myaddr,pk);
|
||||
GetCCaddress1of2(assetscp,houseaddr,pricespk,planpk);
|
||||
GetCCaddress1of2(assetscp,exposureaddr,pricespk,pricespk);
|
||||
result.push_back(Pair("myaddr",myaddr)); // for holding my asssets
|
||||
result.push_back(Pair("houseaddr",houseaddr)); // globally accessible house assets
|
||||
result.push_back(Pair("exposureaddr",exposureaddr)); // tracking of exposure
|
||||
return(result);
|
||||
}
|
||||
|
||||
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;
|
||||
@@ -6524,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;
|
||||
@@ -6655,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 )
|
||||
@@ -6967,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)
|
||||
{
|
||||
@@ -7534,64 +7180,6 @@ UniValue faucetget(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
return(result);
|
||||
}
|
||||
|
||||
uint32_t pricesGetParam(UniValue param) {
|
||||
uint32_t filter = 0;
|
||||
if (STR_TOLOWER(param.get_str()) == "all")
|
||||
filter = 0;
|
||||
else if (STR_TOLOWER(param.get_str()) == "open")
|
||||
filter = 1;
|
||||
else if (STR_TOLOWER(param.get_str()) == "closed")
|
||||
filter = 2;
|
||||
else
|
||||
throw runtime_error("incorrect parameter\n");
|
||||
return filter;
|
||||
}
|
||||
|
||||
UniValue priceslist(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
{
|
||||
if ( fHelp || params.size() != 0 && params.size() != 1)
|
||||
throw runtime_error("priceslist [all|open|closed]\n");
|
||||
if ( ensure_CCrequirements(EVAL_PRICES) < 0 )
|
||||
throw runtime_error(CC_REQUIREMENTS_MSG);
|
||||
uint32_t filter = 0;
|
||||
if (params.size() == 1)
|
||||
filter = pricesGetParam(params[0]);
|
||||
|
||||
CPubKey emptypk;
|
||||
|
||||
return(PricesList(filter, emptypk));
|
||||
}
|
||||
|
||||
UniValue mypriceslist(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
{
|
||||
if (fHelp || params.size() != 0 && params.size() != 1)
|
||||
throw runtime_error("mypriceslist [all|open|closed]\n");
|
||||
if (ensure_CCrequirements(EVAL_PRICES) < 0)
|
||||
throw runtime_error(CC_REQUIREMENTS_MSG);
|
||||
|
||||
uint32_t filter = 0;
|
||||
if (params.size() == 1)
|
||||
filter = pricesGetParam(params[0]);
|
||||
CPubKey pk;
|
||||
if (mypk.IsValid()) pk=mypk;
|
||||
else pk = pubkey2pk(Mypubkey());
|
||||
|
||||
return(PricesList(filter, pk));
|
||||
}
|
||||
|
||||
UniValue pricesinfo(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
{
|
||||
uint256 bettxid; int32_t height;
|
||||
if ( fHelp || params.size() != 1 && params.size() != 2)
|
||||
throw runtime_error("pricesinfo bettxid [height]\n");
|
||||
if ( ensure_CCrequirements(EVAL_PRICES) < 0 )
|
||||
throw runtime_error(CC_REQUIREMENTS_MSG);
|
||||
bettxid = Parseuint256((char *)params[0].get_str().c_str());
|
||||
height = 0;
|
||||
if (params.size() == 2)
|
||||
height = atoi(params[1].get_str().c_str());
|
||||
return(PricesInfo(bettxid, height));
|
||||
}
|
||||
|
||||
UniValue dicefund(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
{
|
||||
@@ -8463,192 +8051,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);
|
||||
|
||||
Reference in New Issue
Block a user