We call them Hush Smart Chains around here
This commit is contained in:
@@ -117,10 +117,10 @@ void komodo_paxdelete(struct pax_transaction *pax)
|
||||
|
||||
void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t fiatoshis,uint8_t *rmd160,uint256 txid,uint16_t vout,uint8_t type,int32_t height,int32_t otherheight,char *source,int32_t approved) // assetchain context
|
||||
{
|
||||
struct pax_transaction *pax; uint8_t buf[35]; int32_t addflag = 0; struct komodo_state *sp; char str[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN],*s;
|
||||
struct pax_transaction *pax; uint8_t buf[35]; int32_t addflag = 0; struct komodo_state *sp; char str[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN],*s;
|
||||
//if ( KOMODO_PAX == 0 )
|
||||
// return;
|
||||
//if ( strcmp(symbol,ASSETCHAINS_SYMBOL) != 0 )
|
||||
//if ( strcmp(symbol,SMART_CHAIN_SYMBOL) != 0 )
|
||||
// return;
|
||||
sp = komodo_stateptr(str,dest);
|
||||
pthread_mutex_lock(&komodo_mutex);
|
||||
@@ -135,11 +135,11 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t
|
||||
memcpy(pax->buf,buf,sizeof(pax->buf));
|
||||
HASH_ADD_KEYPTR(hh,PAX,pax->buf,sizeof(pax->buf),pax);
|
||||
addflag = 1;
|
||||
if ( 0 && ASSETCHAINS_SYMBOL[0] == 0 )
|
||||
if ( 0 && SMART_CHAIN_SYMBOL[0] == 0 )
|
||||
{
|
||||
int32_t i; for (i=0; i<32; i++)
|
||||
printf("%02x",((uint8_t *)&txid)[i]);
|
||||
printf(" v.%d [%s] kht.%d ht.%d create pax.%p symbol.%s source.%s\n",vout,ASSETCHAINS_SYMBOL,height,otherheight,pax,symbol,source);
|
||||
printf(" v.%d [%s] kht.%d ht.%d create pax.%p symbol.%s source.%s\n",vout,SMART_CHAIN_SYMBOL,height,otherheight,pax,symbol,source);
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock(&komodo_mutex);
|
||||
@@ -209,7 +209,7 @@ int32_t komodo_rwapproval(int32_t rwflag,uint8_t *opretbuf,struct pax_transactio
|
||||
|
||||
int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t *values,int64_t *srcvalues,int32_t *kmdheights,int32_t *otherheights,int8_t *baseids,uint8_t *rmd160s,uint8_t *opretbuf,int32_t opretlen,int32_t iskomodo)
|
||||
{
|
||||
struct pax_transaction p,*pax; int32_t i,n=0,j,len=0,incr,height,otherheight; uint8_t type,rmd160[20]; uint64_t fiatoshis; char symbol[KOMODO_ASSETCHAIN_MAXLEN];
|
||||
struct pax_transaction p,*pax; int32_t i,n=0,j,len=0,incr,height,otherheight; uint8_t type,rmd160[20]; uint64_t fiatoshis; char symbol[HUSH_SMART_CHAIN_MAXLEN];
|
||||
//if ( KOMODO_PAX == 0 )
|
||||
// return(0);
|
||||
incr = 34 + (iskomodo * (2*sizeof(fiatoshis) + 2*sizeof(height) + 20 + 4));
|
||||
@@ -221,7 +221,7 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t
|
||||
// printf("%02x",opretbuf[i]);
|
||||
//printf(" opretlen.%d (%s)\n",opretlen,base);
|
||||
//printf(" opretlen.%d vs %d incr.%d (%d)\n",opretlen,(int32_t)(2*sizeof(fiatoshis) + 2*sizeof(height) + 20 + 2),incr,opretlen/incr);
|
||||
//if ( ASSETCHAINS_SYMBOL[0] == 0 || strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0 )
|
||||
//if ( SMART_CHAIN_SYMBOL[0] == 0 || strncmp(SMART_CHAIN_SYMBOL,base,strlen(base)) == 0 )
|
||||
{
|
||||
type = opretbuf[0];
|
||||
opretbuf++, opretlen--;
|
||||
@@ -286,7 +286,7 @@ int32_t komodo_paxcmp(char *symbol,int32_t kmdheight,uint64_t value,uint64_t che
|
||||
return(0);
|
||||
else
|
||||
{
|
||||
if ( ASSETCHAINS_SYMBOL[0] != 0 )
|
||||
if ( SMART_CHAIN_SYMBOL[0] != 0 )
|
||||
printf("ht.%d ignore mismatched %s value %lld vs checkvalue %lld -> ratio.%d\n",kmdheight,symbol,(long long)value,(long long)checkvalue,ratio);
|
||||
return(-1);
|
||||
}
|
||||
@@ -302,7 +302,7 @@ int32_t komodo_paxcmp(char *symbol,int32_t kmdheight,uint64_t value,uint64_t che
|
||||
|
||||
uint64_t komodo_paxtotal()
|
||||
{
|
||||
struct pax_transaction *pax,*pax2,*tmp,*tmp2; char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN],*str; int32_t i,ht; int64_t checktoshis; uint64_t seed,total = 0; struct komodo_state *basesp;
|
||||
struct pax_transaction *pax,*pax2,*tmp,*tmp2; char symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN],*str; int32_t i,ht; int64_t checktoshis; uint64_t seed,total = 0; struct komodo_state *basesp;
|
||||
if ( KOMODO_PASSPORT_INITDONE == 0 ) //KOMODO_PAX == 0 ||
|
||||
return(0);
|
||||
if ( komodo_isrealtime(&ht) == 0 )
|
||||
@@ -327,7 +327,7 @@ uint64_t komodo_paxtotal()
|
||||
pax->fiatoshis = pax2->fiatoshis;
|
||||
basesp->issued += pax->fiatoshis;
|
||||
pax->didstats = 1;
|
||||
if ( strcmp(str,ASSETCHAINS_SYMBOL) == 0 )
|
||||
if ( strcmp(str,SMART_CHAIN_SYMBOL) == 0 )
|
||||
printf("########### %p issued %s += %.8f kmdheight.%d %.8f other.%d\n",basesp,str,dstr(pax->fiatoshis),pax->height,dstr(pax->komodoshis),pax->otherheight);
|
||||
pax2->marked = pax->height;
|
||||
pax->marked = pax->height;
|
||||
@@ -348,7 +348,7 @@ uint64_t komodo_paxtotal()
|
||||
pax->validated = pax->komodoshis = checktoshis;
|
||||
//int32_t j; for (j=0; j<32; j++)
|
||||
// printf("%02x",((uint8_t *)&pax->txid)[j]);
|
||||
//if ( strcmp(str,ASSETCHAINS_SYMBOL) == 0 )
|
||||
//if ( strcmp(str,SMART_CHAIN_SYMBOL) == 0 )
|
||||
// printf(" v%d %p got WITHDRAW.%s kmd.%d ht.%d %.8f -> %.8f/%.8f\n",pax->vout,pax,pax->source,pax->height,pax->otherheight,dstr(pax->fiatoshis),dstr(pax->komodoshis),dstr(checktoshis));
|
||||
}
|
||||
}
|
||||
@@ -430,7 +430,7 @@ int32_t komodo_pending_withdraws(char *opretstr) // todo: enforce deterministic
|
||||
struct pax_transaction *pax,*pax2,*tmp,*paxes[64]; uint8_t opretbuf[16384*4]; int32_t i,n,ht,len=0; uint64_t total = 0;
|
||||
if ( KOMODO_PAX == 0 || KOMODO_PASSPORT_INITDONE == 0 )
|
||||
return(0);
|
||||
if ( komodo_isrealtime(&ht) == 0 || ASSETCHAINS_SYMBOL[0] != 0 )
|
||||
if ( komodo_isrealtime(&ht) == 0 || SMART_CHAIN_SYMBOL[0] != 0 )
|
||||
return(0);
|
||||
n = 0;
|
||||
HASH_ITER(hh,PAX,pax,tmp)
|
||||
@@ -476,13 +476,13 @@ 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[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; uint8_t *script,opcode,opret[16384*4],data[16384*4]; int32_t i,baseid,ht,len=0,opretlen=0,numvouts=1; struct komodo_state *sp; uint64_t available,deposited,issued,withdrawn,approved,redeemed,mask,sum = 0;
|
||||
struct pax_transaction *pax,*tmp; char symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN]; uint8_t *script,opcode,opret[16384*4],data[16384*4]; int32_t i,baseid,ht,len=0,opretlen=0,numvouts=1; struct komodo_state *sp; uint64_t available,deposited,issued,withdrawn,approved,redeemed,mask,sum = 0;
|
||||
if ( KOMODO_PASSPORT_INITDONE == 0 )//KOMODO_PAX == 0 ||
|
||||
return(0);
|
||||
struct komodo_state *kmdsp = komodo_stateptrget((char *)"KMD");
|
||||
sp = komodo_stateptr(symbol,dest);
|
||||
strcpy(symbol,base);
|
||||
if ( ASSETCHAINS_SYMBOL[0] != 0 && komodo_baseid(ASSETCHAINS_SYMBOL) < 0 )
|
||||
if ( SMART_CHAIN_SYMBOL[0] != 0 && komodo_baseid(SMART_CHAIN_SYMBOL) < 0 )
|
||||
return(0);
|
||||
PENDING_KOMODO_TX = 0;
|
||||
for (i=0; i<3; i++)
|
||||
@@ -494,7 +494,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to
|
||||
if ( i == 3 )
|
||||
{
|
||||
if ( tokomodo == 0 )
|
||||
printf("%s not realtime ht.%d\n",ASSETCHAINS_SYMBOL,ht);
|
||||
printf("%s not realtime ht.%d\n",SMART_CHAIN_SYMBOL,ht);
|
||||
return(0);
|
||||
}
|
||||
if ( tokomodo == 0 )
|
||||
@@ -512,7 +512,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to
|
||||
if ( pax->type != 'D' && pax->type != 'A' )
|
||||
continue;
|
||||
{
|
||||
#ifdef KOMODO_ASSETCHAINS_WAITNOTARIZE
|
||||
#ifdef HUSH_SMART_CHAINS_WAITNOTARIZE
|
||||
if ( pax->height > 236000 )
|
||||
{
|
||||
if ( kmdsp != 0 && kmdsp->NOTARIZED_HEIGHT >= pax->height )
|
||||
@@ -530,10 +530,10 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to
|
||||
pax->validated = pax->komodoshis;
|
||||
#endif
|
||||
}
|
||||
if ( ASSETCHAINS_SYMBOL[0] != 0 && (pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,symbol) != 0 || available < pax->fiatoshis) )
|
||||
if ( SMART_CHAIN_SYMBOL[0] != 0 && (pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,symbol) != 0 || available < pax->fiatoshis) )
|
||||
{
|
||||
//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));
|
||||
//if ( pax->height > 214700 || strcmp(SMART_CHAIN_SYMBOL,symbol) == 0 )
|
||||
// printf("miner.[%s]: skip %s %.8f when avail %.8f deposited %.8f, issued %.8f withdrawn %.8f approved %.8f redeemed %.8f\n",SMART_CHAIN_SYMBOL,symbol,dstr(pax->fiatoshis),dstr(available),dstr(deposited),dstr(issued),dstr(withdrawn),dstr(approved),dstr(redeemed));
|
||||
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);
|
||||
@@ -542,16 +542,16 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to
|
||||
printf("reject 2\n");
|
||||
continue;
|
||||
}*/
|
||||
if ( ASSETCHAINS_SYMBOL[0] != 0 && (strcmp(pax->symbol,symbol) != 0 || pax->validated == 0 || pax->ready == 0) )
|
||||
if ( SMART_CHAIN_SYMBOL[0] != 0 && (strcmp(pax->symbol,symbol) != 0 || pax->validated == 0 || pax->ready == 0) )
|
||||
{
|
||||
if ( strcmp(pax->symbol,ASSETCHAINS_SYMBOL) == 0 )
|
||||
if ( strcmp(pax->symbol,SMART_CHAIN_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->height;
|
||||
continue;
|
||||
}
|
||||
if ( pax->ready == 0 )
|
||||
continue;
|
||||
if ( pax->type == 'A' && ASSETCHAINS_SYMBOL[0] == 0 )
|
||||
if ( pax->type == 'A' && SMART_CHAIN_SYMBOL[0] == 0 )
|
||||
{
|
||||
if ( kmdsp != 0 )
|
||||
{
|
||||
@@ -564,8 +564,8 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to
|
||||
}
|
||||
|
||||
//printf("redeem.%d? (%c) %p pax.%s marked.%d %.8f -> %.8f ready.%d validated.%d approved.%d\n",tokomodo,pax->type,pax,pax->symbol,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis),pax->ready!=0,pax->validated!=0,pax->approved!=0);
|
||||
if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 )
|
||||
printf("pax.%s marked.%d %.8f -> %.8f\n",ASSETCHAINS_SYMBOL,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis));
|
||||
if ( 0 && SMART_CHAIN_SYMBOL[0] != 0 )
|
||||
printf("pax.%s marked.%d %.8f -> %.8f\n",SMART_CHAIN_SYMBOL,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis));
|
||||
if ( opcode == 'I' )
|
||||
{
|
||||
sum += pax->fiatoshis;
|
||||
@@ -617,7 +617,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to
|
||||
memcpy(script,opret,opretlen);
|
||||
for (i=0; i<8; i++)
|
||||
printf("%02x",opret[i]);
|
||||
printf(" <- opret, MINER deposits.%d (%s) vouts.%d %.8f opretlen.%d\n",tokomodo,ASSETCHAINS_SYMBOL,numvouts,dstr(PENDING_KOMODO_TX),opretlen);
|
||||
printf(" <- opret, MINER deposits.%d (%s) vouts.%d %.8f opretlen.%d\n",tokomodo,SMART_CHAIN_SYMBOL,numvouts,dstr(PENDING_KOMODO_TX),opretlen);
|
||||
return(1);
|
||||
}
|
||||
return(0);
|
||||
@@ -683,7 +683,7 @@ void komodo_passport_iteration();
|
||||
int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtime) // verify above block is valid pax pricing
|
||||
{
|
||||
static uint256 array[64]; static int32_t numbanned,indallvouts;
|
||||
int32_t i,j,k,n,ht,baseid,txn_count,activation,num,opretlen,offset=1,errs=0,notmatched=0,matched=0,kmdheights[256],otherheights[256]; uint256 hash,txids[256]; char symbol[KOMODO_ASSETCHAIN_MAXLEN],base[KOMODO_ASSETCHAIN_MAXLEN]; uint16_t vouts[256]; int8_t baseids[256]; uint8_t *script,opcode,rmd160s[256*20]; uint64_t total,subsidy,available,deposited,issued,withdrawn,approved,redeemed,seed; int64_t checktoshis,values[256],srcvalues[256]; struct pax_transaction *pax; struct komodo_state *sp; CTransaction tx;
|
||||
int32_t i,j,k,n,ht,baseid,txn_count,activation,num,opretlen,offset=1,errs=0,notmatched=0,matched=0,kmdheights[256],otherheights[256]; uint256 hash,txids[256]; char symbol[HUSH_SMART_CHAIN_MAXLEN],base[HUSH_SMART_CHAIN_MAXLEN]; uint16_t vouts[256]; int8_t baseids[256]; uint8_t *script,opcode,rmd160s[256*20]; uint64_t total,subsidy,available,deposited,issued,withdrawn,approved,redeemed,seed; int64_t checktoshis,values[256],srcvalues[256]; struct pax_transaction *pax; struct komodo_state *sp; CTransaction tx;
|
||||
activation = 235300;
|
||||
if ( *(int32_t *)&array[0] == 0 )
|
||||
numbanned = komodo_bannedset(&indallvouts,array,(int32_t)(sizeof(array)/sizeof(*array)));
|
||||
@@ -694,7 +694,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim
|
||||
memset(kmdheights,0,sizeof(kmdheights));
|
||||
memset(otherheights,0,sizeof(otherheights));
|
||||
txn_count = block.vtx.size();
|
||||
if ( ASSETCHAINS_SYMBOL[0] == 0 )
|
||||
if ( SMART_CHAIN_SYMBOL[0] == 0 )
|
||||
{
|
||||
for (i=0; i<txn_count; i++)
|
||||
{
|
||||
@@ -738,7 +738,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( ASSETCHAINS_SYMBOL[0] == 0 ||
|
||||
if ( SMART_CHAIN_SYMBOL[0] == 0 ||
|
||||
((ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_FOUNDERS_REWARD) && height > 1) ||
|
||||
NetworkUpgradeActive(height, Params().GetConsensus(), Consensus::UPGRADE_SAPLING) )
|
||||
{
|
||||
@@ -763,7 +763,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim
|
||||
}
|
||||
prevtotal = total;
|
||||
}
|
||||
if ( ASSETCHAINS_SYMBOL[0] == 0 )
|
||||
if ( SMART_CHAIN_SYMBOL[0] == 0 )
|
||||
{
|
||||
if ( overflow != 0 || total > COIN/10 )
|
||||
{
|
||||
@@ -819,7 +819,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim
|
||||
{
|
||||
fprintf(stderr,"checkdeposit: ht.%d checktoshis %.8f overflow.%d total %.8f strangeout.%d\n",height,dstr(checktoshis),overflow,dstr(total),strangeout);
|
||||
if ( strangeout != 0 )
|
||||
fprintf(stderr,">>>>>>>>>>>>> %s DUST ht.%d strangeout.%d notmatched.%d <<<<<<<<<\n",ASSETCHAINS_SYMBOL,height,strangeout,notmatched);
|
||||
fprintf(stderr,">>>>>>>>>>>>> %s DUST ht.%d strangeout.%d notmatched.%d <<<<<<<<<\n",SMART_CHAIN_SYMBOL,height,strangeout,notmatched);
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
@@ -831,9 +831,9 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
|
||||
{
|
||||
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' )
|
||||
if ( SMART_CHAIN_SYMBOL[0] != 0 && komodo_baseid(SMART_CHAIN_SYMBOL) < 0 && opretbuf[0] != 'K' )
|
||||
{
|
||||
//printf("komodo_opreturn skip %s\n",ASSETCHAINS_SYMBOL);
|
||||
//printf("komodo_opreturn skip %s\n",SMART_CHAIN_SYMBOL);
|
||||
return("assetchain");
|
||||
}
|
||||
memset(baseids,0xff,sizeof(baseids));
|
||||
@@ -848,7 +848,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
|
||||
komodo_kvupdate(opretbuf,opretlen,value);
|
||||
return("kv");
|
||||
}
|
||||
else if ( ASSETCHAINS_SYMBOL[0] == 0 && KOMODO_PAX == 0 )
|
||||
else if ( SMART_CHAIN_SYMBOL[0] == 0 && KOMODO_PAX == 0 )
|
||||
return("nopax");
|
||||
if ( opretbuf[0] == 'D' )
|
||||
{
|
||||
@@ -865,8 +865,8 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
|
||||
typestr = "deposit";
|
||||
if ( 0 && strcmp("NOK",base) == 0 )
|
||||
{
|
||||
printf("[%s] %s paxdeposit height.%d vs kmdheight.%d\n",ASSETCHAINS_SYMBOL,base,height,kmdheight);
|
||||
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);
|
||||
printf("[%s] %s paxdeposit height.%d vs kmdheight.%d\n",SMART_CHAIN_SYMBOL,base,height,kmdheight);
|
||||
printf("(%s) (%s) kmdheight.%d vs height.%d check %.8f vs %.8f tokomodo.%d %d seed.%llx\n",SMART_CHAIN_SYMBOL,base,kmdheight,height,dstr(checktoshis),dstr(value),komodo_is_issuer(),strncmp(SMART_CHAIN_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);
|
||||
@@ -874,7 +874,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
|
||||
printf("%02x",pubkey33[i]);
|
||||
printf(" checkpubkey check %.8f v %.8f dest.(%s) kmdheight.%d height.%d\n",dstr(checktoshis),dstr(value),destaddr,kmdheight,height);
|
||||
}
|
||||
if ( strcmp(base,ASSETCHAINS_SYMBOL) == 0 && (kmdheight > 195000 || kmdheight <= height) )
|
||||
if ( strcmp(base,SMART_CHAIN_SYMBOL) == 0 && (kmdheight > 195000 || kmdheight <= height) )
|
||||
{
|
||||
didstats = 0;
|
||||
if ( komodo_paxcmp(base,kmdheight,value,checktoshis,kmdheight < 225000 ? seed : 0) == 0 )
|
||||
@@ -885,7 +885,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
|
||||
{
|
||||
basesp->deposited += fiatoshis;
|
||||
didstats = 1;
|
||||
if ( 0 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 )
|
||||
if ( 0 && strcmp(base,SMART_CHAIN_SYMBOL) == 0 )
|
||||
printf("########### %p deposited %s += %.8f kmdheight.%d %.8f\n",basesp,base,dstr(fiatoshis),kmdheight,dstr(value));
|
||||
} else printf("cant get stateptr.(%s)\n",base);
|
||||
komodo_gateway_deposit(coinaddr,value,base,fiatoshis,rmd160,txid,vout,'D',kmdheight,height,(char *)"KMD",0);
|
||||
@@ -902,7 +902,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
|
||||
{
|
||||
basesp->deposited += fiatoshis;
|
||||
didstats = 1;
|
||||
if ( 0 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 )
|
||||
if ( 0 && strcmp(base,SMART_CHAIN_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));
|
||||
}
|
||||
} //
|
||||
@@ -931,16 +931,16 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
|
||||
{
|
||||
if ( (pax= komodo_paxfind(txid,vout,'D')) != 0 )
|
||||
pax->marked = checktoshis;
|
||||
if ( kmdheight > 238000 && (kmdheight > 214700 || strcmp(base,ASSETCHAINS_SYMBOL) == 0) ) //seed != 0 &&
|
||||
if ( kmdheight > 238000 && (kmdheight > 214700 || strcmp(base,SMART_CHAIN_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("[%s] %s paxdeposit height.%d vs kmdheight.%d\n",ASSETCHAINS_SYMBOL,base,height,kmdheight);
|
||||
} //else printf("[%s] %s paxdeposit height.%d vs kmdheight.%d\n",SMART_CHAIN_SYMBOL,base,height,kmdheight);
|
||||
} //else printf("unsupported size.%d for opreturn D\n",opretlen);
|
||||
}
|
||||
else if ( opretbuf[0] == 'I' )
|
||||
{
|
||||
tokomodo = 0;
|
||||
if ( strncmp((char *)"KMD",(char *)&opretbuf[opretlen-4],3) != 0 && strncmp(ASSETCHAINS_SYMBOL,(char *)&opretbuf[opretlen-4],3) == 0 )
|
||||
if ( strncmp((char *)"KMD",(char *)&opretbuf[opretlen-4],3) != 0 && strncmp(SMART_CHAIN_SYMBOL,(char *)&opretbuf[opretlen-4],3) == 0 )
|
||||
{
|
||||
if ( (n= komodo_issued_opreturn(base,txids,vouts,values,srcvalues,kmdheights,otherheights,baseids,rmd160s,opretbuf,opretlen,0)) > 0 )
|
||||
{
|
||||
@@ -954,7 +954,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
|
||||
continue;
|
||||
}
|
||||
bitcoin_address(coinaddr,60,&rmd160s[i*20],20);
|
||||
komodo_gateway_deposit(coinaddr,0,ASSETCHAINS_SYMBOL,0,0,txids[i],vouts[i],'I',height,0,CURRENCIES[baseids[i]],0);
|
||||
komodo_gateway_deposit(coinaddr,0,SMART_CHAIN_SYMBOL,0,0,txids[i],vouts[i],'I',height,0,CURRENCIES[baseids[i]],0);
|
||||
komodo_paxmark(height,txids[i],vouts[i],'I',height);
|
||||
if ( (pax= komodo_paxfind(txids[i],vouts[i],'I')) != 0 )
|
||||
{
|
||||
@@ -988,13 +988,13 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
|
||||
} //else printf("opreturn none issued?\n");
|
||||
}
|
||||
}
|
||||
else if ( height < 236000 && opretbuf[0] == 'W' && strncmp(ASSETCHAINS_SYMBOL,(char *)&opretbuf[opretlen-4],3) == 0 )//&& opretlen >= 38 )
|
||||
else if ( height < 236000 && opretbuf[0] == 'W' && strncmp(SMART_CHAIN_SYMBOL,(char *)&opretbuf[opretlen-4],3) == 0 )//&& opretlen >= 38 )
|
||||
{
|
||||
if ( komodo_baseid((char *)&opretbuf[opretlen-4]) >= 0 && strcmp(ASSETCHAINS_SYMBOL,(char *)&opretbuf[opretlen-4]) == 0 )
|
||||
if ( komodo_baseid((char *)&opretbuf[opretlen-4]) >= 0 && strcmp(SMART_CHAIN_SYMBOL,(char *)&opretbuf[opretlen-4]) == 0 )
|
||||
{
|
||||
for (i=0; i<opretlen; i++)
|
||||
printf("%02x",opretbuf[i]);
|
||||
printf(" [%s] reject obsolete withdraw request.%s\n",ASSETCHAINS_SYMBOL,(char *)&opretbuf[opretlen-4]);
|
||||
printf(" [%s] reject obsolete withdraw request.%s\n",SMART_CHAIN_SYMBOL,(char *)&opretbuf[opretlen-4]);
|
||||
return(typestr);
|
||||
}
|
||||
tokomodo = 1;
|
||||
@@ -1004,7 +1004,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
|
||||
bitcoin_address(coinaddr,addrtype,rmd160,20);
|
||||
checktoshis = PAX_fiatdest(&seed,tokomodo,destaddr,pubkey33,coinaddr,kmdheight,base,value);
|
||||
typestr = "withdraw";
|
||||
//printf(" [%s] WITHDRAW %s.height.%d vs height.%d check %.8f/%.8f vs %.8f tokomodo.%d %d seed.%llx -> (%s) len.%d\n",ASSETCHAINS_SYMBOL,base,kmdheight,height,dstr(checktoshis),dstr(komodoshis),dstr(value),komodo_is_issuer(),strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0,(long long)seed,coinaddr,opretlen);
|
||||
//printf(" [%s] WITHDRAW %s.height.%d vs height.%d check %.8f/%.8f vs %.8f tokomodo.%d %d seed.%llx -> (%s) len.%d\n",SMART_CHAIN_SYMBOL,base,kmdheight,height,dstr(checktoshis),dstr(komodoshis),dstr(value),komodo_is_issuer(),strncmp(SMART_CHAIN_SYMBOL,base,strlen(base)) == 0,(long long)seed,coinaddr,opretlen);
|
||||
didstats = 0;
|
||||
//if ( komodo_paxcmp(base,kmdheight,komodoshis,checktoshis,seed) == 0 )
|
||||
{
|
||||
@@ -1014,11 +1014,11 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
|
||||
{
|
||||
basesp->withdrawn += value;
|
||||
didstats = 1;
|
||||
if ( 0 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 )
|
||||
if ( 0 && strcmp(base,SMART_CHAIN_SYMBOL) == 0 )
|
||||
printf("########### %p withdrawn %s += %.8f check %.8f\n",basesp,base,dstr(value),dstr(checktoshis));
|
||||
}
|
||||
if ( 0 && strcmp(base,"RUB") == 0 && (pax == 0 || pax->approved == 0) )
|
||||
printf("notarize %s %.8f -> %.8f kmd.%d other.%d\n",ASSETCHAINS_SYMBOL,dstr(value),dstr(komodoshis),kmdheight,height);
|
||||
printf("notarize %s %.8f -> %.8f kmd.%d other.%d\n",SMART_CHAIN_SYMBOL,dstr(value),dstr(komodoshis),kmdheight,height);
|
||||
}
|
||||
komodo_gateway_deposit(coinaddr,0,(char *)"KMD",value,rmd160,txid,vout,'W',kmdheight,height,source,0);
|
||||
if ( (pax= komodo_paxfind(txid,vout,'W')) != 0 )
|
||||
@@ -1033,10 +1033,10 @@ 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 ( height < 236000 && tokomodo != 0 && opretbuf[0] == 'A' && ASSETCHAINS_SYMBOL[0] == 0 )
|
||||
else if ( height < 236000 && tokomodo != 0 && opretbuf[0] == 'A' && SMART_CHAIN_SYMBOL[0] == 0 )
|
||||
{
|
||||
tokomodo = 1;
|
||||
if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 )
|
||||
if ( 0 && SMART_CHAIN_SYMBOL[0] != 0 )
|
||||
{
|
||||
for (i=0; i<opretlen; i++)
|
||||
printf("%02x",opretbuf[i]);
|
||||
@@ -1104,7 +1104,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
|
||||
pax->validated = checktoshis;
|
||||
if ( didstats != 0 )
|
||||
pax->didstats = 1;
|
||||
//if ( strcmp(CURRENCIES[baseids[i]],ASSETCHAINS_SYMBOL) == 0 )
|
||||
//if ( strcmp(CURRENCIES[baseids[i]],SMART_CHAIN_SYMBOL) == 0 )
|
||||
//printf(" i.%d approved.%d <<<<<<<<<<<<< APPROVED %p\n",i,kmdheights[i],pax);
|
||||
}
|
||||
}
|
||||
@@ -1112,7 +1112,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 ( height < 236000 && opretbuf[0] == 'X' && ASSETCHAINS_SYMBOL[0] == 0 )
|
||||
else if ( height < 236000 && opretbuf[0] == 'X' && SMART_CHAIN_SYMBOL[0] == 0 )
|
||||
{
|
||||
tokomodo = 1;
|
||||
if ( (n= komodo_issued_opreturn(base,txids,vouts,values,srcvalues,kmdheights,otherheights,baseids,rmd160s,opretbuf,opretlen,1)) > 0 )
|
||||
@@ -1136,7 +1136,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
|
||||
{
|
||||
basesp->redeemed += value;
|
||||
pax->didstats = 1;
|
||||
if ( strcmp(CURRENCIES[baseids[i]],ASSETCHAINS_SYMBOL) == 0 )
|
||||
if ( strcmp(CURRENCIES[baseids[i]],SMART_CHAIN_SYMBOL) == 0 )
|
||||
printf("ht.%d %.8f ########### %p redeemed %s += %.8f %.8f kht.%d ht.%d\n",height,dstr(value),basesp,CURRENCIES[baseids[i]],dstr(value),dstr(srcvalues[i]),kmdheights[i],otherheights[i]);
|
||||
}
|
||||
}
|
||||
@@ -1427,28 +1427,28 @@ void komodo_passport_iteration()
|
||||
{
|
||||
static long lastpos[34]; static char userpass[33][1024]; static uint32_t lasttime,callcounter,lastinterest;
|
||||
int32_t maxseconds = 10;
|
||||
FILE *fp; uint8_t *filedata; long fpos,datalen,lastfpos; int32_t baseid,limit,n,ht,isrealtime,expired,refid,blocks,longest; struct komodo_state *sp,*refsp; char *retstr,fname[512],*base,symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; uint32_t buf[3],starttime; uint64_t RTmask = 0; //CBlockIndex *pindex;
|
||||
FILE *fp; uint8_t *filedata; long fpos,datalen,lastfpos; int32_t baseid,limit,n,ht,isrealtime,expired,refid,blocks,longest; struct komodo_state *sp,*refsp; char *retstr,fname[512],*base,symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN]; uint32_t buf[3],starttime; uint64_t RTmask = 0; //CBlockIndex *pindex;
|
||||
expired = 0;
|
||||
while ( 0 && HUSH_INITDONE == 0 )
|
||||
{
|
||||
fprintf(stderr,"[%s] PASSPORT iteration waiting for HUSH_INITDONE\n",ASSETCHAINS_SYMBOL);
|
||||
fprintf(stderr,"[%s] PASSPORT iteration waiting for HUSH_INITDONE\n",SMART_CHAIN_SYMBOL);
|
||||
sleep(3);
|
||||
}
|
||||
if ( komodo_chainactive_timestamp() > lastinterest )
|
||||
{
|
||||
if ( ASSETCHAINS_SYMBOL[0] == 0 )
|
||||
if ( SMART_CHAIN_SYMBOL[0] == 0 )
|
||||
komodo_interestsum();
|
||||
//komodo_longestchain();
|
||||
lastinterest = komodo_chainactive_timestamp();
|
||||
}
|
||||
refsp = komodo_stateptr(symbol,dest);
|
||||
if ( ASSETCHAINS_SYMBOL[0] == 0 || strcmp(ASSETCHAINS_SYMBOL,"JUSTLIES") == 0 )
|
||||
if ( SMART_CHAIN_SYMBOL[0] == 0 || strcmp(SMART_CHAIN_SYMBOL,"JUSTLIES") == 0 )
|
||||
{
|
||||
refid = 33;
|
||||
limit = 10000000;
|
||||
} else {
|
||||
limit = 10000000;
|
||||
refid = komodo_baseid(ASSETCHAINS_SYMBOL)+1; // illegal base -> baseid.-1 -> 0
|
||||
refid = komodo_baseid(SMART_CHAIN_SYMBOL)+1; // illegal base -> baseid.-1 -> 0
|
||||
if ( refid == 0 )
|
||||
{
|
||||
KOMODO_PASSPORT_INITDONE = 1;
|
||||
@@ -1466,7 +1466,7 @@ void komodo_passport_iteration()
|
||||
sp = 0;
|
||||
isrealtime = 0;
|
||||
base = (char *)CURRENCIES[baseid];
|
||||
//printf("PASSPORT %s baseid+1 %d refid.%d\n",ASSETCHAINS_SYMBOL,baseid+1,refid);
|
||||
//printf("PASSPORT %s baseid+1 %d refid.%d\n",SMART_CHAIN_SYMBOL,baseid+1,refid);
|
||||
if ( baseid+1 != refid ) // only need to import state from a different coin
|
||||
{
|
||||
if ( baseid == 32 ) // only care about KMD's state
|
||||
@@ -1479,10 +1479,10 @@ void komodo_passport_iteration()
|
||||
if ( lastpos[baseid] == 0 && (filedata= OS_fileptr(&datalen,fname)) != 0 )
|
||||
{
|
||||
fpos = 0;
|
||||
fprintf(stderr,"%s processing %s %ldKB\n",ASSETCHAINS_SYMBOL,fname,datalen/1024);
|
||||
fprintf(stderr,"%s processing %s %ldKB\n",SMART_CHAIN_SYMBOL,fname,datalen/1024);
|
||||
while ( komodo_parsestatefiledata(sp,filedata,&fpos,datalen,symbol,dest) >= 0 )
|
||||
lastfpos = fpos;
|
||||
fprintf(stderr,"%s took %d seconds to process %s %ldKB\n",ASSETCHAINS_SYMBOL,(int32_t)(time(NULL)-starttime),fname,datalen/1024);
|
||||
fprintf(stderr,"%s took %d seconds to process %s %ldKB\n",SMART_CHAIN_SYMBOL,(int32_t)(time(NULL)-starttime),fname,datalen/1024);
|
||||
lastpos[baseid] = lastfpos;
|
||||
free(filedata), filedata = 0;
|
||||
datalen = 0;
|
||||
@@ -1493,8 +1493,8 @@ void komodo_passport_iteration()
|
||||
//fprintf(stderr,"couldnt OS_fileptr(%s), freading %ldKB\n",fname,ftell(fp)/1024);
|
||||
if ( ftell(fp) > lastpos[baseid] )
|
||||
{
|
||||
if ( ASSETCHAINS_SYMBOL[0] != 0 )
|
||||
printf("%s passport refid.%d %s fname.(%s) base.%s %ld %ld\n",ASSETCHAINS_SYMBOL,refid,symbol,fname,base,ftell(fp),lastpos[baseid]);
|
||||
if ( SMART_CHAIN_SYMBOL[0] != 0 )
|
||||
printf("%s passport refid.%d %s fname.(%s) base.%s %ld %ld\n",SMART_CHAIN_SYMBOL,refid,symbol,fname,base,ftell(fp),lastpos[baseid]);
|
||||
fseek(fp,lastpos[baseid],SEEK_SET);
|
||||
while ( komodo_parsestatefile(sp,fp,symbol,dest) >= 0 && n < limit )
|
||||
{
|
||||
@@ -1504,7 +1504,7 @@ void komodo_passport_iteration()
|
||||
n = 0;
|
||||
else
|
||||
{
|
||||
//printf("expire passport loop %s -> %s at %ld\n",ASSETCHAINS_SYMBOL,base,lastpos[baseid]);
|
||||
//printf("expire passport loop %s -> %s at %ld\n",SMART_CHAIN_SYMBOL,base,lastpos[baseid]);
|
||||
expired++;
|
||||
}
|
||||
}
|
||||
@@ -1512,7 +1512,7 @@ void komodo_passport_iteration()
|
||||
}
|
||||
lastpos[baseid] = ftell(fp);
|
||||
if ( 0 && lastpos[baseid] == 0 && strcmp(symbol,"KMD") == 0 )
|
||||
printf("from.(%s) lastpos[%s] %ld isrt.%d\n",ASSETCHAINS_SYMBOL,CURRENCIES[baseid],lastpos[baseid],komodo_isrealtime(&ht));
|
||||
printf("from.(%s) lastpos[%s] %ld isrt.%d\n",SMART_CHAIN_SYMBOL,CURRENCIES[baseid],lastpos[baseid],komodo_isrealtime(&ht));
|
||||
} //else fprintf(stderr,"%s.%ld ",CURRENCIES[baseid],ftell(fp));
|
||||
fclose(fp);
|
||||
} else fprintf(stderr,"load error.(%s) %p\n",fname,sp);
|
||||
@@ -1528,8 +1528,8 @@ void komodo_passport_iteration()
|
||||
RTmask |= (1LL << baseid);
|
||||
memcpy(refsp->RTbufs[baseid+1],buf,sizeof(refsp->RTbufs[baseid+1]));
|
||||
}
|
||||
else if ( KOMODO_PAX != 0 && (time(NULL)-buf[2]) > 60 && 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 if ( KOMODO_PAX != 0 && (time(NULL)-buf[2]) > 60 && SMART_CHAIN_SYMBOL[0] != 0 )
|
||||
fprintf(stderr,"[%s]: %s not RT %u %u %d\n",SMART_CHAIN_SYMBOL,base,buf[0],buf[1],(int32_t)(time(NULL)-buf[2]));
|
||||
} //else fprintf(stderr,"%s size error RT\n",base);
|
||||
fclose(fp);
|
||||
} //else fprintf(stderr,"%s open error RT\n",base);
|
||||
@@ -1552,7 +1552,7 @@ void komodo_passport_iteration()
|
||||
memcpy(refsp->RTbufs[0],buf,sizeof(refsp->RTbufs[0]));
|
||||
}
|
||||
if ( fwrite(buf,1,sizeof(buf),fp) != sizeof(buf) )
|
||||
fprintf(stderr,"[%s] %s error writing realtime\n",ASSETCHAINS_SYMBOL,base);
|
||||
fprintf(stderr,"[%s] %s error writing realtime\n",SMART_CHAIN_SYMBOL,base);
|
||||
fclose(fp);
|
||||
} else fprintf(stderr,"%s create error RT\n",base);
|
||||
}
|
||||
@@ -1564,7 +1564,7 @@ void komodo_passport_iteration()
|
||||
if ( expired == 0 && KOMODO_PASSPORT_INITDONE == 0 )
|
||||
{
|
||||
KOMODO_PASSPORT_INITDONE = 1;
|
||||
printf("READY for %s RPC calls at %u! done PASSPORT %s refid.%d\n",ASSETCHAINS_SYMBOL,(uint32_t)time(NULL),ASSETCHAINS_SYMBOL,refid);
|
||||
printf("READY for %s RPC calls at %u! done PASSPORT %s refid.%d\n",SMART_CHAIN_SYMBOL,(uint32_t)time(NULL),SMART_CHAIN_SYMBOL,refid);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user