mypriceslist added

This commit is contained in:
dimxy
2019-04-22 11:30:15 +05:00
parent efec12bcf5
commit a18ab80dde
5 changed files with 25 additions and 13 deletions

View File

@@ -46,7 +46,7 @@ UniValue PricesSetcostbasis(int64_t txfee,uint256 bettxid);
UniValue PricesRekt(int64_t txfee,uint256 bettxid,int32_t rektheight);
UniValue PricesCashout(int64_t txfee,uint256 bettxid);
UniValue PricesInfo(uint256 bettxid,int32_t refheight);
UniValue PricesList();
UniValue PricesList(CPubKey mypk);
#endif

View File

@@ -1113,14 +1113,14 @@ UniValue PricesInfo(uint256 bettxid, int32_t refheight)
return(result);
}
UniValue PricesList()
UniValue PricesList(CPubKey mypk)
{
UniValue result(UniValue::VARR); std::vector<std::pair<CAddressIndexKey, CAmount> > addressIndex;
struct CCcontract_info *cp, C;
int64_t amount, firstprice; int32_t height; int16_t leverage; uint256 txid, hashBlock, tokenid;
CPubKey pk, pricespk;
std::vector<uint16_t> vec;
CTransaction vintx;
UniValue result(UniValue::VARR); std::vector<std::pair<CAddressIndexKey, CAmount> > addressIndex;
struct CCcontract_info *cp, C;
int64_t amount, firstprice; int32_t height; int16_t leverage; uint256 txid, hashBlock, tokenid;
CPubKey pk, pricespk;
std::vector<uint16_t> vec;
CTransaction vintx;
cp = CCinit(&C, EVAL_PRICES);
pricespk = GetUnspendable(cp, 0);
@@ -1130,13 +1130,12 @@ UniValue PricesList()
txid = it->first.txhash;
if (GetTransaction(txid, vintx, hashBlock, false) != 0)
{
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
{
result.push_back(txid.GetHex());
}
}
}
return(result);
}
}

View File

@@ -463,6 +463,7 @@ static const CRPCCommand vRPCCommands[] =
{ "prices", "prices", &prices, true },
{ "prices", "pricesaddress", &pricesaddress, true },
{ "prices", "priceslist", &priceslist, true },
{ "prices", "mypriceslist", &mypriceslist, true },
{ "prices", "pricesinfo", &pricesinfo, true },
{ "prices", "pricesbet", &pricesbet, true },
{ "prices", "pricessetcostbasis", &pricessetcostbasis, true },

View File

@@ -271,6 +271,7 @@ extern UniValue oraclesdata(const UniValue& params, bool fHelp);
extern UniValue oraclessamples(const UniValue& params, bool fHelp);
extern UniValue pricesaddress(const UniValue& params, bool fHelp);
extern UniValue priceslist(const UniValue& params, bool fHelp);
extern UniValue mypriceslist(const UniValue& params, bool fHelp);
extern UniValue pricesinfo(const UniValue& params, bool fHelp);
extern UniValue pegsaddress(const UniValue& params, bool fHelp);
extern UniValue marmaraaddress(const UniValue& params, bool fHelp);

View File

@@ -6925,7 +6925,18 @@ UniValue priceslist(const UniValue& params, bool fHelp)
throw runtime_error("priceslist\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");
return(PricesList());
CPubKey emptypk;
return(PricesList(emptypk));
}
UniValue mypriceslist(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() > 0)
throw runtime_error("priceslist\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");
CPubKey mypk = pubkey2pk(Mypubkey());
return(PricesList(mypk));
}
UniValue pricesinfo(const UniValue& params, bool fHelp)