jl777 7 years ago
parent
commit
8c47d8ce4d
  1. 9
      iguana/exchanges/LP_portfolio.c
  2. 36
      iguana/exchanges/LP_signatures.c

9
iguana/exchanges/LP_portfolio.c

@ -596,7 +596,7 @@ int32_t LP_portfolio_order(struct LP_portfoliotrade *trades,int32_t max,cJSON *a
void prices_loop(void *ignore)
{
char *retstr; cJSON *retjson,*array; char *buycoin,*sellcoin; struct iguana_info *buy,*sell; uint32_t requestid,quoteid; int32_t i,n,m; struct LP_portfoliotrade trades[256]; struct LP_priceinfo *btcpp; void *ctx = bitcoin_ctx();
char *retstr; cJSON *retjson,*array; char *buycoin,*sellcoin; struct iguana_info *buy,*sell; uint32_t requestid,quoteid; uint32_t expiration; int32_t i,n,m; struct LP_portfoliotrade trades[256]; struct LP_priceinfo *btcpp; void *ctx = bitcoin_ctx();
while ( 1 )
{
if ( (btcpp= LP_priceinfofind("BTC")) == 0 )
@ -634,7 +634,12 @@ void prices_loop(void *ignore)
}
free(retstr);
}
sleep(60);
expiration = (uint32_t)time(NULL) + 60;
while ( time(NULL) < expiration )
{
if ( LP_utxosQ_process() == 0 )
usleep(10000);
}
}
}

36
iguana/exchanges/LP_signatures.c

@ -260,21 +260,39 @@ void LP_postutxos(char *symbol,char *coinaddr)
}
}
queue_t utxosQ;
struct LP_utxos_qitem { struct queueitem DL; cJSON *argjson; };
char *LP_postutxos_recv(cJSON *argjson)
{
int32_t n; char *symbol,*coinaddr; struct LP_address *ap; struct iguana_info *coin; cJSON *array;
//printf("posted.(%s)\n",jprint(argjson,0));
if ( (coinaddr= jstr(argjson,"coinaddr")) != 0 && (symbol= jstr(argjson,"coin")) != 0 && (coin= LP_coinfind(symbol)) != 0 ) // addsig
struct LP_utxos_qitem *uitem;
uitem = calloc(1,sizeof(*uitem));
uitem->argjson = jduplicate(argjson);
queue_enqueue("utxosQ",&utxosQ,&uitem->DL);
return(clonestr("{\"result\":\"success\"}"));
}
int32_t LP_utxosQ_process()
{
struct LP_utxos_qitem *uitem; int32_t n; char *symbol,*coinaddr; struct LP_address *ap; struct iguana_info *coin; cJSON *array;
if ( (uitem= queue_dequeue(&utxosQ)) != 0 )
{
if ( coin->electrum == 0 || (ap= LP_addressfind(coin,coinaddr)) != 0 )
printf("LP_utxosQ_process.(%s)\n",jprint(uitem->argjson,0));
if ( (coinaddr= jstr(uitem->argjson,"coinaddr")) != 0 && (symbol= jstr(uitem->argjson,"coin")) != 0 && (coin= LP_coinfind(symbol)) != 0 ) // addsig
{
if ( (array= jarray(&n,argjson,"utxos")) != 0 )
LP_unspents_array(coin,coinaddr,array);
if ( coin->electrum == 0 || (ap= LP_addressfind(coin,coinaddr)) != 0 )
{
if ( (array= jarray(&n,uitem->argjson,"utxos")) != 0 )
LP_unspents_array(coin,coinaddr,array);
}
else if ( (array= electrum_address_listunspent(symbol,coin->electrum,&array,coinaddr,1)) != 0 )
free_json(array);
}
else if ( (array= electrum_address_listunspent(symbol,coin->electrum,&array,coinaddr,1)) != 0 )
free_json(array);
free_json(uitem->argjson);
free(uitem);
return(1);
}
return(clonestr("{\"result\":\"success\"}"));
return(0);
}
char *LP_pricepings(void *ctx,char *myipaddr,int32_t pubsock,char *base,char *rel,double price)

Loading…
Cancel
Save