diff --git a/iguana/exchanges/LP_scan.c b/iguana/exchanges/LP_scan.c index 7c49ed039..ce4a2b0ee 100644 --- a/iguana/exchanges/LP_scan.c +++ b/iguana/exchanges/LP_scan.c @@ -21,7 +21,7 @@ int32_t LP_blockinit(struct iguana_info *coin,int32_t height) { - char str[65]; int32_t i,j,iter,numtx,checkht=-1; cJSON *blockobj,*txs; bits256 txid; struct LP_transaction *tx; + int32_t i,iter,numtx,checkht=-1; cJSON *blockobj,*txs; bits256 txid; struct LP_transaction *tx; if ( (blockobj= LP_blockjson(&checkht,coin->symbol,0,height)) != 0 && checkht == height ) { if ( (txs= jarray(&numtx,blockobj,"tx")) != 0 ) diff --git a/iguana/exchanges/LP_socket.c b/iguana/exchanges/LP_socket.c index 493aa1ead..fa41ecb01 100644 --- a/iguana/exchanges/LP_socket.c +++ b/iguana/exchanges/LP_socket.c @@ -198,7 +198,7 @@ int32_t LP_socketsend(int32_t sock,uint8_t *serialized,int32_t len) flags = MSG_NOSIGNAL; #endif remains = len; - while ( remains > 0 ) + while ( sock >= 0 && remains > 0 ) { if ( (numsent= (int32_t)send(sock,serialized,remains,flags)) < 0 ) { @@ -225,7 +225,7 @@ int32_t LP_socketsend(int32_t sock,uint8_t *serialized,int32_t len) int32_t LP_socketrecv(int32_t sock,uint8_t *recvbuf,int32_t maxlen) { int32_t recvlen = -1; - while ( 1 ) + while ( sock >= 0 ) { if ( (recvlen= (int32_t)recv(sock,recvbuf,maxlen,0)) < 0 ) { @@ -574,7 +574,7 @@ void electrum_test() struct electrum_info *LP_electrum_info(int32_t *alreadyp,char *symbol,char *ipaddr,uint16_t port,int32_t bufsize) { - struct electrum_info *ep=0; int32_t i; struct stritem *sitem; char name[512],*str = "init string"; + struct electrum_info *ep=0; int32_t i,sock; struct stritem *sitem; char name[512],*str = "init string"; *alreadyp = 0; portable_mutex_lock(&LP_electrummutex); for (i=0; isock = LP_socket(0,ipaddr,port); + ep->sock = sock; safecopy(ep->symbol,symbol,sizeof(ep->symbol)); safecopy(ep->ipaddr,ipaddr,sizeof(ep->ipaddr)); ep->port = port; @@ -771,7 +776,11 @@ cJSON *LP_electrumserver(struct iguana_info *coin,char *ipaddr,uint16_t port) struct electrum_info *ep; int32_t already; cJSON *retjson = cJSON_CreateObject(); jaddstr(retjson,"ipaddr",ipaddr); jaddnum(retjson,"port",port); - ep = LP_electrum_info(&already,coin->symbol,ipaddr,port,IGUANA_MAXPACKETSIZE * 10); + if ( (ep= LP_electrum_info(&already,coin->symbol,ipaddr,port,IGUANA_MAXPACKETSIZE * 10)) == 0 ) + { + jaddstr(retjson,"error","couldnt connect to electrum server"); + return(retjson); + } if ( already == 0 ) { if ( ep != 0 && OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)LP_dedicatedloop,(void *)ep) != 0 )