Browse Source

Merge pull request #499 from jl777/spvdex

fix zcredits sign error
etomic
jl777 7 years ago
committed by GitHub
parent
commit
606653dbb0
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      iguana/exchanges/LP_include.h
  2. 18
      iguana/exchanges/LP_nativeDEX.c
  3. 2
      iguana/exchanges/LP_ordermatch.c
  4. 18
      iguana/exchanges/LP_prices.c
  5. 2
      iguana/exchanges/LP_zeroconf.c

2
iguana/exchanges/LP_include.h

@ -484,7 +484,7 @@ int32_t LP_mempoolscan(char *symbol,bits256 searchtxid);
int32_t LP_txheight(struct iguana_info *coin,bits256 txid);
int32_t LP_numpeers();
char *basilisk_swapentry(uint32_t requestid,uint32_t quoteid);
uint64_t LP_KMDvalue(struct iguana_info *coin,uint64_t balance);
int64_t LP_KMDvalue(struct iguana_info *coin,int64_t balance);
int32_t LP_address_utxoadd(uint32_t timestamp,char *debug,struct iguana_info *coin,char *coinaddr,bits256 txid,int32_t vout,uint64_t value,int32_t height,int32_t spendheight);
void LP_smartutxos_push(struct iguana_info *coin);
void LP_cacheptrs_init(struct iguana_info *coin);

18
iguana/exchanges/LP_nativeDEX.c

