diff --git a/iguana/exchanges/LP_commands.c b/iguana/exchanges/LP_commands.c index abad115b0..5e8b4edc2 100644 --- a/iguana/exchanges/LP_commands.c +++ b/iguana/exchanges/LP_commands.c @@ -666,14 +666,14 @@ jpg(srcfile, destfile, power2=7, password, data="", required, ind=0)\n\ } if ( strcmp(method,"inventory") == 0 ) { - struct iguana_info *ptr; + struct iguana_info *ptr; int32_t num; if ( (ptr= LP_coinfind(coin)) != 0 ) { LP_address(ptr,ptr->smartaddr); if ( jint(argjson,"reset") != 0 ) { ptr->privkeydepth = 0; - LP_address_utxo_reset(ptr); + LP_address_utxo_reset(&num,ptr); LP_passphrase_init(jstr(argjson,"passphrase"),G.gui,G.netid,G.seednode); } if ( bits256_nonz(G.LP_privkey) != 0 ) @@ -687,7 +687,7 @@ jpg(srcfile, destfile, power2=7, password, data="", required, ind=0)\n\ //jadd(retjson,"alice",LP_inventory(coin)); //jadd(retjson,"bob",LP_inventory(coin,1)); //LP_smartutxos_push(ptr); - LP_address_utxo_reset(ptr); + LP_address_utxo_reset(&num,ptr); return(jprint(retjson,1)); } } diff --git a/iguana/exchanges/LP_nativeDEX.c b/iguana/exchanges/LP_nativeDEX.c index a5e473324..6ad01bd30 100644 --- a/iguana/exchanges/LP_nativeDEX.c +++ b/iguana/exchanges/LP_nativeDEX.c @@ -566,7 +566,8 @@ void LP_coinsloop(void *_coins) continue; if ( coin->did_addrutxo_reset == 0 ) { - LP_address_utxo_reset(coin); + int32_t num; + LP_address_utxo_reset(&num,coin); coin->did_addrutxo_reset = 1; } if ( coin->longestchain == 1 ) // special init value diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index 888586a7a..2613617b0 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -1446,7 +1446,7 @@ int32_t LP_tradecommand(void *ctx,char *myipaddr,int32_t pubsock,cJSON *argjson, char *LP_autobuy(void *ctx,char *myipaddr,int32_t mypubsock,char *base,char *rel,double maxprice,double relvolume,int32_t timeout,int32_t duration,char *gui,uint32_t nonce,bits256 destpubkey,uint32_t tradeid) { - uint64_t desttxfee,txfee; uint32_t lastnonce; int64_t bestsatoshis=0,destsatoshis; struct iguana_info *basecoin,*relcoin; struct LP_utxoinfo *autxo,B,A; struct LP_quoteinfo Q; bits256 pubkeys[100]; struct LP_address_utxo *utxos[4096]; int32_t maxiters=100,i,max=(int32_t)(sizeof(utxos)/sizeof(*utxos)); + uint64_t desttxfee,txfee; uint32_t lastnonce; int64_t bestsatoshis=0,destsatoshis; struct iguana_info *basecoin,*relcoin; struct LP_utxoinfo *autxo,B,A; struct LP_quoteinfo Q; bits256 pubkeys[100]; struct LP_address_utxo *utxos[4096]; int32_t num=0,maxiters=100,i,max=(int32_t)(sizeof(utxos)/sizeof(*utxos)); basecoin = LP_coinfind(base); relcoin = LP_coinfind(rel); if ( gui == 0 ) @@ -1491,7 +1491,8 @@ 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; - if ( LP_address_utxo_reset(relcoin) == 0 ) + LP_address_utxo_reset(&num,relcoin); + if ( num <= 1 ) { if ( time(NULL) > relcoin->lastautosplit+300 ) { diff --git a/iguana/exchanges/LP_transaction.c b/iguana/exchanges/LP_transaction.c index 4488da326..c429b78c9 100644 --- a/iguana/exchanges/LP_transaction.c +++ b/iguana/exchanges/LP_transaction.c @@ -1521,7 +1521,7 @@ char *LP_opreturndecrypt(void *ctx,char *symbol,bits256 utxotxid,char *passphras char *LP_withdraw(struct iguana_info *coin,cJSON *argjson) { static void *ctx; - int32_t broadcast,allocated_outputs=0,iter,i,utxovout,autofee,completed=0,maxV,numvins,numvouts,datalen,suppress_pubkeys; bits256 privkey; struct LP_address *ap; char changeaddr[64],vinaddr[64],str[65],*signret,*signedtx=0,*rawtx=0; struct vin_info *V; uint32_t locktime; cJSON *retjson,*item,*outputs,*vins=0,*txobj=0,*privkeys=0; struct iguana_msgtx msgtx; bits256 utxotxid,signedtxid; uint64_t txfee,newtxfee=10000; + int32_t broadcast,allocated_outputs=0,iter,i,num,utxovout,autofee,completed=0,maxV,numvins,numvouts,datalen,suppress_pubkeys; bits256 privkey; struct LP_address *ap; char changeaddr[64],vinaddr[64],str[65],*signret,*signedtx=0,*rawtx=0; struct vin_info *V; uint32_t locktime; cJSON *retjson,*item,*outputs,*vins=0,*txobj=0,*privkeys=0; struct iguana_msgtx msgtx; bits256 utxotxid,signedtxid; uint64_t txfee,newtxfee=10000; //printf("withdraw.%s %s\n",coin->symbol,jprint(argjson,0)); if ( coin->etomic[0] != 0 ) { @@ -1569,7 +1569,7 @@ char *LP_withdraw(struct iguana_info *coin,cJSON *argjson) V = malloc(maxV * sizeof(*V)); for (iter=0; iter<2; iter++) { - LP_address_utxo_reset(coin); + LP_address_utxo_reset(&num,coin); privkeys = cJSON_CreateArray(); vins = cJSON_CreateArray(); memset(V,0,sizeof(*V) * maxV); diff --git a/iguana/exchanges/LP_utxo.c b/iguana/exchanges/LP_utxo.c index 3e4197750..00f80f542 100644 --- a/iguana/exchanges/LP_utxo.c +++ b/iguana/exchanges/LP_utxo.c @@ -509,11 +509,12 @@ int32_t LP_address_utxoadd(int32_t skipsearch,uint32_t timestamp,char *debug,str return(retval); } -struct LP_address *LP_address_utxo_reset(struct iguana_info *coin) +struct LP_address *LP_address_utxo_reset(int32_t *nump,struct iguana_info *coin) { struct LP_address *ap; struct LP_address_utxo *up,*tmp; int32_t i,n,numconfs,m,vout,height; cJSON *array,*item,*txobj; bits256 zero; int64_t value; bits256 txid; uint32_t now; LP_address(coin,coin->smartaddr); memset(zero.bytes,0,sizeof(zero)); + *nump = 0; LP_listunspent_issue(coin->symbol,coin->smartaddr,2,zero,zero); if ( (ap= LP_addressfind(coin,coin->smartaddr)) == 0 ) { @@ -540,6 +541,7 @@ struct LP_address *LP_address_utxo_reset(struct iguana_info *coin) if ( (n= cJSON_GetArraySize(array)) > 0 ) { char str[65]; + *nump = n; for (i=m=0; isymbol); } - if ( n <= 1 ) - ap = 0; free_json(array); } portable_mutex_unlock(&coin->addressutxo_mutex);