Browse Source

mypriceslist added

z_createrawtransaction
dimxy 5 years ago
parent
commit
a18ab80dde
  1. 2
      src/cc/CCPrices.h
  2. 21
      src/cc/prices.cpp
  3. 1
      src/rpc/server.cpp
  4. 1
      src/rpc/server.h
  5. 13
      src/wallet/rpcwallet.cpp

2
src/cc/CCPrices.h

@ -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

21
src/cc/prices.cpp

@ -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);
}
}

1
src/rpc/server.cpp

@ -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 },

1
src/rpc/server.h

@ -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);

13
src/wallet/rpcwallet.cpp

@ -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)

Loading…
Cancel
Save