Browse Source

estimatesmartfee

patch-3
jl777 7 years ago
parent
commit
fa29d5d1fe
  1. 2
      iguana/exchanges/LP_include.h
  2. 15
      iguana/exchanges/LP_rpc.c

2
iguana/exchanges/LP_include.h

@ -305,7 +305,7 @@ struct iguana_info
int32_t numutxos,notarized,longestchain,firstrefht,firstscanht,lastscanht,height; uint16_t busport,did_addrutxo_reset;
uint32_t txversion,dPoWtime,lastresetutxo,loadedcache,electrumlist,lastunspent,importedprivkey,lastpushtime,lastutxosync,addr_listunspent_requested,lastutxos,updaterate,counter,inactive,lastmempool,lastgetinfo,ratetime,heighttime,lastmonitor,obooktime;
uint8_t pubtype,p2shtype,isPoS,wiftype,wiftaddr,taddr,noimportprivkey_flag,userconfirms,isassetchain,maxconfirms;
char symbol[128],smartaddr[64],userpass[1024],serverport[128],instantdex_address[64];
char symbol[128],smartaddr[64],userpass[1024],serverport[128],instantdex_address[64],estimatefeestr[32];
// portfolio
double price_kmd,force,perc,goal,goalperc,relvolume,rate;
void *electrum; void *ctx;

15
iguana/exchanges/LP_rpc.c

@ -602,14 +602,17 @@ cJSON *LP_importprivkey(char *symbol,char *wifstr,char *label,int32_t flag)
double _LP_getestimatedrate(struct iguana_info *coin)
{
char buf[512],*retstr=0; int32_t numblocks; cJSON *errjson,*retjson; double rate = 0.00000020;
char buf[512],*retstr=0; int32_t numblocks,err=0; cJSON *errjson,*retjson; double rate = 0.00000020;
if ( coin->rate < 0. || time(NULL) > coin->ratetime+30 )
{
if ( coin->estimatefeestr[0] == 0 )
strcpy(coin->estimatefeestr,"estimatefee");
numblocks = strcmp(coin->symbol,"BTC") == 0 ? 6 : 2;
again:
if ( coin->electrum == 0 )
{
sprintf(buf,"[%d]",numblocks);
retstr = LP_apicall(coin,"estimatefee",buf);
retstr = LP_apicall(coin,coin->estimatefeestr,buf);
}
else
{
@ -621,7 +624,10 @@ double _LP_getestimatedrate(struct iguana_info *coin)
if ( retstr[0] == '{' && (errjson= cJSON_Parse(retstr)) != 0 )
{
if ( jobj(errjson,"error") != 0 )
{
rate = 0.;
err++;
}
free_json(errjson);
}
else if ( retstr[0] != '-' )
@ -638,6 +644,11 @@ double _LP_getestimatedrate(struct iguana_info *coin)
coin->ratetime = (uint32_t)time(NULL);
}
free(retstr);
if ( err == 1 && coin->electrum == 0 && strcmp("BTC",coin->symbol) == 0 )
{
strcpy(coin->estimatefeestr,"estimatesmartfee");
goto again;
}
} else rate = coin->rate;
} else rate = coin->rate;
return(rate);

Loading…
Cancel
Save