test
This commit is contained in:
@@ -108,7 +108,7 @@ 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 ( ASSETCHAINS_SYMBOL[0] == 0 )
|
||||
if ( 0 && ASSETCHAINS_SYMBOL[0] == 0 )
|
||||
{
|
||||
int32_t i; for (i=0; i<32; i++)
|
||||
printf("%02x",((uint8_t *)&txid)[i]);
|
||||
@@ -135,7 +135,7 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t
|
||||
pax->otherheight = otherheight;
|
||||
if ( pax->marked == 0 )
|
||||
{
|
||||
if ( addflag != 0 )
|
||||
if ( 0 && addflag != 0 )
|
||||
{
|
||||
if ( (pax->approved= approved) != 0 )
|
||||
s = (char *)"APPROVED";
|
||||
@@ -148,7 +148,7 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t
|
||||
else
|
||||
{
|
||||
pax->marked = height;
|
||||
printf("pax.%p MARK DEPOSIT ht.%d other.%d\n",pax,height,otherheight);
|
||||
//printf("pax.%p MARK DEPOSIT ht.%d other.%d\n",pax,height,otherheight);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,11 +166,11 @@ int32_t komodo_rwapproval(int32_t rwflag,uint8_t *opretbuf,struct pax_transactio
|
||||
{
|
||||
for (i=0; i<32; i++)
|
||||
((uint8_t *)&pax->txid)[i] = opretbuf[len++];
|
||||
for (i=0; i<32; i++)
|
||||
printf("%02x",((uint8_t *)&pax->txid)[31-i]);
|
||||
//for (i=0; i<32; i++)
|
||||
// printf("%02x",((uint8_t *)&pax->txid)[31-i]);
|
||||
pax->vout = opretbuf[len++];
|
||||
pax->vout += ((uint32_t)opretbuf[len++] << 8);
|
||||
printf(" txid v.%d\n",pax->vout);
|
||||
//printf(" txid v.%d\n",pax->vout);
|
||||
}
|
||||
len += iguana_rwnum(rwflag,&opretbuf[len],sizeof(pax->komodoshis),&pax->komodoshis);
|
||||
len += iguana_rwnum(rwflag,&opretbuf[len],sizeof(pax->fiatoshis),&pax->fiatoshis);
|
||||
@@ -221,6 +221,7 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t
|
||||
otherheights[n] = p.otherheight;
|
||||
memcpy(&rmd160s[n * 20],p.rmd160,20);
|
||||
baseids[n] = komodo_baseid(p.source);
|
||||
if ( 0 )
|
||||
{
|
||||
char coinaddr[64];
|
||||
bitcoin_address(coinaddr,60,&rmd160s[n * 20],20);
|
||||
@@ -276,7 +277,7 @@ uint64_t komodo_paxtotal()
|
||||
pax->fiatoshis = pax2->fiatoshis;
|
||||
basesp->issued += pax->fiatoshis;
|
||||
pax->didstats = 1;
|
||||
printf("Iset %s dstats %.8f += %.8f\n",str,dstr(basesp->issued),dstr(pax->fiatoshis));
|
||||
//printf("Iset %s dstats %.8f += %.8f\n",str,dstr(basesp->issued),dstr(pax->fiatoshis));
|
||||
pax2->marked = pax->height;
|
||||
}
|
||||
}
|
||||
@@ -340,13 +341,13 @@ int32_t komodo_pending_withdraws(char *opretstr)
|
||||
if ( len == 0 )
|
||||
opretbuf[len++] = 'A';
|
||||
len += komodo_rwapproval(1,&opretbuf[len],pax);
|
||||
printf("%s.(marked.%u approved.%d) %p\n",pax->source,pax->marked,pax->approved,pax);
|
||||
//printf("%s.(marked.%u approved.%d) %p\n",pax->source,pax->marked,pax->approved,pax);
|
||||
}
|
||||
}
|
||||
if ( len > 0 )
|
||||
init_hexbytes_noT(opretstr,opretbuf,len);
|
||||
else opretstr[0] = 0;
|
||||
printf("komodo_pending_withdraws len.%d PAXTOTAL %.8f\n",len,dstr(komodo_paxtotal()));
|
||||
fprintf(stderr,"komodo_pending_withdraws len.%d PAXTOTAL %.8f\n",len,dstr(komodo_paxtotal()));
|
||||
return(len);
|
||||
}
|
||||
|
||||
@@ -406,7 +407,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to
|
||||
{
|
||||
len += komodo_rwapproval(1,&data[len],pax);
|
||||
PENDING_KOMODO_TX += pax->komodoshis;
|
||||
printf(" vout.%u DEPOSIT %.8f <- pax.%s pending %.8f | ",pax->vout,(double)txNew->vout[numvouts].nValue/COIN,symbol,dstr(PENDING_KOMODO_TX));
|
||||
//printf(" vout.%u DEPOSIT %.8f <- pax.%s pending %.8f | ",pax->vout,(double)txNew->vout[numvouts].nValue/COIN,symbol,dstr(PENDING_KOMODO_TX));
|
||||
}
|
||||
if ( numvouts++ >= 64 )
|
||||
break;
|
||||
@@ -548,15 +549,15 @@ 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,fiatoshis);
|
||||
typestr = "deposit";
|
||||
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) 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);
|
||||
if ( kmdheight <= height )
|
||||
{
|
||||
for (i=0; i<32; i++)
|
||||
/*for (i=0; i<32; i++)
|
||||
printf("%02x",((uint8_t *)&txid)[i]);
|
||||
printf(" <- txid.v%u ",vout);
|
||||
for (i=0; i<33; i++)
|
||||
printf("%02x",pubkey33[i]);
|
||||
printf(" checkpubkey check %.8f v %.8f dest.(%s) kmdheight.%d height.%d\n",dstr(checktoshis),dstr(value),destaddr,kmdheight,height);
|
||||
printf(" checkpubkey check %.8f v %.8f dest.(%s) kmdheight.%d height.%d\n",dstr(checktoshis),dstr(value),destaddr,kmdheight,height);*/
|
||||
didstats = 0;
|
||||
if ( komodo_paxcmp(value,checktoshis,seed) == 0 )
|
||||
{
|
||||
@@ -566,7 +567,8 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
|
||||
{
|
||||
basesp->deposited += fiatoshis;
|
||||
didstats = 1;
|
||||
printf("########### %p deposited %s += %.8f\n",basesp,base,dstr(fiatoshis));
|
||||
if ( strcmp(base,ASSETCHAINS_SYMBOL) == 0 )
|
||||
printf("########### %p deposited %s += %.8f\n",basesp,base,dstr(fiatoshis));
|
||||
}
|
||||
komodo_gateway_deposit(coinaddr,value,base,fiatoshis,rmd160,txid,vout,'D',kmdheight,height,(char *)"KMD",0);
|
||||
}
|
||||
@@ -578,7 +580,8 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
|
||||
{
|
||||
basesp->deposited += fiatoshis;
|
||||
didstats = 1;
|
||||
printf("########### %p deposited %s += %.8f\n",basesp,base,dstr(fiatoshis));
|
||||
if ( strcmp(base,ASSETCHAINS_SYMBOL) == 0 )
|
||||
printf("########### %p deposited %s += %.8f\n",basesp,base,dstr(fiatoshis));
|
||||
}
|
||||
}
|
||||
if ( didstats != 0 )
|
||||
@@ -596,7 +599,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.height.%d vs height.%d check %.8f/%.8f vs %.8f tokomodo.%d %d seed.%llx -> (%s)\n",ASSETCHAINS_SYMBOL,kmdheight,height,dstr(checktoshis),dstr(komodoshis),dstr(value),komodo_is_issuer(),strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0,(long long)seed,coinaddr);
|
||||
//printf("%s.height.%d vs height.%d check %.8f/%.8f vs %.8f tokomodo.%d %d seed.%llx -> (%s)\n",ASSETCHAINS_SYMBOL,kmdheight,height,dstr(checktoshis),dstr(komodoshis),dstr(value),komodo_is_issuer(),strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0,(long long)seed,coinaddr);
|
||||
didstats = 0;
|
||||
if ( komodo_paxcmp(komodoshis,checktoshis,seed) == 0 )
|
||||
{
|
||||
@@ -606,9 +609,10 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
|
||||
{
|
||||
basesp->withdrawn += value;
|
||||
didstats = 1;
|
||||
printf("########### %p withdrawn %s += %.8f\n",basesp,base,dstr(value));
|
||||
if ( strcmp(base,ASSETCHAINS_SYMBOL) == 0 )
|
||||
printf("########### %p withdrawn %s += %.8f\n",basesp,base,dstr(value));
|
||||
}
|
||||
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",ASSETCHAINS_SYMBOL,dstr(value),dstr(komodoshis),kmdheight,height);
|
||||
}
|
||||
komodo_gateway_deposit(coinaddr,komodoshis,(char *)"KMD",value,rmd160,txid,vout,'W',kmdheight,height,source,0);
|
||||
if ( (pax= komodo_paxfind(txid,vout,'W')) != 0 )
|
||||
@@ -621,7 +625,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
|
||||
}
|
||||
else if ( tokomodo != 0 && opretbuf[0] == 'A' )
|
||||
{
|
||||
if ( ASSETCHAINS_SYMBOL[0] != 0 )
|
||||
if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 )
|
||||
{
|
||||
for (i=0; i<opretlen; i++)
|
||||
printf("%02x",opretbuf[i]);
|
||||
@@ -636,10 +640,10 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
|
||||
didstats = 0;
|
||||
seed = 0;
|
||||
checktoshis = komodo_paxprice(&seed,kmdheights[i],CURRENCIES[baseids[i]],(char *)"KMD",(uint64_t)srcvalues[i]);
|
||||
printf("PAX_fiatdest ht.%d price %s %.8f -> KMD %.8f vs %.8f\n",kmdheights[i],CURRENCIES[baseids[i]],(double)srcvalues[i]/COIN,(double)values[i]/COIN,(double)checktoshis/COIN);
|
||||
/*printf("PAX_fiatdest ht.%d price %s %.8f -> KMD %.8f vs %.8f\n",kmdheights[i],CURRENCIES[baseids[i]],(double)srcvalues[i]/COIN,(double)values[i]/COIN,(double)checktoshis/COIN);
|
||||
for (j=0; j<32; j++)
|
||||
printf("%02x",((uint8_t *)&txids[i])[j]);
|
||||
printf(" v%d %.8f k.%d ht.%d base.%d\n",vouts[i],dstr(values[i]),kmdheights[i],otherheights[i],baseids[i]);
|
||||
printf(" v%d %.8f k.%d ht.%d base.%d\n",vouts[i],dstr(values[i]),kmdheights[i],otherheights[i],baseids[i]);*/
|
||||
if ( (pax= komodo_paxfind(txids[i],vouts[i],'A')) == 0 )
|
||||
{
|
||||
bitcoin_address(coinaddr,60,&rmd160s[i*20],20);
|
||||
@@ -650,9 +654,10 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
|
||||
{
|
||||
basesp->approved += srcvalues[i];
|
||||
didstats = 1;
|
||||
printf("########### %p approved %s += %.8f\n",basesp,CURRENCIES[baseids[i]],dstr(srcvalues[i]));
|
||||
if ( strcmp(CURRENCIES[baseids[i]],ASSETCHAINS_SYMBOL) == 0 )
|
||||
printf("########### %p approved %s += %.8f\n",basesp,CURRENCIES[baseids[i]],dstr(srcvalues[i]));
|
||||
}
|
||||
printf(" i.%d (%s) <- %.8f ADDFLAG APPROVED\n",i,coinaddr,dstr(values[i]));
|
||||
//printf(" i.%d (%s) <- %.8f ADDFLAG APPROVED\n",i,coinaddr,dstr(values[i]));
|
||||
}
|
||||
else if ( pax->didstats == 0 && srcvalues[i] != 0 )
|
||||
{
|
||||
@@ -660,21 +665,22 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
|
||||
{
|
||||
basesp->approved += srcvalues[i];
|
||||
didstats = 1;
|
||||
printf("########### %p approved %s += %.8f\n",basesp,CURRENCIES[baseids[i]],dstr(srcvalues[i]));
|
||||
if ( strcmp(CURRENCIES[baseids[i]],ASSETCHAINS_SYMBOL) == 0 )
|
||||
printf("########### %p approved %s += %.8f\n",basesp,CURRENCIES[baseids[i]],dstr(srcvalues[i]));
|
||||
}
|
||||
}
|
||||
else printf(" i.%d of n.%d pax.%p baseids[] %d\n",i,n,pax,baseids[i]);
|
||||
} //else printf(" i.%d of n.%d pax.%p baseids[] %d\n",i,n,pax,baseids[i]);
|
||||
if ( (pax= komodo_paxfind(txids[i],vouts[i],'A')) != 0 )
|
||||
{
|
||||
pax->type = opretbuf[0];
|
||||
pax->approved = kmdheights[i];
|
||||
if ( didstats != 0 )
|
||||
pax->didstats = 1;
|
||||
printf(" i.%d approved.%d <<<<<<<<<<<<< APPROVED %p\n",i,kmdheights[i],pax);
|
||||
if ( strcmp(CURRENCIES[baseids[i]],ASSETCHAINS_SYMBOL) == 0 )
|
||||
printf(" i.%d approved.%d <<<<<<<<<<<<< APPROVED %p\n",i,kmdheights[i],pax);
|
||||
}
|
||||
}
|
||||
}
|
||||
printf("extra.[%d] after %.8f\n",n,dstr(komodo_paxtotal()));
|
||||
//printf("extra.[%d] after %.8f\n",n,dstr(komodo_paxtotal()));
|
||||
}
|
||||
else if ( opretbuf[0] == 'I' )
|
||||
{
|
||||
@@ -722,6 +728,8 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
|
||||
{
|
||||
basesp->redeemed += srcvalues[i];
|
||||
pax->didstats = 1;
|
||||
if ( strcmp(CURRENCIES[baseids[i]],ASSETCHAINS_SYMBOL) == 0 )
|
||||
printf("########### %p redeemed %s += %.8f\n",basesp,CURRENCIES[baseids[i]],dstr(srcvalues[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -758,13 +766,13 @@ void komodo_passport_iteration()
|
||||
fseek(fp,0,SEEK_END);
|
||||
if ( ftell(fp) > lastpos[baseid] )
|
||||
{
|
||||
if ( lastpos[baseid] == 0 && strcmp(symbol,"KMD") == 0 )
|
||||
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 )
|
||||
;
|
||||
lastpos[baseid] = ftell(fp);
|
||||
if ( lastpos[baseid] == 0 && strcmp(symbol,"KMD") == 0 )
|
||||
if ( 0 && lastpos[baseid] == 0 && strcmp(symbol,"KMD") == 0 )
|
||||
printf("from.(%s) lastpos[%s] %ld\n",ASSETCHAINS_SYMBOL,CURRENCIES[baseid],lastpos[baseid]);
|
||||
} //else fprintf(stderr,"%s.%ld ",CURRENCIES[baseid],ftell(fp));
|
||||
fclose(fp);
|
||||
@@ -783,7 +791,7 @@ void komodo_passport_iteration()
|
||||
} //else fprintf(stderr,"%s not RT\n",base);
|
||||
} //else fprintf(stderr,"%s size error RT\n",base);
|
||||
fclose(fp);
|
||||
} else fprintf(stderr,"%s open error RT\n",base);
|
||||
} //else fprintf(stderr,"%s open error RT\n",base);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -503,7 +503,7 @@ 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 )
|
||||
throw runtime_error("paxdeposit no available inventory");
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user