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 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(); UniValue PricesList(CPubKey mypk);
#endif #endif

View File

@@ -1113,7 +1113,7 @@ UniValue PricesInfo(uint256 bettxid, int32_t refheight)
return(result); return(result);
} }
UniValue PricesList() UniValue PricesList(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;
@@ -1130,7 +1130,8 @@ UniValue PricesList()
txid = it->first.txhash; txid = it->first.txhash;
if (GetTransaction(txid, vintx, hashBlock, false) != 0) 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()); result.push_back(txid.GetHex());
} }
@@ -1138,5 +1139,3 @@ UniValue PricesList()
} }
return(result); return(result);
} }

View File

@@ -463,6 +463,7 @@ static const CRPCCommand vRPCCommands[] =
{ "prices", "prices", &prices, true }, { "prices", "prices", &prices, true },
{ "prices", "pricesaddress", &pricesaddress, true }, { "prices", "pricesaddress", &pricesaddress, true },
{ "prices", "priceslist", &priceslist, true }, { "prices", "priceslist", &priceslist, true },
{ "prices", "mypriceslist", &mypriceslist, true },
{ "prices", "pricesinfo", &pricesinfo, true }, { "prices", "pricesinfo", &pricesinfo, true },
{ "prices", "pricesbet", &pricesbet, true }, { "prices", "pricesbet", &pricesbet, true },
{ "prices", "pricessetcostbasis", &pricessetcostbasis, 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 oraclessamples(const UniValue& params, bool fHelp);
extern UniValue pricesaddress(const UniValue& params, bool fHelp); extern UniValue pricesaddress(const UniValue& params, bool fHelp);
extern UniValue priceslist(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 pricesinfo(const UniValue& params, bool fHelp);
extern UniValue pegsaddress(const UniValue& params, bool fHelp); extern UniValue pegsaddress(const UniValue& params, bool fHelp);
extern UniValue marmaraaddress(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"); throw runtime_error("priceslist\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");
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) UniValue pricesinfo(const UniValue& params, bool fHelp)