Merge branch 'FSM' of https://github.com/blackjok3rtt/komodo into blackjok3rtt-FSM

a
This commit is contained in:
blackjok3r
2018-12-17 12:40:45 +08:00
14 changed files with 195 additions and 510 deletions

View File

@@ -55,7 +55,7 @@ extern uint64_t KOMODO_INTERESTSUM,KOMODO_WALLETBALANCE;
extern int32_t KOMODO_LASTMINED,JUMBLR_PAUSE,KOMODO_LONGESTCHAIN,IS_STAKED_NOTARY,IS_KOMODO_NOTARY,STAKED_ERA;
extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN];
uint32_t komodo_segid32(char *coinaddr);
int64_t komodo_coinsupply(int64_t *zfundsp,int32_t height);
int64_t komodo_coinsupply(int64_t *zfundsp,int64_t *sproutfundsp,int32_t height);
int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *kmdnotarized_heightp);
int8_t StakedNotaryID(std::string &notaryname, char *Raddress);
#define KOMODO_VERSION "0.3.1"
@@ -363,7 +363,7 @@ public:
UniValue coinsupply(const UniValue& params, bool fHelp)
{
int32_t height = 0; int32_t currentHeight; int64_t zfunds,supply = 0; UniValue result(UniValue::VOBJ);
int32_t height = 0; int32_t currentHeight; int64_t sproutfunds,zfunds,supply = 0; UniValue result(UniValue::VOBJ);
if (fHelp || params.size() > 1)
throw runtime_error("coinsupply <height>\n"
"\nReturn coin supply information at a given block height. If no height is given, the current height is used.\n"
@@ -376,7 +376,8 @@ UniValue coinsupply(const UniValue& params, bool fHelp)
" \"height\" : 420, (integer) The height of this coin supply data\n"
" \"supply\" : \"777.0\", (float) The transparent coin supply\n"
" \"zfunds\" : \"0.777\", (float) The shielded coin supply (in zaddrs)\n"
" \"total\" : \"777.777\", (float) The total coin supply, i.e. sum of supply + zfunds\n"
" \"sprout\" : \"0.077\", (float) The sprout coin supply (in zcaddrs)\n"
" \"total\" : \"777.777\", (float) The total coin supply, i.e. sum of supply + zfunds\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("coinsupply", "420")
@@ -388,13 +389,14 @@ UniValue coinsupply(const UniValue& params, bool fHelp)
currentHeight = chainActive.Height();
if (height >= 0 && height <= currentHeight) {
if ( (supply= komodo_coinsupply(&zfunds,height)) > 0 )
if ( (supply= komodo_coinsupply(&zfunds,&sproutfunds,height)) > 0 )
{
result.push_back(Pair("result", "success"));
result.push_back(Pair("coin", ASSETCHAINS_SYMBOL[0] == 0 ? "KMD" : ASSETCHAINS_SYMBOL));
result.push_back(Pair("height", (int)height));
result.push_back(Pair("supply", ValueFromAmount(supply)));
result.push_back(Pair("zfunds", ValueFromAmount(zfunds)));
result.push_back(Pair("sprout", ValueFromAmount(sproutfunds)));
result.push_back(Pair("total", ValueFromAmount(zfunds + supply)));
} else result.push_back(Pair("error", "couldnt calculate supply"));
} else {