test
This commit is contained in:
28
src/komodo.h
28
src/komodo.h
@@ -324,7 +324,8 @@ void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotar
|
||||
|
||||
int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scriptbuf,int32_t scriptlen,int32_t height,uint256 txhash,int32_t i,int32_t j,uint64_t *voutmaskp,int32_t *specialtxp,int32_t *notarizedheightp,uint64_t value,int32_t notarized,uint64_t signedmask)
|
||||
{
|
||||
static uint256 zero; int32_t opretlen,nid,k,len = 0; uint256 kmdtxid,desttxid; uint8_t crypto777[33]; struct komodo_state *sp; char symbol[16],dest[16];
|
||||
static uint256 zero; static FILE *fp;
|
||||
int32_t opretlen,nid,k,len = 0; uint256 kmdtxid,desttxid; uint8_t crypto777[33]; struct komodo_state *sp; char symbol[16],dest[16];
|
||||
if ( (sp= komodo_stateptr(symbol,dest)) == 0 )
|
||||
return(-1);
|
||||
if ( scriptlen == 35 && scriptbuf[0] == 33 && scriptbuf[34] == 0xac )
|
||||
@@ -375,7 +376,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr
|
||||
if ( j == 1 && opretlen >= 32*2+4 && strcmp(ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,(char *)&scriptbuf[len+32*2+4]) == 0 )
|
||||
{
|
||||
len += iguana_rwbignum(0,&scriptbuf[len],32,(uint8_t *)&kmdtxid);
|
||||
len += iguana_rwnum(0,&scriptbuf[len],4,(uint8_t *)notarizedheightp);
|
||||
len += iguana_rwnum(0,&scriptbuf[len],sizeof(*notarizedheightp),(uint8_t *)notarizedheightp);
|
||||
len += iguana_rwbignum(0,&scriptbuf[len],32,(uint8_t *)&desttxid);
|
||||
if ( notarized != 0 && *notarizedheightp > sp->NOTARIZED_HEIGHT && *notarizedheightp < height )
|
||||
{
|
||||
@@ -386,10 +387,27 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr
|
||||
len += 4;
|
||||
if ( ASSETCHAINS_SYMBOL[0] == 0 )
|
||||
printf("%s ht.%d NOTARIZED.%d %s.%s %sTXID.%s (%s) lens.(%d %d)\n",ASSETCHAINS_SYMBOL,height,*notarizedheightp,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,kmdtxid.ToString().c_str(),ASSETCHAINS_SYMBOL[0]==0?"BTC":"KMD",desttxid.ToString().c_str(),(char *)&scriptbuf[len],opretlen,len);
|
||||
if ( ASSETCHAINS_SYMBOL[0] == 0 && opretlen > len && scriptbuf[len] == 'A' )
|
||||
if ( ASSETCHAINS_SYMBOL[0] == 0 )
|
||||
{
|
||||
printf("Found extradata.[%d] %d - %d\n",opretlen-len,opretlen,len);
|
||||
komodo_stateupdate(height,0,0,0,txhash,0,0,0,0,0,0,value,&scriptbuf[len],opretlen-len,j);
|
||||
if ( signedfp == 0 )
|
||||
{
|
||||
char fname[512];
|
||||
komodo_statefname(fname,"","signedmasks");
|
||||
if ( (signedfp= fopen(fname,"rb+")) == 0 )
|
||||
signedfp = fopen(fname,"wb");
|
||||
else fseek(signedfp,0,SEEK_END);
|
||||
}
|
||||
if ( signedfp != 0 )
|
||||
{
|
||||
fwrite(&height,1,sizeof(height),signedfp);
|
||||
fwrite(&signedmask,1,sizeof(signedmask),signedfp);
|
||||
fflush(signedfp);
|
||||
}
|
||||
if ( opretlen > len && scriptbuf[len] == 'A' )
|
||||
{
|
||||
printf("Found extradata.[%d] %d - %d\n",opretlen-len,opretlen,len);
|
||||
komodo_stateupdate(height,0,0,0,txhash,0,0,0,0,0,0,value,&scriptbuf[len],opretlen-len,j);
|
||||
}
|
||||
}
|
||||
} else printf("notarized.%d %llx reject ht.%d NOTARIZED.%d %s.%s DESTTXID.%s (%s)\n",notarized,(long long)signedmask,height,*notarizedheightp,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,kmdtxid.ToString().c_str(),desttxid.ToString().c_str(),(char *)&scriptbuf[len]);
|
||||
}
|
||||
|
||||
@@ -529,6 +529,14 @@ int8_t komodo_minerid(int32_t height)
|
||||
return(-1);
|
||||
}
|
||||
|
||||
int32_t komodo_minerids(uint8_t *minerids,int32_t height)
|
||||
{
|
||||
int32_t i,n=0;
|
||||
for (i=0; i<1000; i++,n++)
|
||||
minerids[i] = komodo_minerid(height - i);
|
||||
return(n);
|
||||
}
|
||||
|
||||
int32_t komodo_is_special(int32_t height,uint8_t pubkey33[33])
|
||||
{
|
||||
int32_t i,notaryid,minerid,limit;
|
||||
|
||||
@@ -387,6 +387,41 @@ int32_t komodo_paxprices(int32_t *heights,uint64_t *prices,int32_t max,char *bas
|
||||
int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height);
|
||||
char *bitcoin_address(char *coinaddr,uint8_t addrtype,uint8_t *pubkey_or_rmd160,int32_t len);
|
||||
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);
|
||||
|
||||
Value minerids(const Array& params, bool fHelp)
|
||||
{
|
||||
Object ret; Array a; uint8_t minerids[1000],pubkeys[64][33]; int32_t i,j,n,tally[65];
|
||||
if ( fHelp || params.size() != 1 )
|
||||
throw runtime_error("minerids needs height\n");
|
||||
LOCK(cs_main);
|
||||
if ( (n= komodo_minerids(minerids,height)) > 0 && n <= 64 )
|
||||
{
|
||||
memset(tally,0,sizeof(tally));
|
||||
for (i=0; i<n; i++)
|
||||
{
|
||||
if ( minerids[i] >= 64 )
|
||||
tally[64]++;
|
||||
else tally[minerids[i]]++;
|
||||
}
|
||||
if ( (n= komodo_notaries(pubkeys,height)) > 0 )
|
||||
{
|
||||
for (i=0; i<64; i++)
|
||||
{
|
||||
Object item; std::string hex; char *hexstr;
|
||||
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));
|
||||
item.push_back(Pair("blocks", tally[i]));
|
||||
a.push_back(item);
|
||||
}
|
||||
}
|
||||
ret.push_back(Pair("mined", a));
|
||||
} else ret.push_back(Pair("error", (char *)"couldnt extract minerids"));
|
||||
return ret;
|
||||
}
|
||||
|
||||
Value notaries(const Array& params, bool fHelp)
|
||||
{
|
||||
|
||||
@@ -110,6 +110,7 @@ static const CRPCConvertParam vRPCConvertParams[] =
|
||||
{ "paxprices", 3 },
|
||||
{ "paxpending", 3 },
|
||||
{ "notaries", 1 },
|
||||
{ "minerids", 1 },
|
||||
};
|
||||
|
||||
class CRPCConvertTable
|
||||
|
||||
@@ -304,6 +304,7 @@ static const CRPCCommand vRPCCommands[] =
|
||||
{ "blockchain", "paxpending", &paxpending, true },
|
||||
{ "blockchain", "paxprices", &paxprices, true },
|
||||
{ "blockchain", "notaries", ¬aries, true },
|
||||
{ "blockchain", "minerids", &minerids, true },
|
||||
|
||||
/* Mining */
|
||||
{ "mining", "getblocktemplate", &getblocktemplate, true },
|
||||
|
||||
@@ -244,6 +244,7 @@ extern json_spirit::Value getblock(const json_spirit::Array& params, bool fHelp)
|
||||
extern json_spirit::Value gettxoutsetinfo(const json_spirit::Array& params, bool fHelp);
|
||||
extern json_spirit::Value gettxout(const json_spirit::Array& params, bool fHelp);
|
||||
extern json_spirit::Value notaries(const json_spirit::Array& params, bool fHelp);
|
||||
extern json_spirit::Value minerids(const json_spirit::Array& params, bool fHelp);
|
||||
extern json_spirit::Value paxprice(const json_spirit::Array& params, bool fHelp);
|
||||
extern json_spirit::Value paxpending(const json_spirit::Array& params, bool fHelp);
|
||||
extern json_spirit::Value paxprices(const json_spirit::Array& params, bool fHelp);
|
||||
|
||||
Reference in New Issue
Block a user