Browse Source

Test

etomic
jl777 7 years ago
parent
commit
840adc1562
  1. 10
      iguana/exchanges/LP_coins.c
  2. 1
      iguana/exchanges/LP_include.h
  3. 23
      iguana/exchanges/LP_rpc.c

10
iguana/exchanges/LP_coins.c

@ -197,9 +197,15 @@ cJSON *LP_coinjson(struct iguana_info *coin,int32_t showwif)
}
jadd(item,"installed",coin->userpass[0] == 0 ? jfalse() : jtrue());
if ( coin->userpass[0] != 0 )
{
jaddnum(item,"height",LP_getheight(coin));
else jaddnum(item,"height",-1);
jaddnum(item,"balance",dstr(LP_smartbalance(coin)));
}
else
{
jaddnum(item,"height",-1);
jaddnum(item,"balance",0);
}
if ( coin->inactive != 0 )
{
jaddstr(item,"status","inactive");

1
iguana/exchanges/LP_include.h

@ -299,6 +299,7 @@ uint16_t LP_psock_get(char *connectaddr,char *publicaddr,int32_t ispaired);
int32_t LP_coinbus(uint16_t coin_busport);
int32_t LP_nanomsg_recvs(void *ctx);
int32_t LP_reserved_msgs();
uint64_t LP_smartbalance(struct iguana_info *coin);
int32_t LP_getheight(struct iguana_info *coin);
int32_t LP_reserved_msg(char *base,char *rel,bits256 pubkey,char *msg);
struct iguana_info *LP_coinfind(char *symbol);

23
iguana/exchanges/LP_rpc.c

@ -225,6 +225,29 @@ int32_t LP_getheight(struct iguana_info *coin)
return(height);
}
uint64_t LP_smartbalance(struct iguana_info *coin)
{
cJSON *array,*item; char buf[512],*retstr; int32_t i,n; uint64_t valuesum,value;
valuesum = 0;
sprintf(buf,"[0, 99999999, [\"%s\"]]",coin->smartaddr);
retstr = bitcoind_passthru(coin->symbol,coin->serverport,coin->userpass,"listunspent","[]");
if ( retstr != 0 && retstr[0] != 0 )
{
array = cJSON_Parse(retstr);
if ( is_cJSON_Array(array) != 0 && (n= cJSON_GetArraySize(array)) > 0 )
{
for (i=0; i<n; i++)
{
item = jitem(array,i);
value = LP_value_extract(item,1);
valuesum += value;
}
}
free_json(array);
}
return(valuesum);
}
cJSON *LP_getmempool(char *symbol,char *coinaddr)
{
cJSON *array; struct iguana_info *coin;

Loading…
Cancel
Save