This commit is contained in:
jl777
2016-10-29 16:56:32 -03:00
parent 1911ff1acd
commit 8e3430ee2d
2 changed files with 46 additions and 35 deletions

View File

@@ -121,9 +121,7 @@ int32_t komodo_gateway_depositremove(uint256 txid,uint16_t vout) // assetchain c
const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int32_t opretlen,uint256 txid,uint16_t vout) const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int32_t opretlen,uint256 txid,uint16_t vout)
{ {
uint8_t rmd160[20],addrtype,shortflag,pubkey33[33]; int32_t i,j,len,tokomodo=0; char base[4],coinaddr[64],destaddr[64]; int64_t fiatoshis,checktoshis; const char *typestr = "unknown"; uint8_t rmd160[20],addrtype,shortflag,pubkey33[33]; int32_t i,j,len,tokomodo=0; char base[4],coinaddr[64],destaddr[64]; int64_t fiatoshis,checktoshis; const char *typestr = "unknown";
#ifdef KOMODO_ISSUER tokomodo = (komodo_is_issuer() == 0);
tokomodo = 1;
#endif
if ( opretbuf[0] == ((tokomodo != 0) ? 'D' : 'W') ) if ( opretbuf[0] == ((tokomodo != 0) ? 'D' : 'W') )
{ {
if ( opretlen == 34 ) if ( opretlen == 34 )
@@ -134,51 +132,57 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
fiatoshis = -fiatoshis; fiatoshis = -fiatoshis;
bitcoin_address(coinaddr,addrtype,rmd160,20); bitcoin_address(coinaddr,addrtype,rmd160,20);
checktoshis = PAX_fiatdest(tokomodo,destaddr,pubkey33,coinaddr,height,base,fiatoshis); checktoshis = PAX_fiatdest(tokomodo,destaddr,pubkey33,coinaddr,height,base,fiatoshis);
for (i=0; i<opretlen; i++)
printf("%02x",opretbuf[i]);
printf(" DEPOSIT %.8f %c%s -> %s ",dstr(fiatoshis),shortflag!=0?'-':'+',base,coinaddr);
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)\n",dstr(checktoshis),dstr(value),destaddr);
typestr = "deposit"; typestr = "deposit";
#ifdef KOMODO_ISSUER if ( tokomodo == 0 && strncmp(KOMODO_SOURCE,base,strlen(base)) == 0 )
if ( strncmp(KOMODO_SOURCE,base,strlen(base)) == 0 && value >= (9999*checktoshis)/10000 && shortflag == ASSETCHAINS_SHORTFLAG )
{ {
komodo_gateway_deposit(value,shortflag,base,fiatoshis,rmd160,txid,vout); for (i=0; i<opretlen; i++)
printf("%02x",opretbuf[i]);
printf(" DEPOSIT %.8f %c%s -> %s ",dstr(fiatoshis),shortflag!=0?'-':'+',base,coinaddr);
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)\n",dstr(checktoshis),dstr(value),destaddr);
if ( value >= (9999*checktoshis)/10000 && shortflag == ASSETCHAINS_SHORTFLAG )
{
komodo_gateway_deposit(value,shortflag,base,fiatoshis,rmd160,txid,vout);
}
} }
#else else
if ( tokomodo != 0 && value <= (10000*checktoshis)/9999 )
{ {
if ( value <= (10000*checktoshis)/9999 )
{
}
} }
#endif
} }
} }
else else
{ {
for (i=0; i<opretlen; i++) if ( tokomodo == 0 && strncmp(KOMODO_SOURCE,base,strlen(base)) == 0 )
printf("%02x",opretbuf[i]);
printf(" komodo_opreturn[%c]: ht.%d %.8f opretlen.%d\n",opretbuf[0],height,dstr(value),opretlen);
if ( opretbuf[0] == 'I' )
{ {
uint256 issuedtxid; uint16_t issuedvout; for (i=0; i<opretlen; i++)
opretbuf++, opretlen--; printf("%02x",opretbuf[i]);
for (i=len=0; i<opretlen/34; i++) printf(" komodo_opreturn[%c]: ht.%d %.8f opretlen.%d\n",opretbuf[0],height,dstr(value),opretlen);
if ( opretbuf[0] == 'I' )
{ {
for (j=0; j<32; j++) uint256 issuedtxid; uint16_t issuedvout;
opretbuf++, opretlen--;
for (i=len=0; i<opretlen/34; i++)
{ {
((uint8_t *)&issuedtxid)[j] = opretbuf[len++]; for (j=0; j<32; j++)
printf("%02x",((uint8_t *)&issuedtxid)[j]); {
((uint8_t *)&issuedtxid)[j] = opretbuf[len++];
printf("%02x",((uint8_t *)&issuedtxid)[j]);
}
issuedvout = opretbuf[len++];
issuedvout = (opretbuf[len++] << 8) | vout;
printf(" issuedtxid v%d i.%d opretlen.%d\n",issuedvout,i,opretlen);
if ( komodo_gateway_depositremove(issuedtxid,issuedvout) == 0 )
printf("error removing deposit\n");
} }
issuedvout = opretbuf[len++];
issuedvout = (opretbuf[len++] << 8) | vout;
printf(" issuedtxid v%d i.%d opretlen.%d\n",issuedvout,i,opretlen);
if ( komodo_gateway_depositremove(issuedtxid,issuedvout) == 0 )
printf("error removing deposit\n");
} }
} }
} }

View File

@@ -800,6 +800,13 @@ int32_t komodo_baseid(char *origbase)
return(-1); return(-1);
} }
int32_t komodo_is_issuer()
{
if ( ASSETCHAINS_SYMBOL[0] != 0 && COINBASE_MATURITY == 1 )
return(1);
else return(0);
}
int32_t _unhex(char c) int32_t _unhex(char c)
{ {
if ( c >= '0' && c <= '9' ) if ( c >= '0' && c <= '9' )