@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/bin/bash
|
||||
set -x
|
||||
source pubkey.txt
|
||||
echo $pubkey
|
||||
|
||||
14
src/init.cpp
14
src/init.cpp
@@ -1244,14 +1244,10 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
LogPrintf("Prune: pruned datadir may not have more than %d blocks; -checkblocks=%d may fail\n",
|
||||
MIN_BLOCKS_TO_KEEP, GetArg("-checkblocks", 288));
|
||||
}
|
||||
extern int32_t KOMODO_REWIND;
|
||||
if ( KOMODO_REWIND == 0 )
|
||||
{
|
||||
if (!CVerifyDB().VerifyDB(pcoinsdbview, GetArg("-checklevel", 3),
|
||||
GetArg("-checkblocks", 288))) {
|
||||
strLoadError = _("Corrupted block database detected");
|
||||
break;
|
||||
}
|
||||
if (!CVerifyDB().VerifyDB(pcoinsdbview, GetArg("-checklevel", 3),
|
||||
GetArg("-checkblocks", 288))) {
|
||||
strLoadError = _("Corrupted block database detected");
|
||||
break;
|
||||
}
|
||||
} catch (const std::exception& e) {
|
||||
if (fDebug) LogPrintf("%s\n", e.what());
|
||||
@@ -1464,7 +1460,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
uiInterface.InitMessage(_("Activating best chain..."));
|
||||
// scan for better chains in the block chain database, that are not yet connected in the active best chain
|
||||
CValidationState state;
|
||||
if (!ActivateBestChain(state))
|
||||
if ( !ActivateBestChain(state))
|
||||
strErrors << "Failed to connect best block";
|
||||
|
||||
std::vector<boost::filesystem::path> vImportFiles;
|
||||
|
||||
@@ -446,7 +446,8 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr
|
||||
printf("ISRATIFICATION (%s)\n",(char *)&scriptbuf[len+32*2+4]);
|
||||
}
|
||||
}
|
||||
if ( *isratificationp == 0 )
|
||||
|
||||
if ( *isratificationp == 0 && (signedmask != 0 || (scriptbuf[len] != 'X' && scriptbuf[len] != 'A' && scriptbuf[len] != 'I')) )
|
||||
komodo_stateupdate(height,0,0,0,txhash,0,0,0,0,0,0,value,&scriptbuf[len],opretlen,j);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
int32_t pax_fiatstatus(uint64_t *available,uint64_t *deposited,uint64_t *issued,uint64_t *withdrawn,uint64_t *approved,uint64_t *redeemed,char *base)
|
||||
{
|
||||
int32_t baseid; struct komodo_state *sp; int64_t netliability,maxallowed;
|
||||
int32_t baseid; struct komodo_state *sp; int64_t netliability,maxallowed,maxval;
|
||||
*available = *deposited = *issued = *withdrawn = *approved = *redeemed = 0;
|
||||
if ( (baseid= komodo_baseid(base)) >= 0 )
|
||||
{
|
||||
@@ -28,11 +28,14 @@ int32_t pax_fiatstatus(uint64_t *available,uint64_t *deposited,uint64_t *issued,
|
||||
*withdrawn = sp->withdrawn;
|
||||
*approved = sp->approved;
|
||||
*redeemed = sp->redeemed;
|
||||
netliability = (sp->deposited - sp->withdrawn) - sp->shorted;
|
||||
maxval = sp->approved;
|
||||
if ( sp->withdrawn > maxval )
|
||||
maxval = sp->withdrawn;
|
||||
netliability = (sp->issued - maxval) - sp->shorted;
|
||||
maxallowed = komodo_maxallowed(baseid);
|
||||
if ( netliability < maxallowed )
|
||||
*available = (maxallowed - netliability);
|
||||
//printf("%p %s %.8f %.8f %.8f %.8f %.8f\n",sp,base,dstr(*deposited),dstr(*issued),dstr(*withdrawn),dstr(*approved),dstr(*redeemed));
|
||||
//printf("%llu - %llu %s %.8f %.8f %.8f %.8f %.8f\n",(long long)maxallowed,(long long)netliability,base,dstr(*deposited),dstr(*issued),dstr(*withdrawn),dstr(*approved),dstr(*redeemed));
|
||||
return(0);
|
||||
} else printf("pax_fiatstatus cant get basesp.%s\n",base);
|
||||
} // else printf("pax_fiatstatus illegal base.%s\n",base);
|
||||
@@ -265,7 +268,7 @@ int32_t komodo_paxcmp(char *symbol,int32_t kmdheight,uint64_t value,uint64_t che
|
||||
if ( seed == 0 && checkvalue != 0 )
|
||||
{
|
||||
ratio = ((value << 6) / checkvalue);
|
||||
if ( ratio >= 63 && ratio <= 65 )
|
||||
if ( ratio >= 62 && ratio <= 66 )
|
||||
return(0);
|
||||
else
|
||||
{
|
||||
@@ -486,7 +489,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to
|
||||
else
|
||||
{
|
||||
opcode = 'X';
|
||||
if ( komodo_paxtotal() == 0 )
|
||||
if ( 1 || komodo_paxtotal() == 0 )
|
||||
return(0);
|
||||
}
|
||||
HASH_ITER(hh,PAX,pax,tmp)
|
||||
@@ -528,6 +531,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to
|
||||
{
|
||||
if ( strcmp(pax->symbol,ASSETCHAINS_SYMBOL) == 0 )
|
||||
printf("pax->symbol.%s != %s or null pax->validated %.8f ready.%d ht.(%d %d)\n",pax->symbol,symbol,dstr(pax->validated),pax->ready,kmdsp->CURRENT_HEIGHT,pax->height);
|
||||
pax->marked = pax->fiatoshis;
|
||||
continue;
|
||||
}
|
||||
if ( pax->ready == 0 )
|
||||
@@ -571,7 +575,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to
|
||||
PENDING_KOMODO_TX += pax->komodoshis;
|
||||
printf(" len.%d vout.%u DEPOSIT %.8f <- pax.%s pending ht %d %d %.8f | ",len,pax->vout,(double)txNew->vout[numvouts].nValue/COIN,symbol,pax->height,pax->otherheight,dstr(PENDING_KOMODO_TX));
|
||||
}
|
||||
if ( numvouts++ >= 64 )
|
||||
if ( numvouts++ >= 1 )
|
||||
break;
|
||||
}
|
||||
if ( numvouts > 1 )
|
||||
@@ -630,7 +634,7 @@ void komodo_bannedset(uint256 *array,int32_t max)
|
||||
int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above block is valid pax pricing
|
||||
{
|
||||
static uint256 array[15];
|
||||
int32_t i,j,k,n,ht,txn_count,num,opretlen,offset=1,errs=0,matched=0,kmdheights[64],otherheights[64]; uint256 hash,txids[64]; char symbol[16],base[16]; uint16_t vouts[64]; int8_t baseids[64]; uint8_t *script,opcode,rmd160s[64*20]; uint64_t available,deposited,issued,withdrawn,approved,redeemed; int64_t values[64],srcvalues[64]; struct pax_transaction *pax; struct komodo_state *sp;
|
||||
int32_t i,j,k,n,ht,txn_count,num,opretlen,offset=1,errs=0,matched=0,kmdheights[64],otherheights[64]; uint256 hash,txids[64]; char symbol[16],base[16]; uint16_t vouts[64]; int8_t baseids[64]; uint8_t *script,opcode,rmd160s[64*20]; uint64_t total,available,deposited,issued,withdrawn,approved,redeemed; int64_t values[64],srcvalues[64]; struct pax_transaction *pax; struct komodo_state *sp;
|
||||
if ( *(int32_t *)&array[0] == 0 )
|
||||
komodo_bannedset(array,(int32_t)(sizeof(array)/sizeof(*array)));
|
||||
memset(baseids,0xff,sizeof(baseids));
|
||||
@@ -659,7 +663,24 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above
|
||||
script = (uint8_t *)block.vtx[0].vout[n-1].scriptPubKey.data();
|
||||
if ( n <= 2 || script[0] != 0x6a )
|
||||
{
|
||||
if ( n == 2 && block.vtx[0].vout[1].nValue > COIN/10 )
|
||||
int64_t val,prevtotal = 0; int32_t overflow = 0;
|
||||
total = 0;
|
||||
for (i=1; i<n; i++)
|
||||
{
|
||||
if ( (val= block.vtx[0].vout[i].nValue) < 0 || val >= MAX_MONEY )
|
||||
{
|
||||
overflow = 1;
|
||||
break;
|
||||
}
|
||||
total += val;
|
||||
if ( total < prevtotal || (val != 0 && total == prevtotal) )
|
||||
{
|
||||
overflow = 1;
|
||||
break;
|
||||
}
|
||||
prevtotal = total;
|
||||
}
|
||||
if ( overflow != 0 || total > COIN/10 )
|
||||
{
|
||||
//fprintf(stderr,">>>>>>>> <<<<<<<<<< ht.%d illegal nonz output %.8f n.%d\n",height,dstr(block.vtx[0].vout[1].nValue),n);
|
||||
if ( height >= 235300 )
|
||||
@@ -667,16 +688,17 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
//fprintf(stderr,"ht.%d n.%d nValue %.8f (%d %d %d)\n",height,n,dstr(block.vtx[0].vout[1].nValue),KOMODO_PAX,komodo_isrealtime(&ht),KOMODO_PASSPORT_INITDONE);
|
||||
if ( komodo_isrealtime(&ht) == 0 || KOMODO_PASSPORT_INITDONE == 0 ) //KOMODO_PAX == 0 ||
|
||||
return(0);
|
||||
offset += komodo_scriptitemlen(&opretlen,&script[offset]);
|
||||
if ( ASSETCHAINS_SYMBOL[0] == 0 )
|
||||
{
|
||||
//for (i=0; i<opretlen; i++)
|
||||
// printf("%02x",script[i]);
|
||||
//printf(" height.%d checkdeposit n.%d [%02x] [%c] %d vs %d\n",height,n,script[0],script[offset],script[offset],'X');
|
||||
for (i=0; i<opretlen; i++)
|
||||
printf("%02x",script[i]);
|
||||
printf(" height.%d checkdeposit n.%d [%02x] [%c] %d vs %d\n",height,n,script[0],script[offset],script[offset],'X');
|
||||
opcode = 'X';
|
||||
if ( height >= 235300 )
|
||||
return(-1);
|
||||
strcpy(symbol,(char *)"KMD");
|
||||
}
|
||||
else
|
||||
@@ -693,6 +715,8 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
if ( komodo_isrealtime(&ht) == 0 || KOMODO_PASSPORT_INITDONE == 0 ) //KOMODO_PAX == 0 ||
|
||||
return(0);
|
||||
if ( script[offset] == opcode && opretlen < block.vtx[0].vout[n-1].scriptPubKey.size() )
|
||||
{
|
||||
if ( (num= komodo_issued_opreturn(base,txids,vouts,values,srcvalues,kmdheights,otherheights,baseids,rmd160s,&script[offset],opretlen,opcode == 'X')) > 0 )
|
||||
@@ -711,9 +735,9 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above
|
||||
if ( opcode == 'I' && (pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,symbol) != 0 || available < pax->fiatoshis) )
|
||||
{
|
||||
printf("checkdeposit.[%s]: skip %s %.8f when avail %.8f deposited %.8f, issued %.8f withdrawn %.8f approved %.8f redeemed %.8f\n",ASSETCHAINS_SYMBOL,symbol,dstr(pax->fiatoshis),dstr(available),dstr(deposited),dstr(issued),dstr(withdrawn),dstr(approved),dstr(redeemed));
|
||||
continue;
|
||||
return(-1);
|
||||
}
|
||||
if ( ((opcode == 'I' && (pax->fiatoshis == 0 || pax->fiatoshis == block.vtx[0].vout[i].nValue)) || (opcode == 'X' && (pax->komodoshis == 0 || pax->komodoshis == block.vtx[0].vout[i].nValue))) )
|
||||
if ( pax->fiatoshis == block.vtx[0].vout[i].nValue )
|
||||
{
|
||||
if ( pax->marked != 0 && height >= 80820 )
|
||||
{
|
||||
@@ -856,7 +880,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
|
||||
if ( 0 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 )
|
||||
printf("########### %p depositedB %s += %.8f/%.8f kmdheight.%d/%d %.8f/%.8f\n",basesp,base,dstr(fiatoshis),dstr(pax->fiatoshis),kmdheight,pax->height,dstr(value),dstr(pax->komodoshis));
|
||||
}
|
||||
}
|
||||
} //
|
||||
if ( didstats != 0 )
|
||||
pax->didstats = 1;
|
||||
if ( (pax2= komodo_paxfind(txid,vout,'I')) != 0 )
|
||||
@@ -878,8 +902,13 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( kmdheight > 238000 && (kmdheight > 214700 || strcmp(base,ASSETCHAINS_SYMBOL) == 0) ) //seed != 0 &&
|
||||
printf("pax %s deposit %.8f rejected kmdheight.%d %.8f KMD check %.8f seed.%llu\n",base,dstr(fiatoshis),kmdheight,dstr(value),dstr(checktoshis),(long long)seed);
|
||||
else
|
||||
{
|
||||
if ( (pax= komodo_paxfind(txid,vout,'D')) != 0 )
|
||||
pax->marked = checktoshis;
|
||||
if ( kmdheight > 238000 && (kmdheight > 214700 || strcmp(base,ASSETCHAINS_SYMBOL) == 0) ) //seed != 0 &&
|
||||
printf("pax %s deposit %.8f rejected kmdheight.%d %.8f KMD check %.8f seed.%llu\n",base,dstr(fiatoshis),kmdheight,dstr(value),dstr(checktoshis),(long long)seed);
|
||||
}
|
||||
} //else printf("paxdeposit height.%d vs kmdheight.%d\n",height,kmdheight);
|
||||
}
|
||||
}
|
||||
@@ -932,7 +961,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
|
||||
} //else printf("opreturn none issued?\n");
|
||||
}
|
||||
}
|
||||
else if ( opretbuf[0] == 'W' )//&& opretlen >= 38 )
|
||||
else if ( height < 236000 && opretbuf[0] == 'W' )//&& opretlen >= 38 )
|
||||
{
|
||||
if ( komodo_baseid((char *)&opretbuf[opretlen-4]) >= 0 && strcmp(ASSETCHAINS_SYMBOL,(char *)&opretbuf[opretlen-4]) == 0 )
|
||||
{
|
||||
@@ -977,7 +1006,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
|
||||
} // else printf("withdraw %s paxcmp ht.%d %d error value %.8f -> %.8f vs %.8f\n",base,kmdheight,height,dstr(value),dstr(komodoshis),dstr(checktoshis));
|
||||
// need to allocate pax
|
||||
}
|
||||
else if ( tokomodo != 0 && opretbuf[0] == 'A' )
|
||||
else if ( height < 236000 && tokomodo != 0 && opretbuf[0] == 'A' )
|
||||
{
|
||||
tokomodo = 1;
|
||||
if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 )
|
||||
@@ -1056,7 +1085,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
|
||||
} //else printf("n.%d from opreturns\n",n);
|
||||
//printf("extra.[%d] after %.8f\n",n,dstr(komodo_paxtotal()));
|
||||
}
|
||||
else if ( opretbuf[0] == 'X' )
|
||||
else if ( height < 236000 && opretbuf[0] == 'X' )
|
||||
{
|
||||
tokomodo = 1;
|
||||
if ( (n= komodo_issued_opreturn(base,txids,vouts,values,srcvalues,kmdheights,otherheights,baseids,rmd160s,opretbuf,opretlen,1)) > 0 )
|
||||
@@ -1098,7 +1127,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
|
||||
|
||||
void komodo_passport_iteration()
|
||||
{
|
||||
static long lastpos[34]; static char userpass[33][1024]; int32_t maxseconds = 17;
|
||||
static long lastpos[34]; static char userpass[33][1024]; int32_t maxseconds = 1;
|
||||
FILE *fp; int32_t baseid,n,ht,isrealtime,expired,refid,blocks,longest; struct komodo_state *sp,*refsp; char *retstr,fname[512],*base,symbol[16],dest[16]; uint32_t buf[3],starttime; cJSON *infoobj,*result; uint64_t RTmask = 0;
|
||||
//printf("PASSPORT.(%s)\n",ASSETCHAINS_SYMBOL);
|
||||
expired = 0;
|
||||
@@ -1147,7 +1176,7 @@ void komodo_passport_iteration()
|
||||
if ( 0 && lastpos[baseid] == 0 && strcmp(symbol,"KMD") == 0 )
|
||||
printf("passport refid.%d %s fname.(%s) base.%s\n",refid,symbol,fname,base);
|
||||
fseek(fp,lastpos[baseid],SEEK_SET);
|
||||
while ( komodo_parsestatefile(sp,fp,symbol,dest) >= 0 && n < 10000 )
|
||||
while ( komodo_parsestatefile(sp,fp,symbol,dest) >= 0 && n < 1000 )
|
||||
{
|
||||
if ( n == 999 )
|
||||
{
|
||||
@@ -1178,7 +1207,7 @@ void komodo_passport_iteration()
|
||||
isrealtime = 1;
|
||||
RTmask |= (1LL << baseid);
|
||||
memcpy(refsp->RTbufs[baseid+1],buf,sizeof(refsp->RTbufs[baseid+1]));
|
||||
} else if ( (time(NULL)-buf[2]) > 1800 )
|
||||
} else if ( (time(NULL)-buf[2]) > 1800 && ASSETCHAINS_SYMBOL[0] != 0 )
|
||||
fprintf(stderr,"[%s]: %s not RT %u %u %d\n",ASSETCHAINS_SYMBOL,base,buf[0],buf[1],(int32_t)(time(NULL)-buf[2]));
|
||||
} //else fprintf(stderr,"%s size error RT\n",base);
|
||||
fclose(fp);
|
||||
|
||||
@@ -40,7 +40,7 @@ struct komodo_state KOMODO_STATES[34];
|
||||
#define _COINBASE_MATURITY 100
|
||||
int COINBASE_MATURITY = _COINBASE_MATURITY;//100;
|
||||
|
||||
int32_t IS_KOMODO_NOTARY,KOMODO_REWIND,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET;
|
||||
int32_t IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET;
|
||||
int32_t KOMODO_LASTMINED,prevKOMODO_LASTMINED;
|
||||
std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES;
|
||||
uint8_t NOTARY_PUBKEY33[33];
|
||||
|
||||
@@ -73,6 +73,8 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin
|
||||
{
|
||||
if ( (minutes= (tiptime - nLockTime) / 60) >= 60 )
|
||||
{
|
||||
if ( minutes > 365 * 24 * 60 )
|
||||
minutes = 365 * 24 * 60;
|
||||
denominator = (((uint64_t)365 * 24 * 60) / minutes);
|
||||
if ( denominator == 0 )
|
||||
denominator = 1; // max KOMODO_INTEREST per transfer, do it at least annually!
|
||||
@@ -102,7 +104,9 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin
|
||||
if ( exception == 0 )
|
||||
{
|
||||
numerator = (nValue / 20); // assumes 5%!
|
||||
interest = (numerator / denominator);
|
||||
if ( txheight < 300000 )
|
||||
interest = (numerator / denominator);
|
||||
else interest = (numerator * minutes) / ((uint64_t)365 * 24 * 60);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -113,7 +117,9 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin
|
||||
else
|
||||
{
|
||||
numerator = (nValue * KOMODO_INTEREST);
|
||||
interest = (numerator / denominator) / COIN;
|
||||
if ( txheight < 300000 || numerator * minutes < 365 * 24 * 60 )
|
||||
interest = (numerator / denominator) / COIN;
|
||||
else interest = ((numerator * minutes) / ((uint64_t)365 * 24 * 60)) / COIN;
|
||||
}
|
||||
//fprintf(stderr,"komodo_interest %lld %.8f nLockTime.%u tiptime.%u minutes.%d interest %lld %.8f (%llu / %llu)\n",(long long)nValue,(double)nValue/COIN,nLockTime,tiptime,minutes,(long long)interest,(double)interest/COIN,(long long)numerator,(long long)denominator);
|
||||
}
|
||||
|
||||
@@ -1463,8 +1463,10 @@ void komodo_args()
|
||||
KOMODO_PAX = 1;
|
||||
} else KOMODO_PAX = GetArg("-pax",0);
|
||||
name = GetArg("-ac_name","");
|
||||
if ( (KOMODO_REWIND= GetArg("-rewind",0)) != 0 )
|
||||
;
|
||||
/*if ( (KOMODO_REWIND= GetArg("-rewind",0)) != 0 )
|
||||
{
|
||||
printf("KOMODO_REWIND %d\n",KOMODO_REWIND);
|
||||
}*/
|
||||
if ( name.c_str()[0] != 0 )
|
||||
{
|
||||
ASSETCHAINS_SUPPLY = GetArg("-ac_supply",10);
|
||||
|
||||
34
src/main.cpp
34
src/main.cpp
@@ -1548,8 +1548,8 @@ bool IsInitialBlockDownload()
|
||||
else if ( pindexBestHeader != 0 && pindexBestHeader->nHeight > ptr->nHeight )
|
||||
ptr = pindexBestHeader;
|
||||
if ( ASSETCHAINS_SYMBOL[0] == 0 )
|
||||
state = (chainActive.Height() < ptr->nHeight - 24*6) ||
|
||||
ptr->GetBlockTime() < (GetTime() - chainParams.MaxTipAge());
|
||||
state = ((chainActive.Height() < ptr->nHeight - 24*6) ||
|
||||
ptr->GetBlockTime() < (GetTime() - chainParams.MaxTipAge()));
|
||||
else state = (chainActive.Height() < ptr->nHeight - 100);
|
||||
//fprintf(stderr,"state.%d ht.%d vs %d, t.%u %u\n",state,(int32_t)chainActive.Height(),(uint32_t)ptr->nHeight,(int32_t)ptr->GetBlockTime(),(uint32_t)(GetTime() - chainParams.MaxTipAge()));
|
||||
if (!state)
|
||||
@@ -2758,7 +2758,6 @@ static void PruneBlockIndexCandidates() {
|
||||
* pblock is either NULL or a pointer to a CBlock corresponding to pindexMostWork.
|
||||
*/
|
||||
static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMostWork, CBlock *pblock) {
|
||||
extern int32_t KOMODO_REWIND;
|
||||
AssertLockHeld(cs_main);
|
||||
bool fInvalidFound = false;
|
||||
const CBlockIndex *pindexOldTip = chainActive.Tip();
|
||||
@@ -2769,21 +2768,28 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo
|
||||
if (!DisconnectTip(state))
|
||||
return false;
|
||||
}
|
||||
if ( KOMODO_REWIND != 0 && chainActive.Tip()->nHeight > KOMODO_REWIND )
|
||||
/*fprintf(stderr,"chaintip %d vs rewind.%d\n",(int32_t)chainActive.Tip()->nHeight,KOMODO_REWIND);
|
||||
if ( KOMODO_REWIND != 0 && chainActive.Tip()->nHeight >= KOMODO_REWIND )
|
||||
{
|
||||
static int32_t didinit;
|
||||
if ( didinit++ == 0 )
|
||||
fprintf(stderr,"rewind ht.%d\n",chainActive.Tip()->nHeight);
|
||||
while ( chainActive.Tip()->nHeight > KOMODO_REWIND )
|
||||
{
|
||||
while (chainActive.Tip()->nHeight > KOMODO_REWIND )
|
||||
if ( !DisconnectTip(state) )
|
||||
{
|
||||
fprintf(stderr,"rewind ht.%d\n",chainActive.Tip()->nHeight);
|
||||
if ( !DisconnectTip(state) )
|
||||
return false;
|
||||
//InvalidateBlock(state,chainActive.Tip());
|
||||
return false;
|
||||
}
|
||||
pindexOldTip = chainActive.Tip();
|
||||
pindexFork = chainActive.FindFork(pindexMostWork);
|
||||
}
|
||||
}
|
||||
fprintf(stderr,"end rewind ht.%d\n",chainActive.Tip()->nHeight);
|
||||
if ( chainActive.Tip()->nHeight == KOMODO_REWIND )
|
||||
{
|
||||
fprintf(stderr,"reached rewind.%d, best to do: ./komodo-cli stop\n",KOMODO_REWIND);
|
||||
sleep(3);
|
||||
return(true);
|
||||
}
|
||||
pindexOldTip = chainActive.Tip();
|
||||
pindexFork = chainActive.FindFork(pindexMostWork);
|
||||
}*/
|
||||
// Build list of new blocks to connect.
|
||||
std::vector<CBlockIndex*> vpindexToConnect;
|
||||
bool fContinue = true;
|
||||
@@ -2859,7 +2865,6 @@ bool ActivateBestChain(CValidationState &state, CBlock *pblock) {
|
||||
|
||||
if (!ActivateBestChainStep(state, pindexMostWork, pblock && pblock->GetHash() == pindexMostWork->GetBlockHash() ? pblock : NULL))
|
||||
return false;
|
||||
|
||||
pindexNewTip = chainActive.Tip();
|
||||
fInitialDownload = IsInitialBlockDownload();
|
||||
}
|
||||
@@ -3258,7 +3263,6 @@ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& sta
|
||||
else if ( komodo_checkpoint(¬arized_height,nHeight,hash) < 0 )
|
||||
return state.DoS(100, error("%s: forked chain %d older than last notarized (height %d) vs %d", __func__,nHeight, notarized_height));
|
||||
}
|
||||
|
||||
// Reject block.nVersion < 4 blocks
|
||||
if (block.nVersion < 4)
|
||||
return state.Invalid(error("%s : rejected nVersion<4 block", __func__),
|
||||
|
||||
@@ -101,7 +101,7 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams,
|
||||
#define ASSETCHAINS_MINHEIGHT 100
|
||||
#define KOMODO_ELECTION_GAP 2000
|
||||
#define ROUNDROBIN_DELAY 59
|
||||
extern int32_t ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE;
|
||||
extern int32_t ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE,KOMODO_PASSPORT_INITDONE;
|
||||
extern char ASSETCHAINS_SYMBOL[16];
|
||||
extern std::string NOTARY_PUBKEY;
|
||||
extern uint8_t NOTARY_PUBKEY33[33];
|
||||
@@ -133,7 +133,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
|
||||
while ( KOMODO_ON_DEMAND == 0 && deposits == 0 && (int32_t)mempool.GetTotalTxSize() == 0 )
|
||||
{
|
||||
deposits = komodo_paxtotal();
|
||||
if ( KOMODO_INITDONE == 0 || (komodo_baseid(ASSETCHAINS_SYMBOL) >= 0 && (isrealtime= komodo_isrealtime(&kmdheight)) == 0) )
|
||||
if ( KOMODO_PASSPORT_INITDONE == 0 || KOMODO_INITDONE == 0 || (komodo_baseid(ASSETCHAINS_SYMBOL) >= 0 && (isrealtime= komodo_isrealtime(&kmdheight)) == 0) )
|
||||
{
|
||||
//fprintf(stderr,"INITDONE.%d RT.%d deposits %.8f ht.%d\n",KOMODO_INITDONE,isrealtime,(double)deposits/COIN,kmdheight);
|
||||
}
|
||||
@@ -403,9 +403,10 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
|
||||
else if ( komodo_is_issuer() != 0 )
|
||||
{
|
||||
komodo_gateway_deposits(&txNew,ASSETCHAINS_SYMBOL,0);
|
||||
//if ( txNew.vout.size() > 1 )
|
||||
if ( txNew.vout.size() > 1 )
|
||||
fprintf(stderr,"%s txNew numvouts.%d\n",ASSETCHAINS_SYMBOL,(int32_t)txNew.vout.size());
|
||||
}
|
||||
|
||||
pblock->vtx[0] = txNew;
|
||||
pblocktemplate->vTxFees[0] = -nFees;
|
||||
// Randomise nonce
|
||||
@@ -589,7 +590,7 @@ void static BitcoinMiner(CWallet *pwallet)
|
||||
LOCK(cs_vNodes);
|
||||
fvNodesEmpty = vNodes.empty();
|
||||
}
|
||||
if (!fvNodesEmpty && !IsInitialBlockDownload())
|
||||
if (!fvNodesEmpty )//&& !IsInitialBlockDownload())
|
||||
break;
|
||||
MilliSleep(5000);
|
||||
//fprintf(stderr,"fvNodesEmpty %d IsInitialBlockDownload(%s) %d\n",(int32_t)fvNodesEmpty,ASSETCHAINS_SYMBOL,(int32_t)IsInitialBlockDownload());
|
||||
@@ -612,7 +613,7 @@ void static BitcoinMiner(CWallet *pwallet)
|
||||
Mining_height = pindexPrev->nHeight+1;
|
||||
Mining_start = (uint32_t)time(NULL);
|
||||
}
|
||||
if ( ASSETCHAINS_SYMBOL[0] != 0 )
|
||||
if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 )
|
||||
fprintf(stderr,"%s create new block ht.%d\n",ASSETCHAINS_SYMBOL,Mining_height);
|
||||
CBlockTemplate *ptr = CreateNewBlockWithKey(reservekey);
|
||||
if ( ptr == 0 )
|
||||
@@ -629,6 +630,17 @@ void static BitcoinMiner(CWallet *pwallet)
|
||||
return;
|
||||
}
|
||||
CBlock *pblock = &pblocktemplate->block;
|
||||
if ( ASSETCHAINS_SYMBOL[0] != 0 )
|
||||
{
|
||||
if ( pblock->vtx[0].vout.size() == 1 && Mining_height > ASSETCHAINS_MINHEIGHT )
|
||||
{
|
||||
static uint32_t counter;
|
||||
if ( counter++ < 10 )
|
||||
fprintf(stderr,"skip generating %s on-demand block, no tx avail\n",ASSETCHAINS_SYMBOL);
|
||||
sleep(10);
|
||||
continue;
|
||||
} else fprintf(stderr,"vouts.%d mining.%d vs %d\n",(int32_t)pblock->vtx[0].vout.size(),Mining_height,ASSETCHAINS_MINHEIGHT);
|
||||
}
|
||||
IncrementExtraNonce(pblock, pindexPrev, nExtraNonce);
|
||||
LogPrintf("Running KomodoMiner.%s with %u transactions in block (%u bytes)\n",solver.c_str(),pblock->vtx.size(),::GetSerializeSize(*pblock,SER_NETWORK,PROTOCOL_VERSION));
|
||||
//
|
||||
@@ -685,12 +697,12 @@ void static BitcoinMiner(CWallet *pwallet)
|
||||
} else Mining_start = 0;
|
||||
while (true)
|
||||
{
|
||||
if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 && pblock->vtx[0].vout.size() == 1 && Mining_height > ASSETCHAINS_MINHEIGHT ) // skips when it shouldnt
|
||||
/*if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 && pblock->vtx[0].vout.size() == 1 && Mining_height > ASSETCHAINS_MINHEIGHT ) // skips when it shouldnt
|
||||
{
|
||||
fprintf(stderr,"skip generating %s on-demand block, no tx avail\n",ASSETCHAINS_SYMBOL);
|
||||
sleep(10);
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
// Hash state
|
||||
KOMODO_CHOSEN_ONE = 0;
|
||||
crypto_generichash_blake2b_state state;
|
||||
|
||||
@@ -119,7 +119,7 @@ extern std::string NOTARY_PUBKEY;
|
||||
|
||||
bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned int nBits, const Consensus::Params& params)
|
||||
{
|
||||
extern int32_t KOMODO_REWIND;
|
||||
//extern int32_t KOMODO_REWIND;
|
||||
bool fNegative,fOverflow; int32_t i,nonzpkeys=0,nonz=0,special=0,special2=0,notaryid=-1,duplicate,flag = 0, mids[66];
|
||||
arith_uint256 bnTarget; CBlockIndex *pindex; uint8_t pubkeys[66][33];
|
||||
|
||||
@@ -155,7 +155,8 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in
|
||||
// Check proof of work matches claimed amount
|
||||
if ( UintToArith256(hash) > bnTarget )
|
||||
{
|
||||
if ( (height < 235300 || height >= 236000) && KOMODO_LOADINGBLOCKS == 0 && height > 188000 && KOMODO_REWIND == 0 )//186269, 182507&& komodo_chainactive(height) != 0 && nonzpkeys > 0
|
||||
if ( (height < 235300 || height >= 236000) && KOMODO_LOADINGBLOCKS == 0 && height > 188000 )
|
||||
//&& KOMODO_REWIND == 0 )//186269, 182507&& komodo_chainactive(height) != 0 && nonzpkeys > 0
|
||||
{
|
||||
int32_t i;
|
||||
for (i=31; i>=0; i--)
|
||||
@@ -163,7 +164,7 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in
|
||||
printf(" hash vs ");
|
||||
for (i=31; i>=0; i--)
|
||||
printf("%02x",((uint8_t *)&bnTarget)[i]);
|
||||
printf(" ht.%d REWIND.%d special.%d notaryid.%d ht.%d mod.%d error\n",height,KOMODO_REWIND,special,notaryid,height,(height % 35));
|
||||
printf(" ht.%d special.%d notaryid.%d ht.%d mod.%d error\n",height,special,notaryid,height,(height % 35));
|
||||
for (i=0; i<33; i++)
|
||||
printf("%02x",pubkey33[i]);
|
||||
printf(" <- pubkey\n");
|
||||
|
||||
@@ -530,8 +530,8 @@ Value getblocktemplate(const Array& params, bool fHelp)
|
||||
if (vNodes.empty())
|
||||
throw JSONRPCError(RPC_CLIENT_NOT_CONNECTED, "Zcash is not connected!");
|
||||
|
||||
if (IsInitialBlockDownload())
|
||||
throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "Zcash is downloading blocks...");
|
||||
//if (IsInitialBlockDownload())
|
||||
// throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "Zcash is downloading blocks...");
|
||||
|
||||
static unsigned int nTransactionsUpdatedLast;
|
||||
|
||||
|
||||
@@ -632,7 +632,10 @@ Value paxdeposit(const Array& params, bool fHelp)
|
||||
std::string dest;
|
||||
height = chainActive.Tip()->nHeight;
|
||||
if ( pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,(char *)base.c_str()) != 0 || available < fiatoshis )
|
||||
{
|
||||
fprintf(stderr,"available %llu vs fiatoshis %llu\n",(long long)available,(long long)fiatoshis);
|
||||
throw runtime_error("paxdeposit not enough available inventory");
|
||||
}
|
||||
komodoshis = PAX_fiatdest(&seed,0,destaddr,pubkey37,(char *)params[0].get_str().c_str(),height,(char *)base.c_str(),fiatoshis);
|
||||
dest.append(destaddr);
|
||||
CBitcoinAddress destaddress(CRYPTO777_KMDADDR);
|
||||
@@ -659,6 +662,7 @@ Value paxwithdraw(const Array& params, bool fHelp)
|
||||
return(0);
|
||||
if (!EnsureWalletIsAvailable(fHelp))
|
||||
return 0;
|
||||
throw runtime_error("paxwithdraw deprecated");
|
||||
if (fHelp || params.size() != 2)
|
||||
throw runtime_error("paxwithdraw address fiatamount");
|
||||
if ( komodo_isrealtime(&kmdheight) == 0 )
|
||||
|
||||
@@ -757,7 +757,7 @@ void CWallet::IncrementNoteWitnesses(const CBlockIndex* pindex,
|
||||
|
||||
void CWallet::DecrementNoteWitnesses(const CBlockIndex* pindex)
|
||||
{
|
||||
extern int32_t KOMODO_REWIND;
|
||||
//extern int32_t KOMODO_REWIND;
|
||||
{
|
||||
LOCK(cs_wallet);
|
||||
for (std::pair<const uint256, CWalletTx>& wtxItem : mapWallet) {
|
||||
@@ -806,7 +806,7 @@ void CWallet::DecrementNoteWitnesses(const CBlockIndex* pindex)
|
||||
extern char ASSETCHAINS_SYMBOL[16];
|
||||
fprintf(stderr,"%s nWitnessCacheSize.%d\n",ASSETCHAINS_SYMBOL,(int32_t)nWitnessCacheSize);
|
||||
}
|
||||
if ( KOMODO_REWIND == 0 )
|
||||
//if ( KOMODO_REWIND == 0 )
|
||||
assert(nWitnessCacheSize > 0);
|
||||
//if (fFileBacked) {
|
||||
// CWalletDB walletdb(strWalletFile);
|
||||
|
||||
Reference in New Issue
Block a user