Browse Source

Test

etomic
jl777 7 years ago
parent
commit
a20368c322
  1. 18
      iguana/exchanges/LP_coins.c
  2. 8
      iguana/exchanges/LP_commands.c

18
iguana/exchanges/LP_coins.c

@ -170,10 +170,18 @@ int32_t LP_userpass(char *userpass,char *symbol,char *assetname,char *confroot,c
return(-1); return(-1);
} }
cJSON *LP_coinjson(struct iguana_info *coin) cJSON *LP_coinjson(struct iguana_info *coin,int32_t showwif)
{ {
cJSON *item = cJSON_CreateObject(); char wifstr[128]; uint8_t tmptype; bits256 checkkey; cJSON *item = cJSON_CreateObject();
jaddstr(item,"coin",coin->symbol); jaddstr(item,"coin",coin->symbol);
if ( showwif != 0 )
{
bitcoin_priv2wif(coin->wiftaddr,wifstr,LP_mypriv25519,coin->wiftype);
bitcoin_wif2priv(coin->wiftaddr,&tmptype,&checkkey,wifstr);
if ( bits256_cmp(LP_mypriv25519,checkkey) == 0 )
jaddstr(item,"wif",wifstr);
else jaddstr(item,"wif","error creating wif");
}
if ( coin->inactive != 0 ) if ( coin->inactive != 0 )
jaddstr(item,"status","inactive"); jaddstr(item,"status","inactive");
else jaddstr(item,"status","active"); else jaddstr(item,"status","active");
@ -188,12 +196,12 @@ cJSON *LP_coinjson(struct iguana_info *coin)
return(item); return(item);
} }
cJSON *LP_coinsjson() cJSON *LP_coinsjson(int32_t showwif)
{ {
struct iguana_info *coin,*tmp; cJSON *array = cJSON_CreateArray(); struct iguana_info *coin,*tmp; cJSON *array = cJSON_CreateArray();
HASH_ITER(hh,LP_coins,coin,tmp) HASH_ITER(hh,LP_coins,coin,tmp)
{ {
jaddi(array,LP_coinjson(coin)); jaddi(array,LP_coinjson(coin,showwif));
} }
return(array); return(array);
} }
@ -206,7 +214,7 @@ char *LP_getcoin(char *symbol)
HASH_ITER(hh,LP_coins,coin,tmp) HASH_ITER(hh,LP_coins,coin,tmp)
{ {
if ( strcmp(symbol,coin->symbol) == 0 ) if ( strcmp(symbol,coin->symbol) == 0 )
item = LP_coinjson(coin); item = LP_coinjson(coin,0);
if ( coin->inactive == 0 ) if ( coin->inactive == 0 )
numenabled++; numenabled++;
else numdisabled++; else numdisabled++;

8
iguana/exchanges/LP_commands.c

@ -133,7 +133,7 @@ trust(pubkey, trust)\n\
retjson = cJSON_CreateObject(); retjson = cJSON_CreateObject();
jaddstr(retjson,"userpass",USERPASS); jaddstr(retjson,"userpass",USERPASS);
jaddbits256(retjson,"mypubkey",LP_mypub25519); jaddbits256(retjson,"mypubkey",LP_mypub25519);
jadd(retjson,"coins",LP_coinsjson()); jadd(retjson,"coins",LP_coinsjson(1));
return(jprint(retjson,1)); return(jprint(retjson,1));
} }
if ( (userpass= jstr(argjson,"userpass")) == 0 || strcmp(userpass,USERPASS) != 0 ) if ( (userpass= jstr(argjson,"userpass")) == 0 || strcmp(userpass,USERPASS) != 0 )
@ -238,13 +238,13 @@ trust(pubkey, trust)\n\
{ {
if ( (ptr= LP_coinsearch(coin)) != 0 ) if ( (ptr= LP_coinsearch(coin)) != 0 )
ptr->inactive = 0; ptr->inactive = 0;
return(jprint(LP_coinsjson(),1)); return(jprint(LP_coinsjson(0),1));
} }
else if ( strcmp(method,"disable") == 0 ) else if ( strcmp(method,"disable") == 0 )
{ {
if ( (ptr= LP_coinsearch(coin)) != 0 ) if ( (ptr= LP_coinsearch(coin)) != 0 )
ptr->inactive = (uint32_t)time(NULL); ptr->inactive = (uint32_t)time(NULL);
return(jprint(LP_coinsjson(),1)); return(jprint(LP_coinsjson(0),1));
} }
if ( LP_isdisabled(coin,0) != 0 ) if ( LP_isdisabled(coin,0) != 0 )
return(clonestr("{\"error\":\"coin is disabled\"}")); return(clonestr("{\"error\":\"coin is disabled\"}"));
@ -309,7 +309,7 @@ trust(pubkey, trust)\n\
else if ( strcmp(method,"checktxid") == 0 ) else if ( strcmp(method,"checktxid") == 0 )
retstr = LP_spentcheck(argjson); retstr = LP_spentcheck(argjson);
else if ( strcmp(method,"getcoins") == 0 ) else if ( strcmp(method,"getcoins") == 0 )
return(jprint(LP_coinsjson(),1)); return(jprint(LP_coinsjson(0),1));
else if ( strcmp(method,"numutxos") == 0 ) else if ( strcmp(method,"numutxos") == 0 )
return(LP_numutxos()); return(LP_numutxos());
else if ( strcmp(method,"postprice") == 0 ) else if ( strcmp(method,"postprice") == 0 )

Loading…
Cancel
Save