From a18ab80ddeef2650345590f2b3d552333835a9aa Mon Sep 17 00:00:00 2001 From: dimxy Date: Mon, 22 Apr 2019 11:30:15 +0500 Subject: [PATCH] mypriceslist added --- src/cc/CCPrices.h | 2 +- src/cc/prices.cpp | 21 ++++++++++----------- src/rpc/server.cpp | 1 + src/rpc/server.h | 1 + src/wallet/rpcwallet.cpp | 13 ++++++++++++- 5 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/cc/CCPrices.h b/src/cc/CCPrices.h index 0225ff69b..c7f3961d5 100644 --- a/src/cc/CCPrices.h +++ b/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 diff --git a/src/cc/prices.cpp b/src/cc/prices.cpp index d8944df9f..425b125c1 100644 --- a/src/cc/prices.cpp +++ b/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 > 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 vec; - CTransaction vintx; + UniValue result(UniValue::VARR); std::vector > 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 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); -} - - +} \ No newline at end of file diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index 29e616bca..13f235e26 100644 --- a/src/rpc/server.cpp +++ b/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 }, diff --git a/src/rpc/server.h b/src/rpc/server.h index 2bd0b91c6..98a0d046f 100644 --- a/src/rpc/server.h +++ b/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); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index a155603d9..8c6e4530f 100644 --- a/src/wallet/rpcwallet.cpp +++ b/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)