diff --git a/src/komodo_defs.h b/src/komodo_defs.h index ee44132bc..94d7300aa 100644 --- a/src/komodo_defs.h +++ b/src/komodo_defs.h @@ -101,7 +101,7 @@ int32_t komodo_dpowconfs(int32_t height,int32_t numconfs); int8_t komodo_segid(int32_t nocache,int32_t height); int32_t komodo_heightpricebits(uint64_t *seedp,uint32_t *heightbits,int32_t nHeight); char *komodo_pricename(char *name,int32_t ind); -int32_t komodo_priceind(char *symbol); +int32_t komodo_priceind(const char *symbol); int32_t komodo_pricesinit(); int64_t komodo_priceave(int64_t *tmpbuf,int64_t *correlated,int32_t cskip); int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int32_t rawskip,uint32_t *nonzprices,int32_t smoothwidth); diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 3f1d5ec5e..5ce9d223f 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2448,6 +2448,7 @@ int32_t komodo_priceind(const char *symbol) return(-1); } +// returns price value which is in a 10% interval for more than 50% points for the preceding 24 hours int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int32_t rawskip,uint32_t *nonzprices,int32_t smoothwidth) { int32_t i,j,k,n,iter,correlation,maxcorrelation=0; int64_t firstprice,price,sum,den,mult,refprice,lowprice,highprice; @@ -2486,7 +2487,7 @@ int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int //fprintf(stderr,"%.1f ",(double)price/10000); sum += price; correlation++; - if ( correlation > (PRICES_DAYWINDOW>>1) ) + if ( correlation > (PRICES_DAYWINDOW>>1) ) // if there are more than 50% raw price values lay within +/-5% interval from the refprice picked from random pos { if ( nonzprices == 0 ) return(refprice * mult); diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 550355cff..26a7f6867 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -43,6 +43,9 @@ #include +#include "cc/CCinclude.h" +#include "cc/CCPrices.h" + using namespace std; extern void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry); @@ -1165,7 +1168,7 @@ UniValue paxprice(const UniValue& params, bool fHelp) return(-1); for (i=0; i vexpr; @@ -1349,7 +1353,7 @@ UniValue pricesaddfunding(const UniValue& params, bool fHelp) { if (fHelp || params.size() != 2) throw runtime_error("pricesaddfunding bettxid amount\n" - "where amount is in satoshis\n"); + "where amount is in satoshis\n"); LOCK(cs_main); UniValue ret(UniValue::VOBJ); @@ -1358,11 +1362,11 @@ UniValue pricesaddfunding(const UniValue& params, bool fHelp) CAmount txfee = 10000; uint256 bettxid = Parseuint256(params[0].get_str().c_str()); - if( bettxid.IsNull() ) + if (bettxid.IsNull()) throw runtime_error("invalid bettxid\n"); CAmount amount = atoll(params[1].get_str().c_str()); - if( amount <= 0 ) + if (amount <= 0) throw runtime_error("invalid amount\n"); return PricesAddFunding(txfee, bettxid, amount); @@ -1380,7 +1384,7 @@ UniValue pricessetcostbasis(const UniValue& params, bool fHelp) throw JSONRPCError(RPC_INVALID_PARAMETER, "only -ac_cbopret chains have prices"); uint256 bettxid = Parseuint256(params[0].get_str().c_str()); - if( bettxid.IsNull() ) + if (bettxid.IsNull()) throw runtime_error("invalid bettxid\n"); int64_t txfee = 10000; @@ -1388,6 +1392,7 @@ UniValue pricessetcostbasis(const UniValue& params, bool fHelp) return PricesSetcostbasis(txfee, bettxid); } +// pricescashout rpc implementation UniValue pricescashout(const UniValue& params, bool fHelp) { if (fHelp || params.size() != 1) @@ -1407,6 +1412,7 @@ UniValue pricescashout(const UniValue& params, bool fHelp) return PricesCashout(txfee, bettxid); } +// pricesrekt rpc implementation UniValue pricesrekt(const UniValue& params, bool fHelp) { if (fHelp || params.size() != 2) @@ -1428,6 +1434,7 @@ UniValue pricesrekt(const UniValue& params, bool fHelp) return PricesRekt(txfee, bettxid, height); } + UniValue gettxout(const UniValue& params, bool fHelp) { if (fHelp || params.size() < 2 || params.size() > 3) @@ -2057,4 +2064,4 @@ void RegisterBlockchainRPCCommands(CRPCTable &tableRPC) { for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++) tableRPC.appendCommand(commands[vcidx].name, &commands[vcidx]); -} +} \ No newline at end of file