Browse Source

Remove unused code

duke
Duke Leto 4 months ago
parent
commit
21530ba159
  1. 7
      src/Makefile.am
  2. 4
      src/cc/CCcustom.cpp
  3. 81
      src/cc/pegs.cpp
  4. 307
      src/cc/prices.cpp
  5. 19
      src/rpc/testtransactions.cpp
  6. 82
      src/wallet/rpcwallet.cpp

7
src/Makefile.am

@ -287,7 +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 \
@ -471,10 +470,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 +716,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

4
src/cc/CCcustom.cpp

@ -382,8 +382,8 @@ 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);

81
src/cc/pegs.cpp

@ -21,74 +21,7 @@
#include "key_io.h"
#include <gmp.h>
/*
pegs CC is able to create a coin backed (by any supported coin with gateways CC deposits) and pegged to any synthetic price that is able to be calculated based on prices CC
First, the prices CC needs to be understood, so the extensive comments at the top of ~/src/cc/prices.cpp needs to be understood.
The second aspect is the ability to import coins, as used by the crosschain burn/import and the -ac_import chains.
<one hour later...>
OK, now we are ready to describe the pegs CC. Let us imagine an -ac_import sidechain with HUSH gateways CC. Now we have each native coin fungible with the real HUSH via the gateways deposit/withdraw mechanism. Let us start with that and make a pegged and backed USD chain.
<alternatively we can start from a CC enabled chain with external value>
Here the native coin is HUSH, but we want USD, so there needs to be a way to convert the HUSH amounts into USD amounts. Something like "HUSHBTC, BTCUSD, *, 1" which is the prices CC syntax to calculate HUSH/USD, which is exactly what we need. So now we can assume that we have a block by block usable HUSH/USD price. implementationwise, there can be an -ac option like -ac_peg="HUSHBTC, BTCUSD, *, 1" and in conjunction with -ac_import=HUSH gateways CC sidechain, we now have a chain where deposit of HUSH issues the correct USD coins and redeem of USD coins releases the correct number of HUSH coins.
Are we done yet?
Not quite, as the prices of HUSH will be quite volatile relative to USD, which is good during bull markets, not so happy during bear markets. There are 2 halves to this problem, how to deal with massive price increase (easy to solve), how to solve 90% price drop (a lot harder).
In order to solve both, what is needed is an "account" based tracking which updates based on both price change, coins issued, payments made. So let us create an account that is based on a specific pubkey, where all relevant deposits, issuances, withdraws are tracked via appropriate vin/vout markers.
Let us modify the USD chain above so that only 80% of the possible USD is issued and 20% held in reserve. This 80% should be at least some easily changeable #define, or even an -ac parameter. We want the issued coins to be released without any encumberances, but the residual 20% value is still controlled (owned) but the depositor. This account has the amount of HUSH deposited and USD issued. At the moment of deposit, there will still be 20% equity left. Let us start with 1000 HUSH deposit, $1.5 per HUSH -> 800 HUSH converted to 1200 USD into depositor pubkey and the account of (1000 HUSH, -1200 USD) = 200 HUSH or $300 equity.
Now it becomes easy for the bull market case, which is to allow (for a fee like 1%) issuance of more USD as the equity increases, so let us imagine HUSH at $10:
(1000 HUSH, -1200 USD, 200HUSH reserve) -> $2000 equity, issue 80% -> $1600 using 160 HUSH
(1000 HUSH, -1200 USD, 200HUSH reserve, -160HUSH, issue $1600 USD, 40 HUSH reserve)
we have $2800 USD in circulation, 40 HUSH reserve left against $10000 marketcap of the original deposit. It it easy to see that there are never any problems with lack of HUSH to redeem the issued USD in a world where prices only go up. Total USD issuance can be limited by using a decentralized account tracking based on each deposit.
What is evident though is that with the constantly changing price and the various times that all the various deposits issue USD, the global reserves are something that will be hard to predict and in fact needs to be specifically tracked. Let us combine all accounts exposure in to a global reserves factor. This factor will control various max/min/ allowed and fee percentages.
Now we are prepared to handle the price goes down scenario. We can rely on the global equity/reserve ratio to be changing relatively slowly as the reference price is the smooted trustless oracles price. This means there will be enough blocks to adjust the global reserves percentage. What we need to do is liquidate specific positions that have the least reserves.
What does liquidation mean? It means a specific account will be purchased at below its current value and the HUSH withdrawn. Let us assume the price drops to $5:
(1000 HUSH, -1200 USD, 200HUSH reserve, -160HUSH, issue $1600 USD, 40 HUSH reserve) 1000 HUSH with 2800 USD issued so $2200 reserves. Let us assume it can be liquidated at a 10% discount, so for $2000 in addition to the $2800, the 5000 HUSH is able to be withdrawn. This removes 4800 USD coins for 1000 HUSH, which is a very low reserve amount of 4%. If a low reserve amount is removed from the system, then the global reserve amount must be improved.
In addition to the global reserves calculation, there needs to be a trigger percentage that enables positions to be liquidated. We also want to liquidate the worst positions, so in addition to the trigger percentage, there should be a liquidation threshold, and the liquidator would need to find 3 or more better positions that are beyond the liquidation threshold, to be able to liquidate. This will get us to at most 3 accounts that could be liquidated but are not able to, so some method to allow those to also be liquidated. The liquidating nodes are making instant profits, so they should be expected to do whatever blockchain scanning and proving to make things easy for the rest of the nodes.
One last issue is the normal redemption case where we are not liquidating. In this case, it should be done at the current marketprice, should improve the global reserves metrics and not cause anybody whose position was modified to have cause for complaint. Ideally, there would be an account that has the identical to the global reserve percentage and also at the same price as current marketprice, but this is not realistic, so we need to identify classes of accounts and consider which ones can be fully or partially liquidated to satisfy the constraints.
looking at our example account:
(1000 HUSH, -1200 USD, 200HUSH reserve, -160HUSH, issue $1600 USD, 40 HUSH reserve)
what sort of non-liquidation withdraw would be acceptable? if the base amount 1000 HUSH is reduced along with USD owed, then the reserve status will go up for the account. but that would seem to allow extra USD to be able to be issued. there should be no disadvantage from funding a withdraw, but also not any large advantage. it needs to be a neutral event....
One solution is to allow for the chance for any account to be liquidated, but the equity compensated for with a premium based on the account reserves. So in the above case, a premium of 5% on the 40HUSH reserve is paid to liquidate its account. Instead of 5% premium, a lower 1% can be done if based on the MAX(correlated[daywindow],smoothed) so we get something that is close to the current marketprice. To prevent people taking advantage of the slowness of the smoothed price to adjust, there would need to be a one day delay in the withdraw.
From a practical sense, it seems a day is a long time, so maybe having a way to pay a premium like 10%, or wait a day to get the MAX(correlated[daywindow],smoothed) price. This price "jumping" might also be taken advantage of in the deposit side, so similar to prices CC it seems good to have the MAX(correlated[daywindow],smoothed) method.
Now, we have a decentralized mechanism to handle the price going lower! Combined with the fully decentralized method new USD coins are issued, makes this argubably the first decentralized blockchain that is both backed and pegged. There is the reliance on the gateways CC multisig signers, so there is a fundamental federated trust for chains without intrinsic value.
Also, notice that the flexibly syntax of prices CC allows to define pegs easily for virtually any type of synthetic, and all the ECB fiats can easily get a backed and pegged coin.
Let us now consider how to enforce a peg onto a specific gateways CC token. If this can also be achieved, then a full DEX for all the different gateways CC supported coins can be created onto a single fiat denominated chain.
I think just having a pegscreate rpc call that binds an existing gateways create to a price CC syntax price will be almost enough to support this. Let us assume a USD stablechain and we have a BTC token, then pegscreate <btc gateways txid> "BTCUSD, 1"
that will specify using the BTCUSD price, so now we need to create a <txid> based way to do tokenbid/tokenask. For a <txid> based price, the smoothed price is substituted.
There is the issue of the one day delay, so it might make sense to allow specific bid/ask to be based on some simple combinations of the three possible prices. it might even be possible to go a bit overboard and make a forth like syntax to define the dynamic price for a bid, which maybe at times wont be valid, like it is only valid if the three prices are within 1% of each other. But all that seems over complex and for initial release it can just use the mined, correlated or smoothed price, with some specified percentage offset
Implementation notes:
make sure that fees and markers that can be sent to an unspendable address are sent to: RNdqHx26GWy9bk8MtmH1UiXjQcXE4RKK2P, this is the address for BOTS
*/
//NOTE: in process of removal
// start of consensus code
#ifndef PEGS_THRESHOLDS
@ -105,8 +38,6 @@ extern uint64_t ASSETCHAINS_PEGSCCPARAMS[3];
extern uint8_t DecodeGatewaysBindOpRet(char *depositaddr,const CScript &scriptPubKey,uint256 &tokenid,std::string &coin,int64_t &totalsupply,uint256 &oracletxid,uint8_t &M,uint8_t &N,std::vector<CPubKey> &gatewaypubkeys,uint8_t &taddr,uint8_t &prefix,uint8_t &prefix2,uint8_t &wiftype);
extern int64_t GetTokenBalance(CPubKey pk, uint256 tokenid);
extern int32_t hush_currentheight();
extern int32_t prices_syntheticvec(std::vector<uint16_t> &vec, std::vector<std::string> synthetic);
extern int64_t prices_syntheticprice(std::vector<uint16_t> vec, int32_t height, int32_t minmax, int16_t leverage);
CScript EncodePegsCreateOpRet(std::vector<uint256> bindtxids)
{
@ -522,16 +453,6 @@ char PegsFindAccount(struct CCcontract_info *cp,CPubKey pk,uint256 pegstxid, uin
int64_t PegsGetTokenPrice(uint256 tokenid)
{
int64_t price; CTransaction tokentx; uint256 hashBlock; std::vector<uint16_t> exp;
std::string name,desc; std::vector<uint8_t> vorigpubkey; int32_t numvouts;
if (myGetTransaction(tokenid,tokentx,hashBlock)!=0 && (numvouts=tokentx.vout.size())>0 && DecodeTokenCreateOpRet(tokentx.vout[numvouts-1].scriptPubKey,vorigpubkey,name,desc)=='c')
{
std::vector<std::string> vexpr;
SplitStr(desc, vexpr);
if (prices_syntheticvec(exp, vexpr)>=0 && (price = prices_syntheticprice(exp, hush_currentheight(), 0, 1))>=0)
return (price);
}
return (0);
}

307
src/cc/prices.cpp

@ -1,307 +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 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;
}
// retrieves costbasis from a tx spending bettx vout1 (deprecated)
int64_t prices_costbasis(CTransaction bettx, uint256 &txidCostbasis)
{
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);
}
// 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);
}
// 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_ispositionup(const std::vector<uint16_t> &vecparsed, int16_t leverage) {
return false;
}
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;
}

19
src/rpc/testtransactions.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]);
}

82
src/wallet/rpcwallet.cpp

@ -6474,30 +6474,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;
@ -7534,64 +7510,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)
{

Loading…
Cancel
Save