added all|open|close opt param to priceslist, mypriceslist
This commit is contained in:
@@ -46,7 +46,7 @@ UniValue PricesSetcostbasis(int64_t txfee,uint256 bettxid);
|
|||||||
UniValue PricesRekt(int64_t txfee,uint256 bettxid,int32_t rektheight);
|
UniValue PricesRekt(int64_t txfee,uint256 bettxid,int32_t rektheight);
|
||||||
UniValue PricesCashout(int64_t txfee,uint256 bettxid);
|
UniValue PricesCashout(int64_t txfee,uint256 bettxid);
|
||||||
UniValue PricesInfo(uint256 bettxid,int32_t refheight);
|
UniValue PricesInfo(uint256 bettxid,int32_t refheight);
|
||||||
UniValue PricesList(CPubKey mypk);
|
UniValue PricesList(uint32_t filter, CPubKey mypk);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1054,7 +1054,8 @@ UniValue PricesInfo(uint256 bettxid, int32_t refheight)
|
|||||||
{
|
{
|
||||||
if (prices_betopretdecode(bettx.vout[numvouts - 1].scriptPubKey, pk, firstheight, positionsize, leverage, firstprice, vec, tokenid) == 'B')
|
if (prices_betopretdecode(bettx.vout[numvouts - 1].scriptPubKey, pk, firstheight, positionsize, leverage, firstprice, vec, tokenid) == 'B')
|
||||||
{
|
{
|
||||||
if (refheight > 0 && refheight < firstheight) {
|
// check acceptable refheight:
|
||||||
|
if (refheight < 0 || refheight > 0 && refheight < firstheight) {
|
||||||
result.push_back(Pair("result", "error"));
|
result.push_back(Pair("result", "error"));
|
||||||
result.push_back(Pair("error", "incorrect height"));
|
result.push_back(Pair("error", "incorrect height"));
|
||||||
return(result);
|
return(result);
|
||||||
@@ -1113,7 +1114,7 @@ UniValue PricesInfo(uint256 bettxid, int32_t refheight)
|
|||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
UniValue PricesList(CPubKey mypk)
|
UniValue PricesList(uint32_t filter, CPubKey mypk)
|
||||||
{
|
{
|
||||||
UniValue result(UniValue::VARR); std::vector<std::pair<CAddressIndexKey, CAmount> > addressIndex;
|
UniValue result(UniValue::VARR); std::vector<std::pair<CAddressIndexKey, CAmount> > addressIndex;
|
||||||
struct CCcontract_info *cp, C;
|
struct CCcontract_info *cp, C;
|
||||||
@@ -1133,7 +1134,21 @@ UniValue PricesList(CPubKey mypk)
|
|||||||
if (vintx.vout.size() > 0 && prices_betopretdecode(vintx.vout[vintx.vout.size() - 1].scriptPubKey, pk, height, amount, leverage, firstprice, vec, tokenid) == 'B' &&
|
if (vintx.vout.size() > 0 && prices_betopretdecode(vintx.vout[vintx.vout.size() - 1].scriptPubKey, pk, height, amount, leverage, firstprice, vec, tokenid) == 'B' &&
|
||||||
(mypk == CPubKey() || mypk == pk)) // if only mypubkey to list
|
(mypk == CPubKey() || mypk == pk)) // if only mypubkey to list
|
||||||
{
|
{
|
||||||
result.push_back(txid.GetHex());
|
bool bAppend = false;
|
||||||
|
if (filter == 0)
|
||||||
|
bAppend = true;
|
||||||
|
else {
|
||||||
|
int32_t vini;
|
||||||
|
int32_t height;
|
||||||
|
uint256 finaltxid;
|
||||||
|
|
||||||
|
int32_t spent = CCgetspenttxid(finaltxid, vini, height, txid, 2);
|
||||||
|
if (filter == 1 && spent < 0 ||
|
||||||
|
filter == 2 && spent == 0)
|
||||||
|
bAppend = true;
|
||||||
|
}
|
||||||
|
if (bAppend)
|
||||||
|
result.push_back(txid.GetHex());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6919,24 +6919,46 @@ UniValue faucetget(const UniValue& params, bool fHelp)
|
|||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t pricesGetParam(UniValue param) {
|
||||||
|
uint32_t filter = 0;
|
||||||
|
if (strcmpi(param.get_str().c_str(), "all") == 0)
|
||||||
|
filter = 0;
|
||||||
|
if (strcmpi(param.get_str().c_str(), "open") == 0)
|
||||||
|
filter = 1;
|
||||||
|
if (strcmpi(param.get_str().c_str(), "closed") == 0)
|
||||||
|
filter = 2;
|
||||||
|
else
|
||||||
|
throw runtime_error("incorrect parameter\n");
|
||||||
|
}
|
||||||
|
|
||||||
UniValue priceslist(const UniValue& params, bool fHelp)
|
UniValue priceslist(const UniValue& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if ( fHelp || params.size() > 0 )
|
if ( fHelp || params.size() != 0 || params.size() != 1)
|
||||||
throw runtime_error("priceslist\n");
|
throw runtime_error("priceslist [all|open|closed]\n");
|
||||||
if ( ensure_CCrequirements(EVAL_PRICES) < 0 )
|
if ( ensure_CCrequirements(EVAL_PRICES) < 0 )
|
||||||
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n");
|
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n");
|
||||||
|
uint32_t filter = 0;
|
||||||
|
if (params.size() == 1)
|
||||||
|
filter = pricesGetParam(params[0]);
|
||||||
|
|
||||||
CPubKey emptypk;
|
CPubKey emptypk;
|
||||||
return(PricesList(emptypk));
|
|
||||||
|
return(PricesList(filter, emptypk));
|
||||||
}
|
}
|
||||||
|
|
||||||
UniValue mypriceslist(const UniValue& params, bool fHelp)
|
UniValue mypriceslist(const UniValue& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (fHelp || params.size() > 0)
|
if (fHelp || params.size() > 0)
|
||||||
throw runtime_error("priceslist\n");
|
throw runtime_error("mypriceslist [all|open|closed]\n");
|
||||||
if (ensure_CCrequirements(EVAL_PRICES) < 0)
|
if (ensure_CCrequirements(EVAL_PRICES) < 0)
|
||||||
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n");
|
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n");
|
||||||
|
|
||||||
|
uint32_t filter = 0;
|
||||||
|
if (params.size() == 1)
|
||||||
|
filter = pricesGetParam(params[0]);
|
||||||
CPubKey mypk = pubkey2pk(Mypubkey());
|
CPubKey mypk = pubkey2pk(Mypubkey());
|
||||||
return(PricesList(mypk));
|
|
||||||
|
return(PricesList(filter, mypk));
|
||||||
}
|
}
|
||||||
|
|
||||||
UniValue pricesinfo(const UniValue& params, bool fHelp)
|
UniValue pricesinfo(const UniValue& params, bool fHelp)
|
||||||
|
|||||||
Reference in New Issue
Block a user