From 9d0a39dbd742239850ec3d62a2e5c395245ac645 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 13 Apr 2019 19:19:00 -1100 Subject: [PATCH] coinsupply inflation calc --- src/rpc/blockchain.cpp | 1 + src/rpc/misc.cpp | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 84bdfd02e..18f7b0fc0 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1255,6 +1255,7 @@ UniValue prices(const UniValue& params, bool fHelp) rngval = (rngval*11109 + 13849); if ( (correlated[i]= komodo_pricecorrelated(rngval,j,&prices[offset],1,0,PRICES_SMOOTHWIDTH)) < 0 ) throw JSONRPCError(RPC_INVALID_PARAMETER, "null correlated price"); + } tmpbuf = (int64_t *)calloc(sizeof(int64_t),2*PRICES_DAYWINDOW); for (i=0; i 1) throw runtime_error("coinsupply \n" "\nReturn coin supply information at a given block height. If no height is given, the current height is used.\n" @@ -448,6 +448,26 @@ UniValue coinsupply(const UniValue& params, bool fHelp) result.push_back(Pair("zfunds", ValueFromAmount(zfunds))); result.push_back(Pair("sprout", ValueFromAmount(sproutfunds))); result.push_back(Pair("total", ValueFromAmount(zfunds + supply))); + if ( ASSETCHAINS_BLOCKTIME > 0 ) + { + blocks_per_year = 24*3600*365 / ASSETCHAINS_BLOCKTIME; + if ( height > blocks_per_year ) + { + supply1 = komodo_coinsupply(&zf,&sf,height - blocks_per_year/12); + supply3 = komodo_coinsupply(&zf,&sf,height - blocks_per_year/4); + supply12 = komodo_coinsupply(&zf,&sf,height - blocks_per_year); + if ( supply1 != 0 && supply3 != 0 && supply12 != 0 ) + { + result.push_back(Pair("lastmonth", ValueFromAmount(supply1))); + result.push_back(Pair("monthcoins", ValueFromAmount(supply - supply1))); + result.push_back(Pair("lastquarter", ValueFromAmount(supply3))); + result.push_back(Pair("quartercoins", ValueFromAmount(supply - supply3))); + result.push_back(Pair("lastyear", ValueFromAmount(supply12))); + result.push_back(Pair("yearcoins", ValueFromAmount(supply - supply12))); + result.push_back(Pair("inflation", 100. * (((double)supply/supply12)-1.))); + } + } + } } else result.push_back(Pair("error", "couldnt calculate supply")); } else { result.push_back(Pair("error", "invalid height"));