From feeaab54643fbb8f0baa13f12ec23cdcd2960986 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 24 Nov 2017 13:41:54 +0400 Subject: [PATCH 01/12] Test --- iguana/exchanges/LP_commands.c | 1 + iguana/exchanges/LP_nativeDEX.c | 5 +---- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/iguana/exchanges/LP_commands.c b/iguana/exchanges/LP_commands.c index b2b9e7026..310de97ae 100644 --- a/iguana/exchanges/LP_commands.c +++ b/iguana/exchanges/LP_commands.c @@ -304,6 +304,7 @@ zeroconf_claim(address, expiration=0)\n\ struct LP_address *ap; char *coinaddr; if ( (ptr= LP_coinsearch("KMD")) != 0 && (coinaddr= jstr(argjson,"address")) != 0 ) { + LP_zeroconf_deposits(ptr); if ( (ap= LP_addressfind(ptr,coinaddr)) != 0 ) { retjson = cJSON_CreateObject(); diff --git a/iguana/exchanges/LP_nativeDEX.c b/iguana/exchanges/LP_nativeDEX.c index aced90d80..abbc777a5 100644 --- a/iguana/exchanges/LP_nativeDEX.c +++ b/iguana/exchanges/LP_nativeDEX.c @@ -17,20 +17,17 @@ // LP_nativeDEX.c // marketmaker // -// feature requests: // alice waiting for bestprice -// USD paxprice based USDvalue in portfolio // cancel bid/ask // delay swap credit back until notarization // electrum dynamic trust over 1000 // https://github.com/bitcoin/bips/blob/master/bip-0143.mediawiki for signing BCH/BTG // -// bugs, validations: // portfolio value based on ask? // verify encrypted destpubkey, broadcast:0 setprice +// USD paxprice based USDvalue in portfolio // improve critical section detection when parallel trades -// previously, it used to show amount, kmd equiv, perc // dPoW security -> 4: KMD notarized, 5: BTC notarized, after next notary elections // bigendian architectures need to use little endian for sighash calcs From 53f20fe033ddacc213a3cebc463a9e2272320d9d Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 24 Nov 2017 13:50:24 +0400 Subject: [PATCH 02/12] Test --- iguana/exchanges/LP_commands.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/iguana/exchanges/LP_commands.c b/iguana/exchanges/LP_commands.c index 310de97ae..618aec6b0 100644 --- a/iguana/exchanges/LP_commands.c +++ b/iguana/exchanges/LP_commands.c @@ -631,15 +631,18 @@ zeroconf_claim(address, expiration=0)\n\ else if ( strcmp(method,"tradestatus") == 0 ) { - bits256 zero; cJSON *tmpjson; + bits256 zero; cJSON *tmpjson; struct LP_quoteinfo Q; + LP_tradecommand_log(argjson); + LP_quoteparse(&Q,argjson); + LP_requestinit(&Q.R,Q.srchash,Q.desthash,Q.srccoin,Q.satoshis-Q.txfee,Q.destcoin,Q.destsatoshis-Q.desttxfee,Q.timestamp,Q.quotetime,0); LP_tradecommand_log(argjson); - //printf("GOT TRADESTATUS! %s\n",jprint(argjson,0)); if ( LP_statslog_parse() > 0 ) { memset(zero.bytes,0,sizeof(zero)); if ( (tmpjson= LP_statslog_disp(2000000000,2000000000,"",zero,0,0))) // pending swaps free_json(tmpjson); } + printf("%-4d (%-10u %10u) %12s id.%22llu %5s/%-5s %12.8f -> %11.8f price %11.8f | RT.%d %d\n",(uint32_t)time(NULL) % 3600,Q.R.requestid,Q.R.quoteid,method,(long long)Q.aliceid,Q.srccoin,Q.destcoin,dstr(Q.satoshis),dstr(Q.destsatoshis),(double)Q.destsatoshis/Q.satoshis,LP_RTcount,LP_swapscount); retstr = clonestr("{\"result\":\"success\"}"); } else if ( strcmp(method,"wantnotify") == 0 ) From a7616b2e7224ef4ab0fd38f3ca6a18d091053af4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 24 Nov 2017 13:59:55 +0400 Subject: [PATCH 03/12] Test --- iguana/exchanges/LP_transaction.c | 2 +- iguana/exchanges/dynamictrust | 3 +++ iguana/exchanges/install | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) create mode 100755 iguana/exchanges/dynamictrust diff --git a/iguana/exchanges/LP_transaction.c b/iguana/exchanges/LP_transaction.c index 99e84135e..a7e70ab5f 100644 --- a/iguana/exchanges/LP_transaction.c +++ b/iguana/exchanges/LP_transaction.c @@ -1126,7 +1126,7 @@ int32_t LP_vins_select(void *ctx,struct iguana_info *coin,int64_t *totalp,int64_ if ( LP_validSPV(coin->symbol,coin->smartaddr,up->U.txid,up->U.vout) < 0 ) continue; } - if ( LP_allocated(up->U.txid,up->U.vout) != 0 ) + if ( bits256_cmp(utxotxid,up->U.txid) != 0 && LP_allocated(up->U.txid,up->U.vout) != 0 ) continue; up->spendheight = 1; total += up->U.value; diff --git a/iguana/exchanges/dynamictrust b/iguana/exchanges/dynamictrust new file mode 100755 index 000000000..0a22e9fd9 --- /dev/null +++ b/iguana/exchanges/dynamictrust @@ -0,0 +1,3 @@ +#!/bin/bash +source userpass +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"dynamictrust\",\"address\":\"RMfQwu5ey23eWJ4as2ckd8dqsQJwo836ny\"}" diff --git a/iguana/exchanges/install b/iguana/exchanges/install index f938704ac..d7810e3c5 100755 --- a/iguana/exchanges/install +++ b/iguana/exchanges/install @@ -1,5 +1,5 @@ #!/bin/bash -cp tradesarray claim deposit deposit1 invreset sendrawtransaction processfiles stop millis mnzservers bot_buy bot_list bot_statuslist bot_pause bot_resume bot_sell bot_settings bot_status bot_stop guistats pubkeystats pendings coinswaps baserelswaps setpassphrase notarizations getrawtransaction parselog statsdisp m_js trust trusted setconfirms balance listunspent electrum snapshot_balance snapshot_loop secretaddresses dividends snapshot goals goal portfolio autoprice deletemessages getmessages debug buy sell bestfit orderbook client run_osx client_osx run coins disable enable myprice myprices getcoins getpeers getpeersIP getprices help inv setprice status ../dexscripts +cp dynamictrust tradesarray claim deposit deposit1 invreset sendrawtransaction processfiles stop millis mnzservers bot_buy bot_list bot_statuslist bot_pause bot_resume bot_sell bot_settings bot_status bot_stop guistats pubkeystats pendings coinswaps baserelswaps setpassphrase notarizations getrawtransaction parselog statsdisp m_js trust trusted setconfirms balance listunspent electrum snapshot_balance snapshot_loop secretaddresses dividends snapshot goals goal portfolio autoprice deletemessages getmessages debug buy sell bestfit orderbook client run_osx client_osx run coins disable enable myprice myprices getcoins getpeers getpeersIP getprices help inv setprice status ../dexscripts cp coins.json .. cd ../dexscripts #cp ../exchanges/passphrase ../exchanges/userpass . From e7f86ecb39da9e07e1570653e2d29958e272c8ca Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 24 Nov 2017 14:08:54 +0400 Subject: [PATCH 04/12] Test --- iguana/exchanges/LP_commands.c | 1 + iguana/exchanges/LP_stats.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/iguana/exchanges/LP_commands.c b/iguana/exchanges/LP_commands.c index 618aec6b0..978fb05b9 100644 --- a/iguana/exchanges/LP_commands.c +++ b/iguana/exchanges/LP_commands.c @@ -304,6 +304,7 @@ zeroconf_claim(address, expiration=0)\n\ struct LP_address *ap; char *coinaddr; if ( (ptr= LP_coinsearch("KMD")) != 0 && (coinaddr= jstr(argjson,"address")) != 0 ) { + LP_statslog_parse(); LP_zeroconf_deposits(ptr); if ( (ap= LP_addressfind(ptr,coinaddr)) != 0 ) { diff --git a/iguana/exchanges/LP_stats.c b/iguana/exchanges/LP_stats.c index 9c3dd87cd..ffb8d0c8f 100644 --- a/iguana/exchanges/LP_stats.c +++ b/iguana/exchanges/LP_stats.c @@ -84,6 +84,7 @@ void LP_statslog_parseline(cJSON *lineobj) int32_t LP_statslog_parse() { static long lastpos; FILE *fp; char line[8192]; cJSON *lineobj; int32_t n = 0; + portable_mutex_lock(&LP_logmutex); if ( (fp= fopen(LP_STATSLOG_FNAME,"rb")) != 0 ) { if ( lastpos > 0 ) @@ -110,6 +111,7 @@ int32_t LP_statslog_parse() } fclose(fp); } + portable_mutex_unlock(&LP_logmutex); return(n); } From db520a5911905c97b53f4cf3dd062f052eab9956 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 24 Nov 2017 14:11:28 +0400 Subject: [PATCH 05/12] Test --- iguana/exchanges/LP_nativeDEX.c | 3 ++- iguana/exchanges/LP_stats.c | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/iguana/exchanges/LP_nativeDEX.c b/iguana/exchanges/LP_nativeDEX.c index abbc777a5..03e143e0b 100644 --- a/iguana/exchanges/LP_nativeDEX.c +++ b/iguana/exchanges/LP_nativeDEX.c @@ -86,7 +86,7 @@ void LP_millistats_update(struct LP_millistats *mp) } #include "LP_include.h" -portable_mutex_t LP_peermutex,LP_UTXOmutex,LP_utxomutex,LP_commandmutex,LP_cachemutex,LP_swaplistmutex,LP_forwardmutex,LP_pubkeymutex,LP_networkmutex,LP_psockmutex,LP_coinmutex,LP_messagemutex,LP_portfoliomutex,LP_electrummutex,LP_butxomutex,LP_reservedmutex,LP_nanorecvsmutex,LP_tradebotsmutex,LP_gcmutex,LP_inusemutex,LP_cJSONmutex,LP_logmutex; +portable_mutex_t LP_peermutex,LP_UTXOmutex,LP_utxomutex,LP_commandmutex,LP_cachemutex,LP_swaplistmutex,LP_forwardmutex,LP_pubkeymutex,LP_networkmutex,LP_psockmutex,LP_coinmutex,LP_messagemutex,LP_portfoliomutex,LP_electrummutex,LP_butxomutex,LP_reservedmutex,LP_nanorecvsmutex,LP_tradebotsmutex,LP_gcmutex,LP_inusemutex,LP_cJSONmutex,LP_logmutex,LP_statslogmutex; int32_t LP_canbind; char *Broadcaststr,*Reserved_msgs[2][1000]; int32_t num_Reserved_msgs[2],max_Reserved_msgs[2]; @@ -1124,6 +1124,7 @@ void LPinit(uint16_t myport,uint16_t mypullport,uint16_t mypubport,uint16_t mybu portable_mutex_init(&LP_tradebotsmutex); portable_mutex_init(&LP_cJSONmutex); portable_mutex_init(&LP_logmutex); + portable_mutex_init(&LP_statslogmutex); myipaddr = clonestr("127.0.0.1"); #ifndef _WIN32 #ifndef FROM_JS diff --git a/iguana/exchanges/LP_stats.c b/iguana/exchanges/LP_stats.c index ffb8d0c8f..855a87ff4 100644 --- a/iguana/exchanges/LP_stats.c +++ b/iguana/exchanges/LP_stats.c @@ -30,7 +30,7 @@ static uint32_t LP_requests,LP_reserveds,LP_connects,LP_connecteds,LP_tradestatu void LP_tradecommand_log(cJSON *argjson) { static FILE *logfp; char *jsonstr; - portable_mutex_lock(&LP_logmutex); + portable_mutex_lock(&LP_statslogmutex); if ( logfp == 0 ) { if ( (logfp= fopen(LP_STATSLOG_FNAME,"rb+")) != 0 ) @@ -44,7 +44,7 @@ void LP_tradecommand_log(cJSON *argjson) free(jsonstr); fflush(logfp); } - portable_mutex_unlock(&LP_logmutex); + portable_mutex_unlock(&LP_statslogmutex); } void LP_statslog_parseline(cJSON *lineobj) From eca316822d9938fbc42e79a1b3842e9088ef07ec Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 24 Nov 2017 14:13:40 +0400 Subject: [PATCH 06/12] Test --- iguana/exchanges/LP_commands.c | 1 - 1 file changed, 1 deletion(-) diff --git a/iguana/exchanges/LP_commands.c b/iguana/exchanges/LP_commands.c index 978fb05b9..618aec6b0 100644 --- a/iguana/exchanges/LP_commands.c +++ b/iguana/exchanges/LP_commands.c @@ -304,7 +304,6 @@ zeroconf_claim(address, expiration=0)\n\ struct LP_address *ap; char *coinaddr; if ( (ptr= LP_coinsearch("KMD")) != 0 && (coinaddr= jstr(argjson,"address")) != 0 ) { - LP_statslog_parse(); LP_zeroconf_deposits(ptr); if ( (ap= LP_addressfind(ptr,coinaddr)) != 0 ) { From 5b031772fa2af7b3e9a6781dce0b2d53fbfe3bef Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 24 Nov 2017 14:19:09 +0400 Subject: [PATCH 07/12] Test --- iguana/exchanges/LP_ordermatch.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index 78ba7552f..ee64b03de 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -495,8 +495,11 @@ int32_t LP_connectstartbob(void *ctx,int32_t pubsock,cJSON *argjson,char *base,c LP_reserved_msg(1,base,rel,qp->desthash,jprint(retjson,0)); bits256 zero; memset(zero.bytes,0,sizeof(zero)); + sleep(1); LP_reserved_msg(1,base,rel,zero,jprint(retjson,0)); - //LP_reserved_msg(0,base,rel,zero,jprint(retjson,0)); + LP_reserved_msg(0,base,rel,zero,jprint(retjson,0)); + sleep(1); + LP_reserved_msg(0,base,rel,zero,jprint(retjson,0)); free_json(retjson); retval = 0; } else printf("error launching swaploop\n"); From f1cbd668fdbea386f8616430a265a70baae24bad Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 24 Nov 2017 14:21:37 +0400 Subject: [PATCH 08/12] Test --- iguana/exchanges/LP_commands.c | 13 ------------- iguana/exchanges/LP_ordermatch.c | 3 --- 2 files changed, 16 deletions(-) diff --git a/iguana/exchanges/LP_commands.c b/iguana/exchanges/LP_commands.c index 618aec6b0..d09217f51 100644 --- a/iguana/exchanges/LP_commands.c +++ b/iguana/exchanges/LP_commands.c @@ -109,7 +109,6 @@ myprice(base, rel)\n\ enable(coin)\n\ disable(coin)\n\ notarizations(coin)\n\ -parselog()\n\ statsdisp(starttime=0, endtime=0, gui="", pubkey="", base="", rel="")\n\ tradesarray(base, rel, starttime=-timescale*1024, endtime=, timescale=60) -> [timestamp, high, low, open, close, relvolume, basevolume, aveprice, numtrades]\n\ pricearray(base, rel, starttime=0, endtime=0, timescale=60) -> [timestamp, avebid, aveask, highbid, lowask]\n\ @@ -269,12 +268,6 @@ zeroconf_claim(address, expiration=0)\n\ { return(LP_portfolio()); } - else if ( strcmp(method,"parselog") == 0 ) - { - bits256 zero; - memset(zero.bytes,0,sizeof(zero)); - return(jprint(LP_statslog_disp(2000000000,2000000000,"",zero,0,0),1)); - } else if ( strcmp(method,"statsdisp") == 0 ) { return(jprint(LP_statslog_disp(juint(argjson,"starttime"),juint(argjson,"endtime"),jstr(argjson,"gui"),jbits256(argjson,"pubkey"),jstr(argjson,"base"),jstr(argjson,"rel")),1)); @@ -636,12 +629,6 @@ zeroconf_claim(address, expiration=0)\n\ LP_quoteparse(&Q,argjson); LP_requestinit(&Q.R,Q.srchash,Q.desthash,Q.srccoin,Q.satoshis-Q.txfee,Q.destcoin,Q.destsatoshis-Q.desttxfee,Q.timestamp,Q.quotetime,0); LP_tradecommand_log(argjson); - if ( LP_statslog_parse() > 0 ) - { - memset(zero.bytes,0,sizeof(zero)); - if ( (tmpjson= LP_statslog_disp(2000000000,2000000000,"",zero,0,0))) // pending swaps - free_json(tmpjson); - } printf("%-4d (%-10u %10u) %12s id.%22llu %5s/%-5s %12.8f -> %11.8f price %11.8f | RT.%d %d\n",(uint32_t)time(NULL) % 3600,Q.R.requestid,Q.R.quoteid,method,(long long)Q.aliceid,Q.srccoin,Q.destcoin,dstr(Q.satoshis),dstr(Q.destsatoshis),(double)Q.destsatoshis/Q.satoshis,LP_RTcount,LP_swapscount); retstr = clonestr("{\"result\":\"success\"}"); } diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index ee64b03de..4a5617469 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -495,11 +495,8 @@ int32_t LP_connectstartbob(void *ctx,int32_t pubsock,cJSON *argjson,char *base,c LP_reserved_msg(1,base,rel,qp->desthash,jprint(retjson,0)); bits256 zero; memset(zero.bytes,0,sizeof(zero)); - sleep(1); LP_reserved_msg(1,base,rel,zero,jprint(retjson,0)); LP_reserved_msg(0,base,rel,zero,jprint(retjson,0)); - sleep(1); - LP_reserved_msg(0,base,rel,zero,jprint(retjson,0)); free_json(retjson); retval = 0; } else printf("error launching swaploop\n"); From d060c7ce2934159a851b78112c6948d3bf279f30 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 24 Nov 2017 14:33:00 +0400 Subject: [PATCH 09/12] Test --- iguana/exchanges/LP_commands.c | 4 ++-- iguana/exchanges/LP_nativeDEX.c | 7 ++++++- iguana/exchanges/dynamictrust | 3 --- iguana/exchanges/install | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) delete mode 100755 iguana/exchanges/dynamictrust diff --git a/iguana/exchanges/LP_commands.c b/iguana/exchanges/LP_commands.c index d09217f51..c122ff233 100644 --- a/iguana/exchanges/LP_commands.c +++ b/iguana/exchanges/LP_commands.c @@ -292,7 +292,7 @@ zeroconf_claim(address, expiration=0)\n\ return(basilisk_swapentries(base,rel,jint(argjson,"limit"))); else return(basilisk_swaplist(0,0)); } - else if ( strcmp(method,"dynamictrust") == 0 ) + /*else if ( strcmp(method,"dynamictrust") == 0 ) { struct LP_address *ap; char *coinaddr; if ( (ptr= LP_coinsearch("KMD")) != 0 && (coinaddr= jstr(argjson,"address")) != 0 ) @@ -308,7 +308,7 @@ zeroconf_claim(address, expiration=0)\n\ } } return(clonestr("{\"error\":\"cant find address\"}")); - } + }*/ else if ( (retstr= LP_istradebots_command(ctx,pubsock,method,argjson)) != 0 ) return(retstr); if ( base[0] != 0 && rel[0] != 0 ) diff --git a/iguana/exchanges/LP_nativeDEX.c b/iguana/exchanges/LP_nativeDEX.c index 03e143e0b..9533d7199 100644 --- a/iguana/exchanges/LP_nativeDEX.c +++ b/iguana/exchanges/LP_nativeDEX.c @@ -30,7 +30,12 @@ // improve critical section detection when parallel trades // dPoW security -> 4: KMD notarized, 5: BTC notarized, after next notary elections // bigendian architectures need to use little endian for sighash calcs - +// dont change error messages: +// if (enable_electrum_coin_output_data.error == 'couldnt find coin locally installed') { //{error: "couldnt find coin locally installed", coin: "BTC"} +//if (enable_native_coin_output_data.error == 'couldnt find coin locally installed') { //{error: "couldnt find coin locally installed", coin: "BTC"} +// if (!data.error === true && data.error !== 'coin is disabled') { +// if (bot_output_data.error == 'not enough funds') { + #include long LP_cjson_allocated,LP_cjson_total,LP_cjson_count; diff --git a/iguana/exchanges/dynamictrust b/iguana/exchanges/dynamictrust deleted file mode 100755 index 0a22e9fd9..000000000 --- a/iguana/exchanges/dynamictrust +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -source userpass -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"dynamictrust\",\"address\":\"RMfQwu5ey23eWJ4as2ckd8dqsQJwo836ny\"}" diff --git a/iguana/exchanges/install b/iguana/exchanges/install index d7810e3c5..f938704ac 100755 --- a/iguana/exchanges/install +++ b/iguana/exchanges/install @@ -1,5 +1,5 @@ #!/bin/bash -cp dynamictrust tradesarray claim deposit deposit1 invreset sendrawtransaction processfiles stop millis mnzservers bot_buy bot_list bot_statuslist bot_pause bot_resume bot_sell bot_settings bot_status bot_stop guistats pubkeystats pendings coinswaps baserelswaps setpassphrase notarizations getrawtransaction parselog statsdisp m_js trust trusted setconfirms balance listunspent electrum snapshot_balance snapshot_loop secretaddresses dividends snapshot goals goal portfolio autoprice deletemessages getmessages debug buy sell bestfit orderbook client run_osx client_osx run coins disable enable myprice myprices getcoins getpeers getpeersIP getprices help inv setprice status ../dexscripts +cp tradesarray claim deposit deposit1 invreset sendrawtransaction processfiles stop millis mnzservers bot_buy bot_list bot_statuslist bot_pause bot_resume bot_sell bot_settings bot_status bot_stop guistats pubkeystats pendings coinswaps baserelswaps setpassphrase notarizations getrawtransaction parselog statsdisp m_js trust trusted setconfirms balance listunspent electrum snapshot_balance snapshot_loop secretaddresses dividends snapshot goals goal portfolio autoprice deletemessages getmessages debug buy sell bestfit orderbook client run_osx client_osx run coins disable enable myprice myprices getcoins getpeers getpeersIP getprices help inv setprice status ../dexscripts cp coins.json .. cd ../dexscripts #cp ../exchanges/passphrase ../exchanges/userpass . From 2cfb57877addfaa028b27c14b055a07629c35bf7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 24 Nov 2017 14:35:06 +0400 Subject: [PATCH 10/12] Test --- iguana/exchanges/LP_utxo.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_utxo.c b/iguana/exchanges/LP_utxo.c index d0c26c788..6669963be 100644 --- a/iguana/exchanges/LP_utxo.c +++ b/iguana/exchanges/LP_utxo.c @@ -419,7 +419,7 @@ int32_t LP_address_utxoadd(uint32_t timestamp,char *debug,struct iguana_info *co struct LP_address *LP_address_utxo_reset(struct iguana_info *coin) { - struct LP_address *ap; struct LP_address_utxo *up,*tmp; int32_t i,n,vout,height; cJSON *array,*item; int64_t value; bits256 txid; uint32_t now; + struct LP_address *ap; struct LP_address_utxo *up,*tmp; int32_t i,n,vout,height; cJSON *array,*item,*txobj; int64_t value; bits256 txid; uint32_t now; LP_address(coin,coin->smartaddr); LP_listunspent_issue(coin->symbol,coin->smartaddr,2); if ( (ap= LP_addressfind(coin,coin->smartaddr)) == 0 ) @@ -448,6 +448,9 @@ struct LP_address *LP_address_utxo_reset(struct iguana_info *coin) //{"tx_hash":"38d1b7c73015e1b1d6cb7fc314cae402a635b7d7ea294970ab857df8777a66f4","tx_pos":0,"height":577975,"value":238700} item = jitem(array,i); value = LP_listunspent_parseitem(coin,&txid,&vout,&height,item); + if ( (txobj= LP_gettxout(coin->symbol,coin->symbol,txid,vout)) == 0 ) + continue; + else free_json(txobj); LP_address_utxoadd(now,"withdraw",coin,coin->smartaddr,txid,vout,value,height,-1); if ( (up= LP_address_utxofind(coin,coin->smartaddr,txid,vout)) == 0 ) printf("couldnt find just added %s/%d ht.%d %.8f\n",bits256_str(str,txid),vout,height,dstr(value)); From 3cf18b518be575946a6453a88353a8d4a1fc7525 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 24 Nov 2017 14:39:35 +0400 Subject: [PATCH 11/12] Test --- iguana/exchanges/LP_stats.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iguana/exchanges/LP_stats.c b/iguana/exchanges/LP_stats.c index 855a87ff4..8c8534153 100644 --- a/iguana/exchanges/LP_stats.c +++ b/iguana/exchanges/LP_stats.c @@ -30,7 +30,7 @@ static uint32_t LP_requests,LP_reserveds,LP_connects,LP_connecteds,LP_tradestatu void LP_tradecommand_log(cJSON *argjson) { static FILE *logfp; char *jsonstr; - portable_mutex_lock(&LP_statslogmutex); + //portable_mutex_lock(&LP_statslogmutex); if ( logfp == 0 ) { if ( (logfp= fopen(LP_STATSLOG_FNAME,"rb+")) != 0 ) @@ -44,7 +44,7 @@ void LP_tradecommand_log(cJSON *argjson) free(jsonstr); fflush(logfp); } - portable_mutex_unlock(&LP_statslogmutex); + //portable_mutex_unlock(&LP_statslogmutex); } void LP_statslog_parseline(cJSON *lineobj) From 4cdd33ccd8a4bf91db2ff89ec1df1d466edb9059 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 24 Nov 2017 14:44:28 +0400 Subject: [PATCH 12/12] Test --- iguana/exchanges/LP_stats.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/iguana/exchanges/LP_stats.c b/iguana/exchanges/LP_stats.c index 8c8534153..f2f9cf13b 100644 --- a/iguana/exchanges/LP_stats.c +++ b/iguana/exchanges/LP_stats.c @@ -30,7 +30,6 @@ static uint32_t LP_requests,LP_reserveds,LP_connects,LP_connecteds,LP_tradestatu void LP_tradecommand_log(cJSON *argjson) { static FILE *logfp; char *jsonstr; - //portable_mutex_lock(&LP_statslogmutex); if ( logfp == 0 ) { if ( (logfp= fopen(LP_STATSLOG_FNAME,"rb+")) != 0 ) @@ -44,7 +43,6 @@ void LP_tradecommand_log(cJSON *argjson) free(jsonstr); fflush(logfp); } - //portable_mutex_unlock(&LP_statslogmutex); } void LP_statslog_parseline(cJSON *lineobj) @@ -84,7 +82,6 @@ void LP_statslog_parseline(cJSON *lineobj) int32_t LP_statslog_parse() { static long lastpos; FILE *fp; char line[8192]; cJSON *lineobj; int32_t n = 0; - portable_mutex_lock(&LP_logmutex); if ( (fp= fopen(LP_STATSLOG_FNAME,"rb")) != 0 ) { if ( lastpos > 0 ) @@ -111,7 +108,6 @@ int32_t LP_statslog_parse() } fclose(fp); } - portable_mutex_unlock(&LP_logmutex); return(n); }