diff --git a/src/komodo.h b/src/komodo.h index d45b87859..5a1dc62f8 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -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); diff --git a/src/komodo_notary.h b/src/komodo_notary.h index f7d6982d0..e4b2a650e 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -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" }, diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 91f694abb..9961fe4f7 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -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