diff --git a/iguana/exchanges/LP_coins.c b/iguana/exchanges/LP_coins.c index c2771e308..fe9c20f34 100644 --- a/iguana/exchanges/LP_coins.c +++ b/iguana/exchanges/LP_coins.c @@ -23,9 +23,12 @@ char *portstrs[][3] = { { "BTC", "8332" }, { "KMD", "7771" } }; uint16_t LP_rpcport(char *symbol) { int32_t i; - for (i=0; iinactive != 0 || coin->electrum != 0 || coin == refcoin ) - continue; - if ( strcmp(coin->serverport,refcoin->serverport) == 0 ) - break; + HASH_ITER(hh,LP_coins,coin,tmp) + { + if ( coin->inactive != 0 || coin->electrum != 0 || coin == refcoin ) + continue; + if ( strcmp(coin->serverport,refcoin->serverport) == 0 ) + break; + } } return(coin); } @@ -254,31 +260,37 @@ cJSON *LP_coinsjson(int32_t showwif) char *LP_getcoin(char *symbol) { int32_t numenabled,numdisabled; struct iguana_info *coin,*tmp; cJSON *item=0,*retjson; - numenabled = numdisabled = 0; retjson = cJSON_CreateObject(); - HASH_ITER(hh,LP_coins,coin,tmp) + if ( symbol != 0 && symbol[0] != 0 ) { - if ( strcmp(symbol,coin->symbol) == 0 ) - item = LP_coinjson(coin,0); - if ( coin->inactive == 0 ) - numenabled++; - else numdisabled++; + numenabled = numdisabled = 0; + HASH_ITER(hh,LP_coins,coin,tmp) + { + if ( strcmp(symbol,coin->symbol) == 0 ) + item = LP_coinjson(coin,0); + if ( coin->inactive == 0 ) + numenabled++; + else numdisabled++; + } + jaddstr(retjson,"result","success"); + jaddnum(retjson,"enabled",numenabled); + jaddnum(retjson,"disabled",numdisabled); + if ( item == 0 ) + item = cJSON_CreateObject(); + jadd(retjson,"coin",item); } - jaddstr(retjson,"result","success"); - jaddnum(retjson,"enabled",numenabled); - jaddnum(retjson,"disabled",numdisabled); - if ( item == 0 ) - item = cJSON_CreateObject(); - jadd(retjson,"coin",item); return(jprint(retjson,1)); } struct iguana_info *LP_coinsearch(char *symbol) { - struct iguana_info *coin; - portable_mutex_lock(&LP_coinmutex); - HASH_FIND(hh,LP_coins,symbol,strlen(symbol),coin); - portable_mutex_unlock(&LP_coinmutex); + struct iguana_info *coin = 0; + if ( symbol != 0 && symbol[0] != 0 ) + { + portable_mutex_lock(&LP_coinmutex); + HASH_FIND(hh,LP_coins,symbol,strlen(symbol),coin); + portable_mutex_unlock(&LP_coinmutex); + } return(coin); } diff --git a/iguana/exchanges/LP_commands.c b/iguana/exchanges/LP_commands.c index 831f81ccb..740c156c6 100644 --- a/iguana/exchanges/LP_commands.c +++ b/iguana/exchanges/LP_commands.c @@ -153,9 +153,12 @@ bot_resume(botid)\n\ \"}")); //sell(base, rel, price, basevolume, timeout=10, duration=3600)\n\ - base = jstr(argjson,"base"); - rel = jstr(argjson,"rel"); - coin = jstr(argjson,"coin"); + if ( (base= jstr(argjson,"base")) == 0 ) + base = ""; + if ((rel= jstr(argjson,"rel")) == 0 ) + rel = ""; + if ( (coin= jstr(argjson,"coin")) == 0 ) + coin = ""; if ( G.USERPASS[0] != 0 && strcmp(remoteaddr,"127.0.0.1") == 0 && port != 0 ) // protected localhost { if ( G.USERPASS_COUNTER == 0 )