height_MoM rpc
This commit is contained in:
@@ -592,7 +592,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("VALID %s MoM.%s [%d]\n",ASSETCHAINS_SYMBOL,sp->MoM.ToString().c_str(),sp->MoMdepth);
|
||||
//printf("VALID %s MoM.%s [%d]\n",ASSETCHAINS_SYMBOL,sp->MoM.ToString().c_str(),sp->MoMdepth);
|
||||
}
|
||||
}
|
||||
komodo_stateupdate(height,0,0,0,zero,0,0,0,0,0,0,0,0,0,0,sp->MoM,sp->MoMdepth);
|
||||
|
||||
@@ -127,12 +127,12 @@ const char *Notaries_elected0[][2] =
|
||||
};
|
||||
|
||||
#define KOMODO_NOTARIES_TIMESTAMP1 1600000000
|
||||
#define KOMODO_NOTARIES_HEIGHT1 ((800000 / KOMODO_ELECTION_GAP) * KOMODO_ELECTION_GAP)
|
||||
#define KOMODO_NOTARIES_HEIGHT1 ((900000 / KOMODO_ELECTION_GAP) * KOMODO_ELECTION_GAP)
|
||||
|
||||
const char *Notaries_elected1[][2] =
|
||||
{
|
||||
{ "0_jl777_testA", "03b7621b44118017a16043f19b30cc8a4cfe068ac4e42417bae16ba460c80f3828" },
|
||||
{ "0_jl777_testB", "02ebfc784a4ba768aad88d44d1045d240d47b26e248cafaf1c5169a42d7a61d344" },
|
||||
{ "0_jl777_testA", "03b7621b44118017a16043f19b30cc8a4cfe068ac4e42417bae16ba460c80f3828" },
|
||||
{ "0_kolo_testA", "0287aa4b73988ba26cf6565d815786caf0d2c4af704d7883d163ee89cd9977edec" },
|
||||
{ "artik_AR", "029acf1dcd9f5ff9c455f8bb717d4ae0c703e089d16cf8424619c491dff5994c90" },
|
||||
{ "artik_EU", "03f54b2c24f82632e3cdebe4568ba0acf487a80f8a89779173cdb78f74514847ce" },
|
||||
|
||||
@@ -527,6 +527,7 @@ char *bitcoin_address(char *coinaddr,uint8_t addrtype,uint8_t *pubkey_or_rmd160,
|
||||
//uint32_t komodo_interest_args(int32_t *txheightp,uint32_t *tiptimep,uint64_t *valuep,uint256 hash,int32_t n);
|
||||
int32_t komodo_minerids(uint8_t *minerids,int32_t height,int32_t width);
|
||||
int32_t komodo_kvsearch(uint256 *refpubkeyp,int32_t current_height,uint32_t *flagsp,int32_t *heightp,uint8_t value[IGUANA_MAXSCRIPTSIZE],uint8_t *key,int32_t keylen);
|
||||
int32_t komodo_MoMdata(int32_t *notarized_htp,uint256 *MoMp,int32_t nHeight);
|
||||
/*uint64_t conv_NXTpassword(unsigned char *mysecret,unsigned char *mypublic,uint8_t *pass,int32_t passlen);
|
||||
|
||||
|
||||
@@ -579,6 +580,28 @@ UniValue kvsearch(const UniValue& params, bool fHelp)
|
||||
return ret;
|
||||
}
|
||||
|
||||
UniValue height_MoM(const UniValue& params, bool fHelp)
|
||||
{
|
||||
int32_t height,depth,notarized_height; uint256 MoM; uint32_t timestamp = 0; UniValue ret(UniValue::VOBJ); UniValue a(UniValue::VARR);
|
||||
if ( fHelp || params.size() != 1 )
|
||||
throw runtime_error("height_MoM needs height\n");
|
||||
LOCK(cs_main);
|
||||
height = atoi(params[0].get_str().c_str());
|
||||
if ( height <= 0 )
|
||||
height = chainActive.Tip()->nHeight;
|
||||
depth = komodo_MoMdata(¬arized_height,&MoM,height);
|
||||
ret.push_back(Pair("coin",ASSETCHAINS_SYMBOL[0] == 0 ? "KMD" : ASSSETCHAINS_SYMBOL));
|
||||
ret.push_back(Pair("height",height));
|
||||
if ( depth > 0 )
|
||||
{
|
||||
ret.push_back(Pair("depth",depth));
|
||||
ret.push_back(Pair("notarized_height",notarized_height));
|
||||
ret.push_back(Pair("MoM",MoM.GetHex()));
|
||||
} else ret.push_back(Pair("error",(char *)"no MoM for height"));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
UniValue minerids(const UniValue& params, bool fHelp)
|
||||
{
|
||||
uint32_t timestamp = 0; UniValue ret(UniValue::VOBJ); UniValue a(UniValue::VARR); uint8_t minerids[2000],pubkeys[65][33]; int32_t i,j,n,numnotaries,tally[129];
|
||||
@@ -639,57 +662,56 @@ UniValue minerids(const UniValue& params, bool fHelp)
|
||||
UniValue notaries(const UniValue& params, bool fHelp)
|
||||
{
|
||||
UniValue a(UniValue::VARR); uint32_t timestamp=0; UniValue ret(UniValue::VOBJ); int32_t i,j,n,m; char *hexstr; uint8_t pubkeys[64][33]; char btcaddr[64],kmdaddr[64],*ptr;
|
||||
if ( fHelp || params.size() != 1 )
|
||||
throw runtime_error("notaries height\n");
|
||||
if ( fHelp || (params.size() != 1 && params.size() != 2) )
|
||||
throw runtime_error("notaries height timestamp\n");
|
||||
LOCK(cs_main);
|
||||
int32_t height = atoi(params[0].get_str().c_str());
|
||||
if ( params.size() == 2 )
|
||||
timestamp = (uint32_t)atol(params[1].get_str().c_str());
|
||||
else timestamp = (uint32_t)time(NULL);
|
||||
if ( height < 0 )
|
||||
{
|
||||
height = chainActive.Tip()->nHeight;
|
||||
timestamp = chainActive.Tip()->GetBlockTime();
|
||||
}
|
||||
else
|
||||
else if ( params.size() < 2 )
|
||||
{
|
||||
CBlockIndex *pblockindex = chainActive[height];
|
||||
if ( pblockindex != 0 )
|
||||
timestamp = pblockindex->GetBlockTime();
|
||||
}
|
||||
//fprintf(stderr,"notaries as of height.%d\n",height);
|
||||
//if ( height > chainActive.Height()+20000 )
|
||||
// throw JSONRPCError(RPC_INVALID_PARAMETER, "Block height out of range");
|
||||
//else
|
||||
if ( (n= komodo_notaries(pubkeys,height,timestamp)) > 0 )
|
||||
{
|
||||
if ( (n= komodo_notaries(pubkeys,height,timestamp)) > 0 )
|
||||
for (i=0; i<n; i++)
|
||||
{
|
||||
for (i=0; i<n; i++)
|
||||
{
|
||||
UniValue item(UniValue::VOBJ);
|
||||
std::string btcaddress,kmdaddress,hex;
|
||||
hex.resize(66);
|
||||
hexstr = (char *)hex.data();
|
||||
for (j=0; j<33; j++)
|
||||
sprintf(&hexstr[j*2],"%02x",pubkeys[i][j]);
|
||||
item.push_back(Pair("pubkey", hex));
|
||||
|
||||
bitcoin_address(btcaddr,0,pubkeys[i],33);
|
||||
m = (int32_t)strlen(btcaddr);
|
||||
btcaddress.resize(m);
|
||||
ptr = (char *)btcaddress.data();
|
||||
memcpy(ptr,btcaddr,m);
|
||||
item.push_back(Pair("BTCaddress", btcaddress));
|
||||
|
||||
bitcoin_address(kmdaddr,60,pubkeys[i],33);
|
||||
m = (int32_t)strlen(kmdaddr);
|
||||
kmdaddress.resize(m);
|
||||
ptr = (char *)kmdaddress.data();
|
||||
memcpy(ptr,kmdaddr,m);
|
||||
item.push_back(Pair("KMDaddress", kmdaddress));
|
||||
a.push_back(item);
|
||||
}
|
||||
UniValue item(UniValue::VOBJ);
|
||||
std::string btcaddress,kmdaddress,hex;
|
||||
hex.resize(66);
|
||||
hexstr = (char *)hex.data();
|
||||
for (j=0; j<33; j++)
|
||||
sprintf(&hexstr[j*2],"%02x",pubkeys[i][j]);
|
||||
item.push_back(Pair("pubkey", hex));
|
||||
|
||||
bitcoin_address(btcaddr,0,pubkeys[i],33);
|
||||
m = (int32_t)strlen(btcaddr);
|
||||
btcaddress.resize(m);
|
||||
ptr = (char *)btcaddress.data();
|
||||
memcpy(ptr,btcaddr,m);
|
||||
item.push_back(Pair("BTCaddress", btcaddress));
|
||||
|
||||
bitcoin_address(kmdaddr,60,pubkeys[i],33);
|
||||
m = (int32_t)strlen(kmdaddr);
|
||||
kmdaddress.resize(m);
|
||||
ptr = (char *)kmdaddress.data();
|
||||
memcpy(ptr,kmdaddr,m);
|
||||
item.push_back(Pair("KMDaddress", kmdaddress));
|
||||
a.push_back(item);
|
||||
}
|
||||
ret.push_back(Pair("notaries", a));
|
||||
ret.push_back(Pair("numnotaries", n));
|
||||
}
|
||||
ret.push_back(Pair("notaries", a));
|
||||
ret.push_back(Pair("numnotaries", n));
|
||||
ret.push_back(Pair("height", height));
|
||||
ret.push_back(Pair("timestamp", timestamp));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -115,7 +115,8 @@ static const CRPCConvertParam vRPCConvertParams[] =
|
||||
{ "paxprice", 4 },
|
||||
{ "paxprices", 3 },
|
||||
{ "paxpending", 0 },
|
||||
{ "notaries", 1 },
|
||||
{ "notaries", 2 },
|
||||
{ "height_MoM", 1 },
|
||||
{ "minerids", 1 },
|
||||
{ "kvsearch", 1 },
|
||||
{ "kvupdate", 4 },
|
||||
|
||||
@@ -295,6 +295,7 @@ static const CRPCCommand vRPCCommands[] =
|
||||
{ "blockchain", "paxpending", &paxpending, true },
|
||||
{ "blockchain", "paxprices", &paxprices, true },
|
||||
{ "blockchain", "notaries", ¬aries, true },
|
||||
{ "blockchain", "height_MoM", &height_MoM, true },
|
||||
{ "blockchain", "minerids", &minerids, true },
|
||||
{ "blockchain", "kvsearch", &kvsearch, true },
|
||||
{ "blockchain", "kvupdate", &kvupdate, true },
|
||||
|
||||
@@ -297,6 +297,7 @@ extern UniValue z_getoperationresult(const UniValue& params, bool fHelp); // in
|
||||
extern UniValue z_listoperationids(const UniValue& params, bool fHelp); // in rpcwallet.cpp
|
||||
extern UniValue z_validateaddress(const UniValue& params, bool fHelp); // in rpcmisc.cpp
|
||||
|
||||
extern UniValue height_MoM(const UniValue& params, bool fHelp);
|
||||
extern UniValue notaries(const UniValue& params, bool fHelp);
|
||||
extern UniValue minerids(const UniValue& params, bool fHelp);
|
||||
extern UniValue kvsearch(const UniValue& params, bool fHelp);
|
||||
|
||||
Reference in New Issue
Block a user