From 4618855b8602bf81d48c10cc8ba0e58f8695d3b7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 30 Apr 2018 13:37:11 +0300 Subject: [PATCH] Retry initial impogrtaddress to avoid timing issue --- iguana/exchanges/LP_rpc.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/iguana/exchanges/LP_rpc.c b/iguana/exchanges/LP_rpc.c index c848225db..2c7763930 100644 --- a/iguana/exchanges/LP_rpc.c +++ b/iguana/exchanges/LP_rpc.c @@ -649,7 +649,7 @@ int32_t LP_importaddress(char *symbol,char *address) cJSON *LP_importprivkey(char *symbol,char *wifstr,char *label,int32_t flag) { static void *ctx; - char buf[512],address[64]; cJSON *retjson; struct iguana_info *coin; int32_t doneflag = 0; + char buf[512],address[64]; cJSON *retjson; struct iguana_info *coin; int32_t i,doneflag = 0; if ( symbol == 0 || symbol[0] == 0 ) return(cJSON_Parse("{\"error\":\"null symbol\"}")); coin = LP_coinfind(symbol); @@ -663,9 +663,16 @@ cJSON *LP_importprivkey(char *symbol,char *wifstr,char *label,int32_t flag) #ifdef LP_DONT_IMPORTPRIVKEY if ( LP_importaddress(symbol,address) < 0 ) { - printf("%s importaddress %s from %s failed, isvalid.%d\n",symbol,address,wifstr,bitcoin_validaddress(symbol,coin->taddr,coin->pubtype,coin->p2shtype,address)); - return(cJSON_Parse("{\"error\":\"couldnt import\"}")); - } else return(cJSON_Parse("{\"result\":\"success\"}")); + for (i=0; i<3; i++) + { + printf("%s importaddress %s from %s failed, isvalid.%d\n",symbol,address,wifstr,bitcoin_validaddress(symbol,coin->taddr,coin->pubtype,coin->p2shtype,address)); + if ( LP_importaddress(symbol,address) >= 0 ) + break; + } + if ( i == 3 ) + return(cJSON_Parse("{\"error\":\"couldnt import\"}")); + } + return(cJSON_Parse("{\"result\":\"success\"}")); #endif if ( (retjson= LP_validateaddress(symbol,address)) != 0 ) {