Browse Source

pricesinfo height opt

z_createrawtransaction
dimxy 5 years ago
parent
commit
59fbfbcae7
  1. 13
      src/cc/prices.cpp
  2. 10
      src/wallet/rpcwallet.cpp

13
src/cc/prices.cpp

@ -397,6 +397,11 @@ int64_t prices_syntheticprofits(bool calcCostbasis, int64_t &costbasis, int32_t
{
int64_t price, profits = 0;
if (height < firstheight) {
fprintf(stderr, "requested height is lower than bet firstheight.%d\n", height);
return 0;
}
int32_t minmax = (height < firstheight + PRICES_DAYWINDOW); // if we are within 24h then use min or max value
if ((price = prices_syntheticprice(vec, height, minmax, leverage)) < 0)
@ -768,6 +773,14 @@ UniValue PricesInfo(uint256 bettxid, int32_t refheight)
{
if (prices_betopretdecode(bettx.vout[numvouts - 1].scriptPubKey, pk, firstheight, positionsize, leverage, firstprice, vec, tokenid) == 'B')
{
if (refheight > 0 && refheight < firstheight) {
result.push_back(Pair("result", "error"));
result.push_back(Pair("error", "incorrect height"));
return(result);
}
if (refheight == 0)
refheight = komodo_nextheight()-1;
costbasis = prices_costbasis(bettx);
addedbets = prices_batontxid(batontxid, bettx, bettxid);
if ((profits = prices_syntheticprofits(false, costbasis, firstheight, refheight, leverage, vec, positionsize, addedbets)) < 0)

10
src/wallet/rpcwallet.cpp

@ -6931,13 +6931,15 @@ UniValue priceslist(const UniValue& params, bool fHelp)
UniValue pricesinfo(const UniValue& params, bool fHelp)
{
uint256 bettxid; int32_t height;
if ( fHelp || params.size() != 2 )
throw runtime_error("pricesinfo fundingtxid height\n");
if ( fHelp || params.size() != 1 && params.size() != 2)
throw runtime_error("pricesinfo fundingtxid [height]\n");
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");
bettxid = Parseuint256((char *)params[0].get_str().c_str());
height = atoi(params[1].get_str().c_str());
return(PricesInfo(bettxid,height));
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)

Loading…
Cancel
Save