test
This commit is contained in:
@@ -144,7 +144,7 @@ int32_t komodo_rwapproval(int32_t rwflag,uint8_t *opretbuf,struct pax_transactio
|
|||||||
return(len);
|
return(len);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t *values,int32_t *kmdheights,int32_t *otherheights,int8_t *baseids,uint8_t *rmd160s,uint8_t *opretbuf,int32_t opretlen,int32_t iskomodo)
|
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; int32_t i,n=0,j,len=0,incr,height,otherheight; uint8_t rmd160[20]; uint64_t fiatoshis; char symbol[16];
|
struct pax_transaction p; int32_t i,n=0,j,len=0,incr,height,otherheight; uint8_t rmd160[20]; uint64_t fiatoshis; char symbol[16];
|
||||||
for (i=0; i<4; i++)
|
for (i=0; i<4; i++)
|
||||||
@@ -160,11 +160,12 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t
|
|||||||
{
|
{
|
||||||
memset(&p,0,sizeof(p));
|
memset(&p,0,sizeof(p));
|
||||||
len += komodo_rwapproval(0,&opretbuf[len],&p);
|
len += komodo_rwapproval(0,&opretbuf[len],&p);
|
||||||
if ( values != 0 && kmdheights != 0 && otherheights != 0 && baseids != 0 && rmd160s != 0 )
|
if ( values != 0 && srcvalues != 0 && kmdheights != 0 && otherheights != 0 && baseids != 0 && rmd160s != 0 )
|
||||||
{
|
{
|
||||||
txids[n] = p.txid;
|
txids[n] = p.txid;
|
||||||
vouts[n] = p.vout;
|
vouts[n] = p.vout;
|
||||||
values[n] = (ASSETCHAINS_SYMBOL[0] == 0) ? p.komodoshis : p.fiatoshis;
|
values[n] = (ASSETCHAINS_SYMBOL[0] == 0) ? p.komodoshis : p.fiatoshis;
|
||||||
|
srcvalues[n] = (ASSETCHAINS_SYMBOL[0] == 0) ? p.fiatoshis : p.komodoshis;
|
||||||
kmdheights[n] = p.height;
|
kmdheights[n] = p.height;
|
||||||
otherheights[n] = p.otherheight;
|
otherheights[n] = p.otherheight;
|
||||||
memcpy(&rmd160s[n * 20],p.rmd160,20);
|
memcpy(&rmd160s[n * 20],p.rmd160,20);
|
||||||
@@ -313,9 +314,10 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to
|
|||||||
|
|
||||||
int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above block is valid pax pricing
|
int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above block is valid pax pricing
|
||||||
{
|
{
|
||||||
int32_t i,j,n,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]; int64_t values[64]; struct pax_transaction *pax;
|
int32_t i,j,n,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]; int64_t values[64],srcvalues[64]; struct pax_transaction *pax;
|
||||||
memset(baseids,0xff,sizeof(baseids));
|
memset(baseids,0xff,sizeof(baseids));
|
||||||
memset(values,0,sizeof(values));
|
memset(values,0,sizeof(values));
|
||||||
|
memset(srcvalues,0,sizeof(srcvalues));
|
||||||
memset(rmd160s,0,sizeof(rmd160s));
|
memset(rmd160s,0,sizeof(rmd160s));
|
||||||
memset(kmdheights,0,sizeof(kmdheights));
|
memset(kmdheights,0,sizeof(kmdheights));
|
||||||
memset(otherheights,0,sizeof(otherheights));
|
memset(otherheights,0,sizeof(otherheights));
|
||||||
@@ -339,7 +341,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above
|
|||||||
}
|
}
|
||||||
if ( script[offset] == opcode && opretlen < block.vtx[0].vout[n-1].scriptPubKey.size() )
|
if ( script[offset] == opcode && opretlen < block.vtx[0].vout[n-1].scriptPubKey.size() )
|
||||||
{
|
{
|
||||||
if ( (num= komodo_issued_opreturn(base,txids,vouts,values,kmdheights,otherheights,baseids,rmd160s,&script[offset],opretlen,opcode == 'X')) > 0 )
|
if ( (num= komodo_issued_opreturn(base,txids,vouts,values,srcvalues,kmdheights,otherheights,baseids,rmd160s,&script[offset],opretlen,opcode == 'X')) > 0 )
|
||||||
{
|
{
|
||||||
for (i=1; i<n-1; i++)
|
for (i=1; i<n-1; i++)
|
||||||
{
|
{
|
||||||
@@ -453,21 +455,25 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
|
|||||||
}
|
}
|
||||||
else if ( tokomodo != 0 && opretbuf[0] == 'A' )
|
else if ( tokomodo != 0 && opretbuf[0] == 'A' )
|
||||||
{
|
{
|
||||||
//if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 )
|
if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 )
|
||||||
{
|
{
|
||||||
for (i=0; i<opretlen; i++)
|
for (i=0; i<opretlen; i++)
|
||||||
printf("%02x",opretbuf[i]);
|
printf("%02x",opretbuf[i]);
|
||||||
printf(" opret[%c] else path tokomodo.%d ht.%d before %.8f\n",opretbuf[0],tokomodo,height,dstr(komodo_paxtotal()));
|
printf(" opret[%c] else path tokomodo.%d ht.%d before %.8f\n",opretbuf[0],tokomodo,height,dstr(komodo_paxtotal()));
|
||||||
}
|
}
|
||||||
printf("extra 'A' opret[%d]\n",opretlen);
|
printf("extra 'A' opret[%d]\n",opretlen);
|
||||||
if ( (n= komodo_issued_opreturn(base,txids,vouts,values,kmdheights,otherheights,baseids,rmd160s,opretbuf,opretlen,1)) > 0 )
|
if ( (n= komodo_issued_opreturn(base,txids,vouts,values,srcvalues,kmdheights,otherheights,baseids,rmd160s,opretbuf,opretlen,1)) > 0 )
|
||||||
{
|
{
|
||||||
for (i=0; i<n; i++)
|
for (i=0; i<n; i++)
|
||||||
{
|
{
|
||||||
|
if ( baseids[i] < 0 )
|
||||||
|
continue;
|
||||||
|
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],base,(double)fiatoshis/COIN,(double)values[i]/COIN,(double)checktoshis/COIN);
|
||||||
for (j=0; j<32; j++)
|
for (j=0; j<32; j++)
|
||||||
printf("%02x",((uint8_t *)&txids[i])[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])) == 0 && baseids[i] >= 0 )
|
if ( (pax= komodo_paxfind(txids[i],vouts[i])) == 0 )
|
||||||
{
|
{
|
||||||
bitcoin_address(coinaddr,60,&rmd160s[i*20],20);
|
bitcoin_address(coinaddr,60,&rmd160s[i*20],20);
|
||||||
komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],kmdheights[i],otherheights[i],CURRENCIES[baseids[i]],kmdheights[i]);
|
komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],kmdheights[i],otherheights[i],CURRENCIES[baseids[i]],kmdheights[i]);
|
||||||
@@ -486,7 +492,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
|
|||||||
{
|
{
|
||||||
if ( strncmp((char *)"KMD",(char *)&opretbuf[opretlen-4],3) != 0 )
|
if ( strncmp((char *)"KMD",(char *)&opretbuf[opretlen-4],3) != 0 )
|
||||||
{
|
{
|
||||||
if ( (n= komodo_issued_opreturn(base,txids,vouts,values,kmdheights,otherheights,baseids,rmd160s,opretbuf,opretlen,0)) > 0 )
|
if ( (n= komodo_issued_opreturn(base,txids,vouts,values,srcvalues,kmdheights,otherheights,baseids,rmd160s,opretbuf,opretlen,0)) > 0 )
|
||||||
{
|
{
|
||||||
for (i=0; i<n; i++)
|
for (i=0; i<n; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user