Original HUSH source code based on ZEC 1.0.8 . For historical purposes only!
https://hush.is
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
103 lines
4.8 KiB
103 lines
4.8 KiB
/******************************************************************************
|
|
* Copyright © 2014-2018 The SuperNET Developers. *
|
|
* *
|
|
* See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at *
|
|
* the top-level directory of this distribution for the individual copyright *
|
|
* holder information and the developer policies on copyright and licensing. *
|
|
* *
|
|
* Unless otherwise agreed in a custom licensing agreement, no part of the *
|
|
* SuperNET software, including this file may be copied, modified, propagated *
|
|
* or distributed except according to the terms contained in the LICENSE file *
|
|
* *
|
|
* Removal or modification of this copyright notice is prohibited. *
|
|
* *
|
|
******************************************************************************/
|
|
|
|
#ifndef komodo_rpcblockchain_h
|
|
#define komodo_rpcblockchain_h
|
|
|
|
#include "main.h"
|
|
|
|
int32_t komodo_MoMdata(int32_t *notarized_htp,uint256 *MoMp,uint256 *kmdtxidp,int32_t height,uint256 *MoMoMp,int32_t *MoMoMoffsetp,int32_t *MoMoMdepthp,int32_t *kmdstartip,int32_t *kmdendip);
|
|
uint256 komodo_calcMoM(int32_t height,int32_t MoMdepth);
|
|
extern char ASSETCHAINS_SYMBOL[65];
|
|
|
|
int32_t komodo_MoM(int32_t *notarized_heightp,uint256 *MoMp,uint256 *kmdtxidp,int32_t nHeight,uint256 *MoMoMp,int32_t *MoMoMoffsetp,int32_t *MoMoMdepthp,int32_t *kmdstartip,int32_t *kmdendip)
|
|
{
|
|
int32_t depth,notarized_ht; uint256 MoM,kmdtxid;
|
|
depth = komodo_MoMdata(¬arized_ht,&MoM,&kmdtxid,nHeight,MoMoMp,MoMoMoffsetp,MoMoMdepthp,kmdstartip,kmdendip);
|
|
memset(MoMp,0,sizeof(*MoMp));
|
|
memset(kmdtxidp,0,sizeof(*kmdtxidp));
|
|
*notarized_heightp = 0;
|
|
if ( depth > 0 && notarized_ht > 0 && nHeight > notarized_ht-depth && nHeight <= notarized_ht )
|
|
{
|
|
*MoMp = MoM;
|
|
*notarized_heightp = notarized_ht;
|
|
*kmdtxidp = kmdtxid;
|
|
}
|
|
return(depth);
|
|
}
|
|
|
|
UniValue calc_MoM(const UniValue& params, bool fHelp)
|
|
{
|
|
int32_t height,MoMdepth; uint256 MoM; UniValue ret(UniValue::VOBJ); UniValue a(UniValue::VARR);
|
|
if ( fHelp || params.size() != 2 )
|
|
throw runtime_error("calc_MoM height MoMdepth\n");
|
|
LOCK(cs_main);
|
|
height = atoi(params[0].get_str().c_str());
|
|
MoMdepth = atoi(params[1].get_str().c_str());
|
|
if ( height <= 0 )
|
|
throw runtime_error("calc_MoM illegal height, must be positive\n");
|
|
if ( MoMdepth <= 0 || MoMdepth >= height )
|
|
throw runtime_error("calc_MoM illegal MoMdepth, must be positive and less than height\n");
|
|
|
|
//fprintf(stderr,"height_MoM height.%d\n",height);
|
|
MoM = komodo_calcMoM(height,MoMdepth);
|
|
ret.push_back(Pair("coin",(char *)(ASSETCHAINS_SYMBOL[0] == 0 ? "KMD" : ASSETCHAINS_SYMBOL)));
|
|
ret.push_back(Pair("height",height));
|
|
ret.push_back(Pair("MoMdepth",MoMdepth));
|
|
ret.push_back(Pair("MoM",MoM.GetHex()));
|
|
return ret;
|
|
}
|
|
|
|
UniValue height_MoM(const UniValue& params, bool fHelp)
|
|
{
|
|
int32_t height,depth,notarized_height,MoMoMdepth,MoMoMoffset,kmdstarti,kmdendi; uint256 MoM,MoMoM,kmdtxid; uint32_t timestamp = 0; UniValue ret(UniValue::VOBJ); UniValue a(UniValue::VARR);
|
|
if ( fHelp || params.size() != 1 )
|
|
throw runtime_error("height_MoM height\n");
|
|
LOCK(cs_main);
|
|
height = atoi(params[0].get_str().c_str());
|
|
if ( height <= 0 )
|
|
{
|
|
if ( chainActive.Tip() == 0 )
|
|
{
|
|
ret.push_back(Pair("error",(char *)"no active chain yet"));
|
|
return(ret);
|
|
}
|
|
height = chainActive.Tip()->nHeight;
|
|
}
|
|
//fprintf(stderr,"height_MoM height.%d\n",height);
|
|
depth = komodo_MoM(¬arized_height,&MoM,&kmdtxid,height,&MoMoM,&MoMoMoffset,&MoMoMdepth,&kmdstarti,&kmdendi);
|
|
ret.push_back(Pair("coin",(char *)(ASSETCHAINS_SYMBOL[0] == 0 ? "KMD" : ASSETCHAINS_SYMBOL)));
|
|
ret.push_back(Pair("height",height));
|
|
ret.push_back(Pair("timestamp",(uint64_t)timestamp));
|
|
if ( depth > 0 )
|
|
{
|
|
ret.push_back(Pair("depth",depth));
|
|
ret.push_back(Pair("notarized_height",notarized_height));
|
|
ret.push_back(Pair("MoM",MoM.GetHex()));
|
|
ret.push_back(Pair("kmdtxid",kmdtxid.GetHex()));
|
|
if ( ASSETCHAINS_SYMBOL[0] != 0 )
|
|
{
|
|
ret.push_back(Pair("MoMoM",MoMoM.GetHex()));
|
|
ret.push_back(Pair("MoMoMoffset",MoMoMoffset));
|
|
ret.push_back(Pair("MoMoMdepth",MoMoMdepth));
|
|
ret.push_back(Pair("kmdstarti",kmdstarti));
|
|
ret.push_back(Pair("kmdendi",kmdendi));
|
|
}
|
|
} else ret.push_back(Pair("error",(char *)"no MoM for height"));
|
|
|
|
return ret;
|
|
}
|
|
|
|
#endif /* komodo_rpcblockchain_h */
|
|
|