This commit is contained in:
jl777
2016-11-23 13:45:20 -03:00
parent 55ecfab2cc
commit d6be719d8a
2 changed files with 13 additions and 9 deletions

View File

@@ -51,9 +51,9 @@ struct pax_transaction *komodo_paxmark(int32_t height,struct pax_transaction *sp
return(pax); return(pax);
} }
void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t fiatoshis,uint8_t *rmd160,uint256 txid,uint16_t vout,int32_t height,int32_t otherheight,char *source) // assetchain context void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t fiatoshis,uint8_t *rmd160,uint256 txid,uint16_t vout,int32_t height,int32_t otherheight,char *source,int32_t approved) // assetchain context
{ {
struct pax_transaction *pax; int32_t addflag = 0; struct komodo_state *sp; char str[16],dest[16]; struct pax_transaction *pax; int32_t addflag = 0; struct komodo_state *sp; char str[16],dest[16],*s;
sp = komodo_stateptr(str,dest); sp = komodo_stateptr(str,dest);
pthread_mutex_lock(&komodo_mutex); pthread_mutex_lock(&komodo_mutex);
HASH_FIND(hh,PAX,&txid,sizeof(txid),pax); HASH_FIND(hh,PAX,&txid,sizeof(txid),pax);
@@ -92,7 +92,12 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t
if ( pax->marked == 0 ) if ( pax->marked == 0 )
{ {
if ( addflag != 0 ) if ( addflag != 0 )
printf("[%s] addflag.%d ADD %s %s %.8f -> %s TO PAX ht.%d otherht.%d total %.8f\n",ASSETCHAINS_SYMBOL,addflag,ASSETCHAINS_SYMBOL[0]==0?"WITHDRAW":"DEPOSIT",symbol,dstr(ASSETCHAINS_SYMBOL[0]==0?pax->komodoshis:pax->fiatoshis),pax->coinaddr,pax->height,pax->otherheight,dstr(komodo_paxtotal())); {
if ( (pax->approved= approved) != 0 )
s = (char *)"APPROVED";
else s = (char *)(ASSETCHAINS_SYMBOL[0]==0?"WITHDRAW":"DEPOSIT");
printf("[%s] addflag.%d ADD %s %s %.8f -> %s TO PAX ht.%d otherht.%d total %.8f\n",ASSETCHAINS_SYMBOL,addflag,s,symbol,dstr(ASSETCHAINS_SYMBOL[0]==0?pax->komodoshis:pax->fiatoshis),pax->coinaddr,pax->height,pax->otherheight,dstr(komodo_paxtotal()));
}
} }
//else printf("%p MARKED.%d DEPOSIT %s %.8f -> %s TO PAX ht.%d otherht.%d\n",pax,pax->marked,symbol,dstr(fiatoshis),coinaddr,height,otherheight); //else printf("%p MARKED.%d DEPOSIT %s %.8f -> %s TO PAX ht.%d otherht.%d\n",pax,pax->marked,symbol,dstr(fiatoshis),coinaddr,height,otherheight);
} }
@@ -138,7 +143,6 @@ int32_t komodo_rwapproval(int32_t rwflag,uint8_t *opretbuf,struct pax_transactio
memcpy(pax->rmd160,&opretbuf[len],20), len += 20; memcpy(pax->rmd160,&opretbuf[len],20), len += 20;
for (i=0; i<4; i++) for (i=0; i<4; i++)
pax->source[i] = opretbuf[len++]; pax->source[i] = opretbuf[len++];
printf("%02x %02x %02x %02x %s\n",pax->source[0],pax->source[1],pax->source[2],pax->source[3],pax->source);
} }
return(len); return(len);
} }
@@ -422,7 +426,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
{ {
if ( komodo_paxfind(&space,txid,vout) == 0 ) if ( komodo_paxfind(&space,txid,vout) == 0 )
{ {
komodo_gateway_deposit(coinaddr,value,base,fiatoshis,rmd160,txid,vout,kmdheight,height,(char *)"KMD"); komodo_gateway_deposit(coinaddr,value,base,fiatoshis,rmd160,txid,vout,kmdheight,height,(char *)"KMD",0);
} else printf("duplicate deposit\n"); } else printf("duplicate deposit\n");
} }
} }
@@ -444,7 +448,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
{ {
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,kmdheight,height,source); komodo_gateway_deposit(coinaddr,komodoshis,(char *)"KMD",value,rmd160,txid,vout,kmdheight,height,source,0);
} }
} }
else if ( tokomodo != 0 && opretbuf[0] == 'A' ) else if ( tokomodo != 0 && opretbuf[0] == 'A' )
@@ -463,7 +467,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
if ( (pax= komodo_paxfind(&space,txids[i],vouts[i])) == 0 && baseids[i] >= 0 ) if ( (pax= komodo_paxfind(&space,txids[i],vouts[i])) == 0 && baseids[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]]); komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],kmdheights[i],otherheights[i],CURRENCIES[baseids[i]],kmdheights[i]);
printf("i.%d (%s) <- %.8f\n",i,coinaddr,dstr(values[i])); printf("i.%d (%s) <- %.8f\n",i,coinaddr,dstr(values[i]));
} else printf("i.%d pax.%p baseids[] %d\n",i,pax,baseids[i]); } else printf("i.%d pax.%p baseids[] %d\n",i,pax,baseids[i]);
if ( (pax= komodo_paxfind(&space,txids[i],vouts[i])) != 0 ) if ( (pax= komodo_paxfind(&space,txids[i],vouts[i])) != 0 )
@@ -485,7 +489,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
{ {
bitcoin_address(coinaddr,60,&rmd160s[i*20],20); bitcoin_address(coinaddr,60,&rmd160s[i*20],20);
if ( komodo_paxmark(height,&space,txids[i],vouts[i],height) == 0 && baseids[i] >= 0 ) if ( komodo_paxmark(height,&space,txids[i],vouts[i],height) == 0 && baseids[i] >= 0 )
komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],height,0,CURRENCIES[baseids[i]]); komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],height,0,CURRENCIES[baseids[i]],0);
} }
} }
} }

View File

@@ -398,7 +398,7 @@ Value minerids(const Array& params, bool fHelp)
int32_t height = atoi(params[0].get_str().c_str()); int32_t height = atoi(params[0].get_str().c_str());
if ( height <= 0 ) if ( height <= 0 )
height = chainActive.Tip()->nHeight; height = chainActive.Tip()->nHeight;
if ( (n= komodo_minerids(minerids,height)) > 0 && n <= 64 ) if ( (n= komodo_minerids(minerids,height)) > 0 )
{ {
memset(tally,0,sizeof(tally)); memset(tally,0,sizeof(tally));
numnotaries = komodo_notaries(pubkeys,height); numnotaries = komodo_notaries(pubkeys,height);