diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index fcdea155f..888586a7a 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -1491,7 +1491,15 @@ char *LP_autobuy(void *ctx,char *myipaddr,int32_t mypubsock,char *base,char *rel memset(pubkeys,0,sizeof(pubkeys)); LP_txfees(&txfee,&desttxfee,base,rel); destsatoshis = SATOSHIDEN * relvolume + 2*desttxfee; - LP_address_utxo_reset(relcoin); + if ( LP_address_utxo_reset(relcoin) == 0 ) + { + if ( time(NULL) > relcoin->lastautosplit+300 ) + { + relcoin->lastautosplit = (uint32_t)time(NULL); + return(LP_autosplit(relcoin)); + } + return(clonestr("{\"error\":\"not enough utxo, please make more deposits\"}")); + } autxo = 0; for (i=0; ietomic[0] == 0 ) + { + if ( coin->electrum != 0 ) + balance = LP_unspents_load(coin->symbol,coin->smartaddr); + else balance = LP_RTsmartbalance(coin); + if ( balance >= 0.001+coin->txfee ) + { + halfval = ((balance - coin->txfee - 0.001) / 100) * 45; + argjson = cJSON_CreateObject(); + outputs = cJSON_CreateArray(); + item = cJSON_CreateObject(); + jaddnum(item,coin->smartaddr,dstr(halfval)); + jaddi(outputs,item); + item = cJSON_CreateObject(); + jaddnum(item,coin->smartaddr,dstr(halfval)); + jaddi(outputs,item); + item = cJSON_CreateObject(); + jaddnum(item,coin->smartaddr,dstr(balance - 2*halfval)); + jaddi(outputs,item); + jadd(argjson,"outputs",outputs); + jaddnum(argjson,"broadcast",1); + printf("autosplit.(%s)\n",jprint(argjson,0)); + retstr = LP_withdraw(coin,argjson); + free_json(argjson); + return(retstr); + } else return(clonestr("{\"error\":\"less than 0.0011 in balance\"}")); + } + return(clonestr("{\"error\":\"couldnt autosplit\"}")); +} + #ifndef NOTETOMIC char *LP_eth_withdraw(struct iguana_info *coin,cJSON *argjson) @@ -1685,6 +1718,8 @@ char *LP_eth_withdraw(struct iguana_info *coin,cJSON *argjson) #endif + + int32_t basilisk_rawtx_gen(void *ctx,char *str,uint32_t swapstarted,uint8_t *pubkey33,int32_t iambob,int32_t lockinputs,struct basilisk_rawtx *rawtx,uint32_t locktime,uint8_t *script,int32_t scriptlen,int64_t txfee,int32_t minconf,int32_t delay,bits256 privkey,uint8_t *changermd160,char *vinaddr) { struct iguana_info *coin; int32_t len,retval=-1; char *retstr,*hexstr; cJSON *argjson,*outputs,*item,*retjson,*obj; diff --git a/iguana/exchanges/LP_utxo.c b/iguana/exchanges/LP_utxo.c index 9b0c10c0a..65e272f5e 100644 --- a/iguana/exchanges/LP_utxo.c +++ b/iguana/exchanges/LP_utxo.c @@ -538,7 +538,7 @@ struct LP_address *LP_address_utxo_reset(struct iguana_info *coin) portable_mutex_unlock(&coin->addrmutex); portable_mutex_unlock(&LP_gcmutex); now = (uint32_t)time(NULL); - if ( (n= cJSON_GetArraySize(array)) > 0 ) + if ( (n= cJSON_GetArraySize(array)) > 1 ) { char str[65]; for (i=m=0; isymbol); - } + } else ap = 0; free_json(array); } portable_mutex_unlock(&coin->addressutxo_mutex);