Revert to main
This commit is contained in:
@@ -446,7 +446,7 @@ 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 && (signedmask != 0 || (scriptbuf[len] != 'X' && scriptbuf[len] != 'A' && scriptbuf[len] != 'I')) )
|
||||
if ( *isratificationp == 0 )
|
||||
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,maxval;
|
||||
int32_t baseid; struct komodo_state *sp; int64_t netliability,maxallowed;
|
||||
*available = *deposited = *issued = *withdrawn = *approved = *redeemed = 0;
|
||||
if ( (baseid= komodo_baseid(base)) >= 0 )
|
||||
{
|
||||
@@ -28,11 +28,7 @@ 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;
|
||||
netliability = (sp->deposited - sp->withdrawn) - sp->shorted;
|
||||
maxallowed = komodo_maxallowed(baseid);
|
||||
if ( netliability < maxallowed )
|
||||
*available = (maxallowed - netliability);
|
||||
@@ -60,22 +56,12 @@ struct pax_transaction *komodo_paxfind(uint256 txid,uint16_t vout,uint8_t type)
|
||||
return(pax);
|
||||
}
|
||||
|
||||
struct pax_transaction *komodo_paxfinds(int32_t strictflag,uint256 txid,uint16_t vout)
|
||||
struct pax_transaction *komodo_paxfinds(uint256 txid,uint16_t vout)
|
||||
{
|
||||
struct pax_transaction *pax; int32_t i; uint8_t types[] = { 'I', 'D', 'X', 'A', 'W' };
|
||||
if ( strictflag != 0 )
|
||||
{
|
||||
if ( (pax= komodo_paxfind(txid,vout,'D')) != 0 )
|
||||
for (i=0; i<sizeof(types)/sizeof(*types); i++)
|
||||
if ( (pax= komodo_paxfind(txid,vout,types[i])) != 0 )
|
||||
return(pax);
|
||||
//if ( (pax= komodo_paxfind(txid,vout,'X')) != 0 )
|
||||
// return(pax);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i=0; i<sizeof(types)/sizeof(*types); i++)
|
||||
if ( (pax= komodo_paxfind(txid,vout,types[i])) != 0 )
|
||||
return(pax);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
@@ -258,7 +244,7 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t
|
||||
vouts[n] = opretbuf[len++];
|
||||
vouts[n] = (opretbuf[len++] << 8) | vouts[n];
|
||||
baseids[n] = komodo_baseid(base);
|
||||
if ( (pax= komodo_paxfinds(0,txids[n],vouts[n])) != 0 )
|
||||
if ( (pax= komodo_paxfinds(txids[n],vouts[n])) != 0 )
|
||||
{
|
||||
values[n] = (strcmp("KMD",base) == 0) ? pax->komodoshis : pax->fiatoshis;
|
||||
srcvalues[n] = (strcmp("KMD",base) == 0) ? pax->fiatoshis : pax->komodoshis;
|
||||
@@ -357,11 +343,8 @@ uint64_t komodo_paxtotal()
|
||||
HASH_ITER(hh,PAX,pax,tmp)
|
||||
{
|
||||
pax->ready = 0;
|
||||
char str[65],coinaddr[64]; bits256 tmp;
|
||||
bitcoin_address(coinaddr,60,pax->rmd160,20);
|
||||
memcpy(&tmp,&pax->txid,sizeof(tmp));
|
||||
if ( 0 && pax->fiatoshis > 9000*SATOSHIDEN )//pax->type == 'A' )
|
||||
printf("(%s).%c pax.%s <- %s marked.%d %.8f -> %.8f validated.%d approved.%d %s\n",coinaddr,pax->type,pax->symbol,pax->source,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis),pax->validated != 0,pax->approved != 0,bits256_str(str,tmp));
|
||||
if ( 0 && pax->type == 'A' )
|
||||
printf("%p pax.%s <- %s marked.%d %.8f -> %.8f validated.%d approved.%d\n",pax,pax->symbol,pax->source,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis),pax->validated != 0,pax->approved != 0);
|
||||
if ( pax->marked != 0 )
|
||||
continue;
|
||||
if ( strcmp(symbol,pax->symbol) == 0 || pax->type == 'A' )
|
||||
@@ -442,7 +425,7 @@ int32_t komodo_pending_withdraws(char *opretstr) // todo: enforce deterministic
|
||||
if ( pax2->approved != 0 )
|
||||
pax->approved = pax2->approved;
|
||||
}
|
||||
else if ( (pax2= komodo_paxfind(pax->txid,pax->vout,'x')) != 0 )
|
||||
else if ( (pax2= komodo_paxfind(pax->txid,pax->vout,'X')) != 0 )
|
||||
pax->approved = pax->height;
|
||||
//printf("pending_withdraw: pax %s marked.%u approved.%u validated.%llu\n",pax->symbol,pax->marked,pax->approved,(long long)pax->validated);
|
||||
if ( pax->marked == 0 && pax->approved == 0 && pax->validated != 0 ) //strcmp((char *)"KMD",pax->symbol) == 0 &&
|
||||
@@ -477,7 +460,7 @@ int32_t komodo_pending_withdraws(char *opretstr) // todo: enforce deterministic
|
||||
int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t tokomodo)
|
||||
{
|
||||
struct pax_transaction *pax,*tmp; char symbol[16],dest[16]; uint8_t *script,opcode,opret[16384],data[16384]; int32_t i,baseid,ht,len=0,opretlen=0,numvouts=1; struct komodo_state *sp; uint64_t available,deposited,issued,withdrawn,approved,redeemed,mask;
|
||||
if ( KOMODO_PAX == 0 || KOMODO_PASSPORT_INITDONE == 0 || ASSETCHAINS_SYMBOL[0] == 0 )
|
||||
if ( KOMODO_PAX == 0 || KOMODO_PASSPORT_INITDONE == 0 )
|
||||
return(0);
|
||||
struct komodo_state *kmdsp = komodo_stateptrget((char *)"KMD");
|
||||
sp = komodo_stateptr(symbol,dest);
|
||||
@@ -503,7 +486,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to
|
||||
else
|
||||
{
|
||||
opcode = 'X';
|
||||
if ( 1 || komodo_paxtotal() == 0 )
|
||||
if ( komodo_paxtotal() == 0 )
|
||||
return(0);
|
||||
}
|
||||
HASH_ITER(hh,PAX,pax,tmp)
|
||||
@@ -533,7 +516,6 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to
|
||||
{
|
||||
if ( pax->height > 214700 || strcmp(ASSETCHAINS_SYMBOL,symbol) == 0 )
|
||||
printf("miner.[%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));
|
||||
pax->marked = pax->fiatoshis;
|
||||
continue;
|
||||
}
|
||||
/*printf("pax.%s marked.%d %.8f -> %.8f ready.%d validated.%d\n",pax->symbol,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis),pax->ready!=0,pax->validated!=0);
|
||||
@@ -589,7 +571,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++ >= 1 )
|
||||
if ( numvouts++ >= 64 )
|
||||
break;
|
||||
}
|
||||
if ( numvouts > 1 )
|
||||
@@ -599,12 +581,9 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to
|
||||
for (i=0; symbol[i]!=0; i++)
|
||||
data[len++] = symbol[i];
|
||||
data[len++] = 0;
|
||||
if ( 0 && pax != 0 )
|
||||
{
|
||||
for (i=0; i<32; i++)
|
||||
printf("%02x",((uint8_t *)&pax->txid)[32-1-i]);
|
||||
printf(" <- data[%d]\n",len);
|
||||
}
|
||||
for (i=0; i<len; i++)
|
||||
printf("%02x",data[i]);
|
||||
printf(" <- data[%d]\n",len);
|
||||
opretlen = komodo_opreturnscript(opret,opcode,data,len);
|
||||
txNew->vout.resize(numvouts+1);
|
||||
txNew->vout[numvouts].nValue = 0;
|
||||
@@ -651,7 +630,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,retval,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 maxval,total,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));
|
||||
@@ -702,8 +681,6 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above
|
||||
//printf(" height.%d checkdeposit n.%d [%02x] [%c] %d vs %d\n",height,n,script[0],script[offset],script[offset],'X');
|
||||
opcode = 'X';
|
||||
strcpy(symbol,(char *)"KMD");
|
||||
if ( height >= 235300 )
|
||||
return(-1); // no redeems for now
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -731,23 +708,15 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above
|
||||
matched++;
|
||||
continue;*/
|
||||
}
|
||||
if ( (pax= komodo_paxfinds(0,txids[i-1],vouts[i-1])) != 0 ) // finds... make sure right one
|
||||
if ( (pax= komodo_paxfinds(txids[i-1],vouts[i-1])) != 0 ) // finds... make sure right one
|
||||
{
|
||||
pax->type = opcode;
|
||||
if ( pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,symbol) < 0 )
|
||||
{
|
||||
matched++; // this node isnt running this assetchain, leaves validation to others
|
||||
continue;
|
||||
}
|
||||
maxval = approved;
|
||||
if ( redeemed > maxval )
|
||||
maxval = redeemed;
|
||||
if ( (opcode == 'I' && available < pax->fiatoshis) || (opcode == 'X' && pax->komodoshis > issued-maxval) )
|
||||
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;
|
||||
}
|
||||
if ( (opcode == 'I' && pax->fiatoshis == block.vtx[0].vout[i].nValue) || (opcode == 'X' && pax->komodoshis == block.vtx[0].vout[i].nValue) )
|
||||
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->marked != 0 && height >= 80820 )
|
||||
{
|
||||
@@ -818,7 +787,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above
|
||||
|
||||
const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int32_t opretlen,uint256 txid,uint16_t vout,char *source)
|
||||
{
|
||||
uint8_t rmd160[20],rmd160s[64*20],addrtype,shortflag,pubkey33[33]; int32_t didstats,i,j,n,kvheight,len,tokomodo,kmdheight,otherheights[64],kmdheights[64]; int8_t baseids[64]; char base[4],coinaddr[64],destaddr[64]; uint256 txids[64]; uint16_t vouts[64]; uint64_t convtoshis,seed; int64_t fee,fiatoshis,komodoshis,checktoshis,values[64],srcvalues[64]; struct pax_transaction *pax,*pax2; struct komodo_state *basesp; double diff;
|
||||
uint8_t rmd160[20],rmd160s[64*20],addrtype,shortflag,pubkey33[33]; int32_t didstats,i,j,n,kvheight,len,tokomodo,kmdheight,otherheights[64],kmdheights[64]; int8_t baseids[64]; char base[4],coinaddr[64],destaddr[64]; uint256 txids[64]; uint16_t vouts[64]; uint64_t convtoshis,seed; int64_t fee,fiatoshis,komodoshis,checktoshis,values[64],srcvalues[64]; struct pax_transaction *pax,*pax2; struct komodo_state *basesp; double diff;
|
||||
const char *typestr = "unknown";
|
||||
if ( ASSETCHAINS_SYMBOL[0] != 0 && komodo_baseid(ASSETCHAINS_SYMBOL) < 0 && opretbuf[0] != 'K' )
|
||||
{
|
||||
@@ -852,9 +821,9 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
|
||||
if ( kmdheight > 195000 || kmdheight <= height )
|
||||
{
|
||||
didstats = 0;
|
||||
if ( 1 && strcmp("EUR",ASSETCHAINS_SYMBOL) == 0 && kmdheight > 214700 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 )
|
||||
if ( 0 && kmdheight > 214700 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 )
|
||||
{
|
||||
printf("(%s) (%s) kmdheight.%d vs height.%d check %.8f vs %.8f tokomodo.%d %d seed.%llx paxcmp.%d\n",ASSETCHAINS_SYMBOL,base,kmdheight,height,dstr(checktoshis),dstr(value),komodo_is_issuer(),strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0,(long long)seed,komodo_paxcmp(base,kmdheight,value,checktoshis,0));
|
||||
printf("(%s) (%s) kmdheight.%d vs height.%d check %.8f vs %.8f tokomodo.%d %d seed.%llx\n",ASSETCHAINS_SYMBOL,base,kmdheight,height,dstr(checktoshis),dstr(value),komodo_is_issuer(),strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0,(long long)seed);
|
||||
for (i=0; i<32; i++)
|
||||
printf("%02x",((uint8_t *)&txid)[i]);
|
||||
printf(" <- txid.v%u ",vout);
|
||||
@@ -906,11 +875,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
|
||||
basesp->issued += pax2->fiatoshis;
|
||||
pax2->didstats = 1;
|
||||
if ( 0 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 )
|
||||
{
|
||||
char str[65]; bits256 tmp;
|
||||
memcpy(&tmp,&pax2->txid,sizeof(tmp));
|
||||
printf("########### %p issueda %s += %.8f kmdheight.%d %.8f other.%d (%s)\n",basesp,base,dstr(pax2->fiatoshis),pax2->height,dstr(pax2->komodoshis),pax2->otherheight,bits256_str(str,tmp));
|
||||
}
|
||||
printf("########### %p issueda %s += %.8f kmdheight.%d %.8f other.%d\n",basesp,base,dstr(pax2->fiatoshis),pax2->height,dstr(pax2->komodoshis),pax2->otherheight);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -956,7 +921,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
|
||||
pax->didstats = 1;
|
||||
pax->height = pax2->height;
|
||||
pax->otherheight = height;
|
||||
if ( strcmp("USD",ASSETCHAINS_SYMBOL) == 0 && strcmp(CURRENCIES[baseids[i]],ASSETCHAINS_SYMBOL) == 0 )
|
||||
if ( 0 && strcmp(CURRENCIES[baseids[i]],ASSETCHAINS_SYMBOL) == 0 )
|
||||
printf("########### %p issuedb %s += %.8f kmdheight.%d %.8f other.%d\n",basesp,CURRENCIES[baseids[i]],dstr(pax->fiatoshis),pax->height,dstr(pax->komodoshis),pax->otherheight);
|
||||
}
|
||||
}
|
||||
@@ -1094,7 +1059,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 ( opretbuf[0] == 'X' )
|
||||
{
|
||||
tokomodo = 1;
|
||||
if ( (n= komodo_issued_opreturn(base,txids,vouts,values,srcvalues,kmdheights,otherheights,baseids,rmd160s,opretbuf,opretlen,1)) > 0 )
|
||||
@@ -1216,7 +1181,7 @@ void komodo_passport_iteration()
|
||||
isrealtime = 1;
|
||||
RTmask |= (1LL << baseid);
|
||||
memcpy(refsp->RTbufs[baseid+1],buf,sizeof(refsp->RTbufs[baseid+1]));
|
||||
} else if ( 0 && (time(NULL)-buf[2]) > 1800 )
|
||||
} else if ( (time(NULL)-buf[2]) > 1800 )
|
||||
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);
|
||||
|
||||
@@ -73,8 +73,6 @@ 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!
|
||||
@@ -104,9 +102,7 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin
|
||||
if ( exception == 0 )
|
||||
{
|
||||
numerator = (nValue / 20); // assumes 5%!
|
||||
if ( txheight < 300000 )
|
||||
interest = (numerator / denominator);
|
||||
else interest = (numerator * minutes) / ((uint64_t)365 * 24 * 60);
|
||||
interest = (numerator / denominator);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -117,9 +113,7 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin
|
||||
else
|
||||
{
|
||||
numerator = (nValue * KOMODO_INTEREST);
|
||||
if ( txheight < 300000 || numerator * minutes < 365 * 24 * 60 )
|
||||
interest = (numerator / denominator) / COIN;
|
||||
else interest = ((numerator * minutes) / ((uint64_t)365 * 24 * 60)) / COIN;
|
||||
interest = (numerator / denominator) / 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);
|
||||
}
|
||||
|
||||
@@ -3293,7 +3293,7 @@ bool ContextualCheckBlock(const CBlock& block, CValidationState& state, CBlockIn
|
||||
CScript expect = CScript() << nHeight;
|
||||
if (block.vtx[0].vin[0].scriptSig.size() < expect.size() ||
|
||||
!std::equal(expect.begin(), expect.end(), block.vtx[0].vin[0].scriptSig.begin())) {
|
||||
return state.DoS(100, error("%s: block height mismatch in coinbase ht.%d", __func__,nHeight), REJECT_INVALID, "bad-cb-height");
|
||||
return state.DoS(100, error("%s: block height mismatch in coinbase", __func__), REJECT_INVALID, "bad-cb-height");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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,KOMODO_PASSPORT_INITDONE;
|
||||
extern int32_t ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_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_PASSPORT_INITDONE == 0 || KOMODO_INITDONE == 0 || (komodo_baseid(ASSETCHAINS_SYMBOL) >= 0 && (isrealtime= komodo_isrealtime(&kmdheight)) == 0) )
|
||||
if ( 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);
|
||||
}
|
||||
@@ -145,7 +145,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
|
||||
sleep(10);
|
||||
}
|
||||
KOMODO_ON_DEMAND = 0;
|
||||
if ( 1 && deposits != 0 )
|
||||
if ( 0 && deposits != 0 )
|
||||
printf("miner KOMODO_DEPOSIT %llu pblock->nHeight %d mempool.GetTotalTxSize(%d)\n",(long long)komodo_paxtotal(),(int32_t)chainActive.Tip()->nHeight,(int32_t)mempool.GetTotalTxSize());
|
||||
}
|
||||
// -regtest only: allow overriding block.nVersion with
|
||||
@@ -383,7 +383,6 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
|
||||
// Add fees
|
||||
txNew.vout[0].nValue += nFees;
|
||||
txNew.vin[0].scriptSig = CScript() << nHeight << OP_0;
|
||||
//fprintf(stderr,"set coinbase height to %d\n",nHeight);
|
||||
if ( ASSETCHAINS_SYMBOL[0] == 0 )
|
||||
{
|
||||
int32_t i,opretlen; uint8_t opret[256],*ptr;
|
||||
@@ -630,15 +629,6 @@ 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 ) // skips when it shouldnt
|
||||
{
|
||||
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));
|
||||
//
|
||||
@@ -695,6 +685,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
|
||||
{
|
||||
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;
|
||||
|
||||
@@ -170,7 +170,7 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in
|
||||
for (i=0; i<66; i++)
|
||||
printf("%d ",mids[i]);
|
||||
printf(" minerids from ht.%d\n",height);
|
||||
if ( notaryid >= 0 || height > 225065 )
|
||||
if ( notaryid >= 0 || height > 225000 )
|
||||
return error("CheckProofOfWork(): hash doesn't match nBits");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -496,8 +496,6 @@ uint256 komodo_kvsig(uint8_t *buf,int32_t len,uint256 privkey);
|
||||
int32_t komodo_kvduration(uint32_t flags);
|
||||
uint256 komodo_kvprivkey(uint256 *pubkeyp,char *passphrase);
|
||||
int32_t komodo_kvsigverify(uint8_t *buf,int32_t len,uint256 _pubkey,uint256 sig);
|
||||
uint64_t komodo_maxallowed(int32_t baseid);
|
||||
int32_t komodo_baseid(char *origbase);
|
||||
|
||||
Value kvupdate(const Array& params, bool fHelp)
|
||||
{
|
||||
@@ -629,23 +627,12 @@ Value paxdeposit(const Array& params, bool fHelp)
|
||||
CBitcoinAddress address(params[0].get_str());
|
||||
if (!address.IsValid())
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Bitcoin address");
|
||||
int32_t baseid,errflag = 0; int64_t netliability,minval,maxallowed,fiatoshis = atof(params[1].get_str().c_str()) * COIN;
|
||||
int64_t fiatoshis = atof(params[1].get_str().c_str()) * COIN;
|
||||
std::string base = params[2].get_str();
|
||||
std::string dest;
|
||||
height = chainActive.Tip()->nHeight;
|
||||
baseid = komodo_baseid((char *)base.c_str());
|
||||
if ( pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,(char *)base.c_str()) != 0 || available < fiatoshis )
|
||||
errflag = 1;
|
||||
minval = approved;
|
||||
if ( withdrawn < minval )
|
||||
minval = withdrawn;
|
||||
netliability = (deposited - minval);
|
||||
maxallowed = komodo_maxallowed(baseid);
|
||||
if ( fiatoshis > (maxallowed - netliability) )
|
||||
errflag = 1;
|
||||
if ( errflag != 0 )
|
||||
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);
|
||||
@@ -672,7 +659,6 @@ 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 )
|
||||
|
||||
Reference in New Issue
Block a user