jl777 7 years ago
parent
commit
f10cbf5eea
  1. 39
      iguana/exchanges/LP_rpc.c

39
iguana/exchanges/LP_rpc.c

@ -598,28 +598,31 @@ int32_t LP_importaddress(char *symbol,char *address)
double _LP_getestimatedrate(struct iguana_info *coin) double _LP_getestimatedrate(struct iguana_info *coin)
{ {
char buf[512],*retstr; cJSON *errjson; double rate = 0.00000020; char buf[512],*retstr; cJSON *errjson; double rate = 0.00000020;
sprintf(buf,"[%d]",strcmp(coin->symbol,"BTC") == 0 ? 6 : 2); if ( coin->rate == 0. || time(NULL) > time(NULL) > coin->ratetime+6 )
if ( (retstr= LP_apicall(coin,coin->electrum==0?"estimatefee" : "blockchain.estimatefee",buf)) != 0 )
{ {
if ( retstr[0] == '{' && (errjson= cJSON_Parse(retstr)) != 0 ) sprintf(buf,"[%d]",strcmp(coin->symbol,"BTC") == 0 ? 6 : 2);
if ( (retstr= LP_apicall(coin,coin->electrum==0?"estimatefee" : "blockchain.estimatefee",buf)) != 0 )
{ {
if ( jobj(errjson,"error") != 0 ) if ( retstr[0] == '{' && (errjson= cJSON_Parse(retstr)) != 0 )
rate = 0.; {
free_json(errjson); if ( jobj(errjson,"error") != 0 )
} rate = 0.;
else if ( retstr[0] != '-' ) free_json(errjson);
{ }
rate = atof(retstr) / 1024.; else if ( retstr[0] != '-' )
if ( rate < 0.00000020 ) {
rate = 0.00000020; rate = atof(retstr) / 1024.;
rate *= 1.25; if ( rate < 0.00000020 )
if ( coin->electrum != 0 ) rate = 0.00000020;
rate *= 1.25; rate *= 1.25;
coin->rate = rate; if ( coin->electrum != 0 )
printf("t%u estimated rate.(%s) (%s) -> %.8f %.8f\n",coin->ratetime,coin->symbol,retstr,rate,coin->rate); rate *= 1.25;
coin->ratetime = (uint32_t)time(NULL); coin->rate = rate;
printf("t%u estimated rate.(%s) (%s) -> %.8f %.8f\n",coin->ratetime,coin->symbol,retstr,rate,coin->rate);
coin->ratetime = (uint32_t)time(NULL);
}
free(retstr);
} }
free(retstr);
} }
return(rate); return(rate);
} }

Loading…
Cancel
Save