@ -553,11 +553,8 @@ void LP_coinsloop(void *_coins)
}
if ( (backupep= ep->prev) == 0 )
backupep = ep;
if ( (ap= LP_addressfind(coin,coin->smartaddr)) != 0 )
{
if ( (retjson= electrum_address_listunspent(coin->symbol,ep,&retjson,ap->coinaddr,1)) != 0 )
free_json(retjson);
}
if ( (retjson= electrum_address_listunspent(coin->symbol,ep,&retjson,coin->smartaddr,1)) != 0 )
free_json(retjson);
HASH_ITER(hh,coin->addresses,ap,atmp)
{
break;
@ -791,14 +788,15 @@ void LP_initpeers(int32_t pubsock,struct LP_peerinfo *mypeer,char *myipaddr,uint
void LP_pubkeysloop(void *ctx)
{
static uint32_t lasttime; cJSON *retjson; struct iguana_info *coin,*tmp;
static uint32_t lasttime;
struct LP_pubkey_info *pubp,*ptmp; //cJSON *retjson; struct iguana_info *coin,*tmp;
strcpy(LP_pubkeysloop_stats.name,"LP_pubkeysloop");
LP_pubkeysloop_stats.threshold = 15000.;
sleep(10);
while ( 1 )
{
LP_millistats_update(&LP_pubkeysloop_stats);
HASH_ITER(hh,LP_coins,coin,tmp) // firstrefht,firstscanht,lastscanht
/*HASH_ITER(hh,LP_coins,coin,tmp) // firstrefht,firstscanht,lastscanht
{
if ( coin->electrum != 0 && time(NULL) > coin->lastunspent+30 )
{
@ -807,6 +805,10 @@ void LP_pubkeysloop(void *ctx)
free_json(retjson);
coin->lastunspent = (uint32_t)time(NULL);
}
}*/
HASH_ITER(hh,LP_pubkeyinfos,pubp,ptmp)
{
pubp->dynamictrust = LP_dynamictrust(pubp->pubkey,0);
}
if ( time(NULL) > lasttime+LP_ORDERBOOK_DURATION*0.5 )
{
@ -1271,7 +1273,7 @@ void LPinit(uint16_t myport,uint16_t mypullport,uint16_t mypubport,uint16_t mybu
printf("error launching LP_pubkeysloop for ctx.%p\n",ctx);
exit(-1);
}
if ( OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)LP_privkeysloop,(void *)myipaddr) != 0 )
if ( 0 && OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)LP_privkeysloop,(void *)myipaddr) != 0 )
{
printf("error launching LP_privkeysloop for ctx.%p\n",ctx);
exit(-1);

2
iguana/exchanges/LP_ordermatch.c

@ -810,7 +810,7 @@ int32_t LP_tradecommand(void *ctx,char *myipaddr,int32_t pubsock,cJSON *argjson,
LP_quoteparse(&Q,argjson);
LP_requestinit(&Q.R,Q.srchash,Q.desthash,Q.srccoin,Q.satoshis-Q.txfee,Q.destcoin,Q.destsatoshis-Q.desttxfee,Q.timestamp,Q.quotetime,DEXselector);
LP_tradecommand_log(argjson);
printf("(%-10u %10u) %12s aliceid.%22llu %5s/%-5s %12.8f -> %12.8f price %12.8f | RT.%d %d\n",Q.R.requestid,Q.R.quoteid,method,(long long)Q.aliceid,Q.srccoin,Q.destcoin,dstr(Q.satoshis),dstr(Q.destsatoshis),(double)Q.destsatoshis/Q.satoshis,LP_RTcount,LP_swapscount);
printf("%-4d (%-10u %10u) %12s id.%22llu %5s/%-5s %12.8f -> %11.8f price %11.8f | RT.%d %d\n",(uint32_t)time(NULL) % 3600,Q.R.requestid,Q.R.quoteid,method,(long long)Q.aliceid,Q.srccoin,Q.destcoin,dstr(Q.satoshis),dstr(Q.destsatoshis),(double)Q.destsatoshis/Q.satoshis,LP_RTcount,LP_swapscount);
retval = 1;
autxo = &A;
butxo = &B;

18
iguana/exchanges/LP_prices.c

@ -22,7 +22,7 @@ struct LP_orderbookentry
{
bits256 pubkey;
double price;
uint64_t avesatoshis,maxsatoshis,depth,dynamictrust;
int64_t avesatoshis,maxsatoshis,depth,dynamictrust;
uint32_t timestamp;
int32_t numutxos;
char coinaddr[64];
@ -330,9 +330,9 @@ char *LP_pubkey_trusted()
return(jprint(array,1));
}
uint64_t LP_unspents_metric(struct iguana_info *coin,char *coinaddr)
int64_t LP_unspents_metric(struct iguana_info *coin,char *coinaddr)
{
cJSON *array,*item; int32_t i,n; uint64_t metric=0,total;
cJSON *array,*item; int32_t i,n; int64_t metric=0,total;
LP_listunspent_both(coin->symbol,coinaddr,0);
if ( (array= LP_address_utxos(coin,coinaddr,1)) != 0 )
{
@ -763,7 +763,7 @@ cJSON *LP_orderbookjson(char *symbol,struct LP_orderbookentry *op)
return(item);
}
struct LP_orderbookentry *LP_orderbookentry(char *address,char *base,char *rel,double price,int32_t numutxos,uint64_t avesatoshis,uint64_t maxsatoshis,bits256 pubkey,uint32_t timestamp,uint64_t balance,uint64_t dynamictrust)
struct LP_orderbookentry *LP_orderbookentry(char *address,char *base,char *rel,double price,int32_t numutxos,int64_t avesatoshis,int64_t maxsatoshis,bits256 pubkey,uint32_t timestamp,int64_t balance,int64_t dynamictrust)
{
struct LP_orderbookentry *op;
if ( (op= calloc(1,sizeof(*op))) != 0 )
@ -850,7 +850,7 @@ int32_t LP_orderbook_utxoentries(uint32_t now,int32_t polarity,char *base,char *
char *LP_orderbook(char *base,char *rel,int32_t duration)
{
uint32_t now,i; uint64_t depth; struct LP_priceinfo *basepp=0,*relpp=0; struct LP_orderbookentry **bids = 0,**asks = 0; cJSON *retjson,*array; struct iguana_info *basecoin,*relcoin; int32_t n,numbids=0,numasks=0,cachenumbids,cachenumasks,baseid,relid,suppress_prefetch=0;
uint32_t now,i; int64_t depth; struct LP_priceinfo *basepp=0,*relpp=0; struct LP_orderbookentry **bids = 0,**asks = 0; cJSON *retjson,*array; struct iguana_info *basecoin,*relcoin; int32_t n,numbids=0,numasks=0,cachenumbids,cachenumasks,baseid,relid,suppress_prefetch=0;
basecoin = LP_coinfind(base);
relcoin = LP_coinfind(rel);
if ( basecoin == 0 || relcoin == 0 )
@ -952,9 +952,9 @@ char *LP_orderbook(char *base,char *rel,int32_t duration)
return(jprint(retjson,1));
}
uint64_t LP_KMDvalue(struct iguana_info *coin,uint64_t balance)
int64_t LP_KMDvalue(struct iguana_info *coin,int64_t balance)
{
cJSON *bids,*asks,*orderbook,*item; double bid=0,ask=0,price = 0.; int32_t numasks,numbids; char *retstr; uint64_t KMDvalue=0;
cJSON *bids,*asks,*orderbook,*item; double bid=0,ask=0,price = 0.; int32_t numasks,numbids; char *retstr; int64_t KMDvalue=0;
if ( balance != 0 )
{
if ( strcmp(coin->symbol,"KMD") == 0 )
@ -1021,7 +1021,7 @@ void LP_priceitemadd(cJSON *retarray,uint32_t timestamp,double avebid,double ave
cJSON *LP_pricearray(char *base,char *rel,uint32_t firsttime,uint32_t lasttime,int32_t timescale)
{
cJSON *retarray; char askfname[1024],bidfname[1024]; uint64_t bidprice64,askprice64; uint32_t bidnow,asknow,bidi,aski,lastbidi,lastaski; int32_t numbids,numasks; double bidemit,askemit,bidsum,asksum,bid,ask,highbid,lowbid,highask,lowask,bidemit2,askemit2; FILE *askfp=0,*bidfp=0;
cJSON *retarray; char askfname[1024],bidfname[1024]; int64_t bidprice64,askprice64; uint32_t bidnow,asknow,bidi,aski,lastbidi,lastaski; int32_t numbids,numasks; double bidemit,askemit,bidsum,asksum,bid,ask,highbid,lowbid,highask,lowask,bidemit2,askemit2; FILE *askfp=0,*bidfp=0;
if ( timescale <= 0 )
timescale = 60;
if ( lasttime == 0 )
@ -1132,7 +1132,7 @@ cJSON *LP_pricearray(char *base,char *rel,uint32_t firsttime,uint32_t lasttime,i
void LP_pricefeedupdate(bits256 pubkey,char *base,char *rel,double price,char *utxocoin,int32_t numrelutxos,int64_t balance,int64_t minutxo,int64_t maxutxo)
{
struct LP_priceinfo *basepp,*relpp; uint32_t now; uint64_t price64; struct LP_pubkey_info *pubp; char str[65],fname[512]; FILE *fp;
struct LP_priceinfo *basepp,*relpp; uint32_t now; int64_t price64; struct LP_pubkey_info *pubp; char str[65],fname[512]; FILE *fp;
//printf("check PRICEFEED UPDATE.(%s/%s) %.8f %s\n",base,rel,price,bits256_str(str,pubkey));
if ( LP_pricevalid(price) > 0 && (basepp= LP_priceinfofind(base)) != 0 && (relpp= LP_priceinfofind(rel)) != 0 )
{

2
iguana/exchanges/LP_zeroconf.c

@ -192,7 +192,7 @@ char *LP_zeroconf_claim(struct iguana_info *coin,char *depositaddr,uint32_t expi
return(clonestr("{\"error\":\"no zeroconf deposits to claim\"}"));
}
void LP_zeroconf_credit(int32_t dispflag,char *coinaddr,uint64_t satoshis,int32_t weeki,char *p2shaddr)
void LP_zeroconf_credit(int32_t dispflag,char *coinaddr,int64_t satoshis,int32_t weeki,char *p2shaddr)
{
uint32_t timestamp; struct LP_address *ap; struct iguana_info *coin = LP_coinfind("KMD");
if ( coin != 0 )

Loading…
Cancel
Save