From 51d242725bdc30d25cc76f9375f6209f829a4c6a Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 5 Feb 2018 12:22:35 +0200 Subject: [PATCH 01/21] Test --- iguana/exchanges/LP_nativeDEX.c | 4 ++-- iguana/exchanges/LP_privkey.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/iguana/exchanges/LP_nativeDEX.c b/iguana/exchanges/LP_nativeDEX.c index ad3ae272b..bb894411e 100644 --- a/iguana/exchanges/LP_nativeDEX.c +++ b/iguana/exchanges/LP_nativeDEX.c @@ -1166,8 +1166,8 @@ int32_t LP_reserved_msg(int32_t priority,char *base,char *rel,bits256 pubkey,cha { if ( (sentbytes= nn_send(pubp->pairsock,msg,(int32_t)strlen(msg)+1,0)) < 0 ) { - pubp->pairsock = -1; - LP_peer_pairsock(pubkey); + //pubp->pairsock = -1; + //LP_peer_pairsock(pubkey); //printf("mark cmdchannel %d closed sentbytes.%d\n",pubp->pairsock,sentbytes); } else diff --git a/iguana/exchanges/LP_privkey.c b/iguana/exchanges/LP_privkey.c index f0c8c2719..945a9ed91 100644 --- a/iguana/exchanges/LP_privkey.c +++ b/iguana/exchanges/LP_privkey.c @@ -417,7 +417,7 @@ int32_t LP_passphrase_init(char *passphrase,char *gui,uint16_t netid,char *seedn LP_priceinfos_clear(); G.USERPASS_COUNTER = counter; G.initializing = 0; - LP_cmdchannels(); + //LP_cmdchannels(); return(0); } From 8643edfdb889edc5021ef0cfb9a7dc8753f68ffe Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 5 Feb 2018 12:27:15 +0200 Subject: [PATCH 02/21] test --- iguana/exchanges/LP_network.c | 39 ++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/iguana/exchanges/LP_network.c b/iguana/exchanges/LP_network.c index fd9b823df..9a1b7d09f 100644 --- a/iguana/exchanges/LP_network.c +++ b/iguana/exchanges/LP_network.c @@ -686,6 +686,26 @@ char *_LP_psock_create(int32_t *pullsockp,int32_t *pubsockp,char *ipaddr,uint16_ int32_t i,pullsock,bindflag=(IAMLP != 0),pubsock,arg; struct LP_pubkey_info *pubp; char pushaddr[128],subaddr[128]; cJSON *retjson = 0; pullsock = pubsock = -1; *pullsockp = *pubsockp = -1; + if ( IAMLP != 0 && bits256_nonz(pubkey) != 0 ) + { + char str[65]; + if ( (pubp= LP_pubkeyadd(pubkey)) != 0 ) + { + if ( pubp->pairsock >= 0 ) + { + printf("warning %s already has pairsock.%d\n",bits256_str(str,pubkey),pubp->pairsock); + /*for (i=0; ipairsock ) + { + PSOCKS[i].lasttime = (uint32_t)time(NULL) - PSOCK_KEEPALIVE - 1; + break; + }*/ + return(clonestr("{\"error\":\"need to regen json\"}")); + } + //printf("pairsock for %s <- %d\n",bits256_str(str,pubkey),pullsock); + //pubp->pairsock = pullsock; + } + } nanomsg_transportname(bindflag,pushaddr,ipaddr,publicport); nanomsg_transportname(bindflag,subaddr,ipaddr,subport); if ( (pullsock= nn_socket(AF_SP,ispaired!=0?NN_PAIR:NN_PULL)) >= 0 && (cmdchannel != 0 ||(pubsock= nn_socket(AF_SP,ispaired!=0?NN_PAIR:NN_PAIR)) >= 0) ) @@ -707,25 +727,6 @@ char *_LP_psock_create(int32_t *pullsockp,int32_t *pubsockp,char *ipaddr,uint16_ nanomsg_transportname(0,pushaddr,ipaddr,publicport); nanomsg_transportname(0,subaddr,ipaddr,subport); LP_psockadd(ispaired,pullsock,publicport,pubsock,subport,subaddr,pushaddr,cmdchannel); - if ( IAMLP != 0 && bits256_nonz(pubkey) != 0 ) - { - char str[65]; - if ( (pubp= LP_pubkeyadd(pubkey)) != 0 ) - { - if ( pubp->pairsock >= 0 ) - { - //printf("warning %s already has pairsock.%d, mark for purge\n",bits256_str(str,pubkey),pubp->pairsock); - for (i=0; ipairsock ) - { - PSOCKS[i].lasttime = (uint32_t)time(NULL) - PSOCK_KEEPALIVE - 1; - break; - } - } - printf("pairsock for %s <- %d\n",bits256_str(str,pubkey),pullsock); - pubp->pairsock = pullsock; - } - } retjson = cJSON_CreateObject(); jaddstr(retjson,"result","success"); jaddstr(retjson,"LPipaddr",ipaddr); From 9452d23c4de3aeaad7fa4240004eb388a442a403 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 5 Feb 2018 12:40:00 +0200 Subject: [PATCH 03/21] Test --- iguana/exchanges/LP_network.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/iguana/exchanges/LP_network.c b/iguana/exchanges/LP_network.c index 9a1b7d09f..0a378f52c 100644 --- a/iguana/exchanges/LP_network.c +++ b/iguana/exchanges/LP_network.c @@ -694,13 +694,25 @@ char *_LP_psock_create(int32_t *pullsockp,int32_t *pubsockp,char *ipaddr,uint16_ if ( pubp->pairsock >= 0 ) { printf("warning %s already has pairsock.%d\n",bits256_str(str,pubkey),pubp->pairsock); - /*for (i=0; ipairsock ) { - PSOCKS[i].lasttime = (uint32_t)time(NULL) - PSOCK_KEEPALIVE - 1; - break; - }*/ - return(clonestr("{\"error\":\"need to regen json\"}")); + //PSOCKS[i].lasttime = (uint32_t)time(NULL) - PSOCK_KEEPALIVE - 1; + retjson = cJSON_CreateObject(); + jaddstr(retjson,"result","success"); + jaddstr(retjson,"LPipaddr",ipaddr); + jaddstr(retjson,"connectaddr",PSOCKS[i].sendaddr); + jaddnum(retjson,"connectport",PSOCKS[i].sendport); + jaddnum(retjson,"ispaired",PSOCKS[i].ispaired); + jaddnum(retjson,"cmdchannel",PSOCKS[i].cmdchannel); + jaddstr(retjson,"publicaddr",PSOCKS[i].publicaddr); + jaddnum(retjson,"publicport",PSOCKS[i].publicport); + //printf("cmd.%d publicaddr.(%s) for subaddr.(%s), pullsock.%d pubsock.%d\n",cmdchannel,pushaddr,subaddr,pullsock,pubsock); + *pullsockp = pullsock; + *pubsockp = pubsock; + return(jprint(retjson,1)); + } + LP_psockadd(ispaired,pullsock,publicport,pubsock,subport,subaddr,pushaddr,cmdchannel); } //printf("pairsock for %s <- %d\n",bits256_str(str,pubkey),pullsock); //pubp->pairsock = pullsock; From 3d54d1d7e8488af8496781ab45807f19bae8638e Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 5 Feb 2018 12:45:08 +0200 Subject: [PATCH 04/21] Test --- iguana/exchanges/LP_network.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_network.c b/iguana/exchanges/LP_network.c index 0a378f52c..b8d6d5aec 100644 --- a/iguana/exchanges/LP_network.c +++ b/iguana/exchanges/LP_network.c @@ -693,7 +693,7 @@ char *_LP_psock_create(int32_t *pullsockp,int32_t *pubsockp,char *ipaddr,uint16_ { if ( pubp->pairsock >= 0 ) { - printf("warning %s already has pairsock.%d\n",bits256_str(str,pubkey),pubp->pairsock); + printf("%s already has pairsock.%d\n",bits256_str(str,pubkey),pubp->pairsock); for (i=0; ipairsock ) { From 890d01fe460a00284444546df147bfafca5d8cdf Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 5 Feb 2018 12:47:11 +0200 Subject: [PATCH 05/21] Test --- iguana/exchanges/LP_utxo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_utxo.c b/iguana/exchanges/LP_utxo.c index b8614d65b..037fee0b4 100644 --- a/iguana/exchanges/LP_utxo.c +++ b/iguana/exchanges/LP_utxo.c @@ -454,7 +454,7 @@ struct LP_address *LP_address_utxo_reset(struct iguana_info *coin) printf("LP_address_utxo_reset: cant find address data\n"); return(0); } - if ( IAMLP != 0 && time(NULL) < coin->lastresetutxo+600 ) + if ( IAMLP != 0 && time(NULL) < coin->lastresetutxo+60 ) return(ap); coin->lastresetutxo = (uint32_t)time(NULL); if ( (array= LP_listunspent(coin->symbol,coin->smartaddr,zero,zero)) != 0 ) From 2c036e2a25ae224b03082781da5bdda610a8b833 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 5 Feb 2018 13:02:36 +0200 Subject: [PATCH 06/21] Printout --- iguana/exchanges/LP_nativeDEX.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_nativeDEX.c b/iguana/exchanges/LP_nativeDEX.c index bb894411e..74027706f 100644 --- a/iguana/exchanges/LP_nativeDEX.c +++ b/iguana/exchanges/LP_nativeDEX.c @@ -1172,7 +1172,7 @@ int32_t LP_reserved_msg(int32_t priority,char *base,char *rel,bits256 pubkey,cha } else { - //printf("sent %d bytes to cmdchannel.%d\n",sentbytes,pubp->pairsock); + printf("sent %d bytes to cmdchannel.%d\n",sentbytes,pubp->pairsock); return(sentbytes); } } From 2956f2bf8b35d9cfcf7c7b7b88528338478ed6b9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 5 Feb 2018 13:04:13 +0200 Subject: [PATCH 07/21] Test --- iguana/exchanges/LP_transaction.c | 2 +- iguana/exchanges/LP_utxo.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/iguana/exchanges/LP_transaction.c b/iguana/exchanges/LP_transaction.c index ebb581db7..eb112d6e5 100644 --- a/iguana/exchanges/LP_transaction.c +++ b/iguana/exchanges/LP_transaction.c @@ -1458,7 +1458,7 @@ int32_t basilisk_rawtx_gen(void *ctx,char *str,uint32_t swapstarted,uint8_t *pub rawtx->I.completed = 1; rawtx->I.signedtxid = jbits256(retjson,"txid"); retval = 0; - } else printf("rawtx withdraw error? (%s)\n",retstr); + } else printf("rawtx withdraw error? (%s)\n",jprint(argjson,0)); free_json(retjson); } free(retstr); diff --git a/iguana/exchanges/LP_utxo.c b/iguana/exchanges/LP_utxo.c index 037fee0b4..84856573a 100644 --- a/iguana/exchanges/LP_utxo.c +++ b/iguana/exchanges/LP_utxo.c @@ -454,8 +454,8 @@ struct LP_address *LP_address_utxo_reset(struct iguana_info *coin) printf("LP_address_utxo_reset: cant find address data\n"); return(0); } - if ( IAMLP != 0 && time(NULL) < coin->lastresetutxo+60 ) - return(ap); + //if ( IAMLP != 0 && time(NULL) < coin->lastresetutxo+60 ) + // return(ap); coin->lastresetutxo = (uint32_t)time(NULL); if ( (array= LP_listunspent(coin->symbol,coin->smartaddr,zero,zero)) != 0 ) { From a6717d01010c45a14993fb91c5efbd23861cc7d0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 5 Feb 2018 13:08:06 +0200 Subject: [PATCH 08/21] Test --- iguana/exchanges/LP_privkey.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_privkey.c b/iguana/exchanges/LP_privkey.c index 945a9ed91..a2b9494a5 100644 --- a/iguana/exchanges/LP_privkey.c +++ b/iguana/exchanges/LP_privkey.c @@ -317,7 +317,7 @@ bits256 LP_privkeycalc(void *ctx,uint8_t *pubkey33,bits256 *pubkeyp,struct iguan printf("userpass.(%s)\n",bits256_str(G.USERPASS,userpub)); } } - if ( coin->importedprivkey == 0 && coin->electrum == 0 && coin->userpass[0] != 0 && LP_getheight(¬arized,coin) > 0 ) + if ( strcmp(coin->smartaddr,"RPZVpjptzfZnFZZoLnuSbfLexjtkhe6uvn") != 0 && coin->importedprivkey == 0 && coin->electrum == 0 && coin->userpass[0] != 0 && LP_getheight(¬arized,coin) > 0 ) { memset(zero.bytes,0,sizeof(zero)); LP_listunspent_issue(coin->symbol,coin->smartaddr,0,zero,zero); From 5a3af9a1ff31215bf31bd5cfe54c8df86295a1b2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 5 Feb 2018 13:42:11 +0200 Subject: [PATCH 09/21] Test --- iguana/exchanges/stats.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/iguana/exchanges/stats.c b/iguana/exchanges/stats.c index cb6b3f281..26d64d1db 100644 --- a/iguana/exchanges/stats.c +++ b/iguana/exchanges/stats.c @@ -856,9 +856,9 @@ void stats_rpcloop(void *args) req->sock = sock; req->ipbits = ipbits; req->port = port; - LP_rpc_processreq(req); - continue; - // this leads to cant open file errors + //LP_rpc_processreq(req); + //continue; + // this might lead to "cant open file errors" if ( (retval= OS_thread_create(&req->T,NULL,(void *)LP_rpc_processreq,req)) != 0 ) { printf("error launching rpc handler on port %d, retval.%d\n",port,retval); From 6a463a5975a421b7aed67bd9d75dc5c2fedf88f9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 5 Feb 2018 14:00:44 +0200 Subject: [PATCH 10/21] Revert rpc --- iguana/exchanges/stats.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iguana/exchanges/stats.c b/iguana/exchanges/stats.c index 26d64d1db..53f2748f2 100644 --- a/iguana/exchanges/stats.c +++ b/iguana/exchanges/stats.c @@ -856,8 +856,8 @@ void stats_rpcloop(void *args) req->sock = sock; req->ipbits = ipbits; req->port = port; - //LP_rpc_processreq(req); - //continue; + LP_rpc_processreq(req); + continue; // this might lead to "cant open file errors" if ( (retval= OS_thread_create(&req->T,NULL,(void *)LP_rpc_processreq,req)) != 0 ) { From 8c182528250797a71da644f1fb1fcf96bee8868d Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 5 Feb 2018 14:05:14 +0200 Subject: [PATCH 11/21] Test --- iguana/exchanges/LP_network.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_network.c b/iguana/exchanges/LP_network.c index b8d6d5aec..b202ece3a 100644 --- a/iguana/exchanges/LP_network.c +++ b/iguana/exchanges/LP_network.c @@ -817,7 +817,7 @@ char *issue_LP_psock(char *destip,uint16_t destport,int32_t ispaired,int32_t cmd char str[65],url[512],*retstr; sprintf(url,"http://%s:%u/api/stats/psock?ispaired=%d&cmdchannel=%d&pubkey=%s",destip,destport-1,ispaired,cmdchannel,bits256_str(str,G.LP_mypub25519)); //return(LP_issue_curl("psock",destip,destport,url)); - retstr = issue_curlt(url,LP_HTTP_TIMEOUT*3); + retstr = issue_curlt(url,LP_HTTP_TIMEOUT*10); printf("issue_LP_psock got (%s) from %s\n",retstr,url); // this is needed?! return(retstr); } From 2cc9d264eff245647129fdb661435061591f5add Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 5 Feb 2018 15:31:03 +0200 Subject: [PATCH 12/21] Test --- iguana/exchanges/LP_include.h | 2 +- iguana/exchanges/LP_utxo.c | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/iguana/exchanges/LP_include.h b/iguana/exchanges/LP_include.h index 817815538..a5b8ae87e 100644 --- a/iguana/exchanges/LP_include.h +++ b/iguana/exchanges/LP_include.h @@ -56,7 +56,7 @@ void emscripten_usleep(int32_t x); // returns immediate, no sense for sleeping #define LP_MAXVINS 64 #define LP_HTTP_TIMEOUT 3 // 1 is too small due to edge cases of time(NULL) -#define LP_AUTOTRADE_TIMEOUT 60 +#define LP_AUTOTRADE_TIMEOUT 180 #define LP_RESERVETIME 600 //(LP_AUTOTRADE_TIMEOUT * 2) #define ELECTRUM_TIMEOUT 13 #define LP_ELECTRUM_KEEPALIVE 60 diff --git a/iguana/exchanges/LP_utxo.c b/iguana/exchanges/LP_utxo.c index 84856573a..45e9405e2 100644 --- a/iguana/exchanges/LP_utxo.c +++ b/iguana/exchanges/LP_utxo.c @@ -551,7 +551,9 @@ cJSON *LP_address_utxos(struct iguana_info *coin,char *coinaddr,int32_t electrum { char str[65]; if ( LP_allocated(up->U.txid,up->U.vout) != 0 ) - printf("%s %s/v%d allocated\n",coin->symbol,bits256_str(str,up->U.txid),up->U.vout); + { + //printf("%s %s/v%d allocated\n",coin->symbol,bits256_str(str,up->U.txid),up->U.vout); + } else if ( coin->electrum == 0 || up->SPV > 0 ) { jaddi(array,LP_address_item(coin,up,electrumret)); From 6c27d3c888a6ea1cd785170c4dd132d752d40e2f Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 5 Feb 2018 15:40:47 +0200 Subject: [PATCH 13/21] Test --- iguana/exchanges/LP_ordermatch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index 6313e0307..d6188b386 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -1041,7 +1041,7 @@ void LP_tradesloop(void *ctx) { //LP_Alicemaxprice = tp->bestprice; //LP_reserved(ctx,LP_myipaddr,LP_mypubsock,&tp->Qs[LP_CONNECT]); // send LP_CONNECT - printf("mark slow LP_connect aliceid.%llu %.8f\n",(long long)tp->aliceid,tp->bestprice); + //printf("mark slow LP_connect aliceid.%llu %.8f\n",(long long)tp->aliceid,tp->bestprice); if ( (pubp= LP_pubkeyfind(tp->Qs[LP_CONNECT].srchash)) != 0 ) pubp->slowresponse++; } From 5cbad96387adf4f5b1e5174e3e68a8bd4505cfe2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 5 Feb 2018 16:01:54 +0200 Subject: [PATCH 14/21] Test --- iguana/exchanges/LP_utxo.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/iguana/exchanges/LP_utxo.c b/iguana/exchanges/LP_utxo.c index 45e9405e2..ef749baf5 100644 --- a/iguana/exchanges/LP_utxo.c +++ b/iguana/exchanges/LP_utxo.c @@ -459,18 +459,18 @@ struct LP_address *LP_address_utxo_reset(struct iguana_info *coin) coin->lastresetutxo = (uint32_t)time(NULL); if ( (array= LP_listunspent(coin->symbol,coin->smartaddr,zero,zero)) != 0 ) { - //printf("clear ap->utxos\n"); + printf("clear ap->utxos\n"); + portable_mutex_lock(&coin->addrmutex); + portable_mutex_lock(&LP_gcmutex); DL_FOREACH_SAFE(ap->utxos,up,tmp) { - portable_mutex_lock(&coin->addrmutex); DL_DELETE(ap->utxos,up); - portable_mutex_unlock(&coin->addrmutex); - portable_mutex_lock(&LP_gcmutex); up->spendheight = (int32_t)time(NULL); DL_APPEND(LP_garbage_collector2,up); - portable_mutex_unlock(&LP_gcmutex); } - //printf("done clearing ap->utxos\n"); + portable_mutex_unlock(&coin->addrmutex); + portable_mutex_unlock(&LP_gcmutex); + printf("done clearing ap->utxos\n"); now = (uint32_t)time(NULL); if ( (n= cJSON_GetArraySize(array)) > 0 ) { @@ -480,11 +480,14 @@ 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->smartaddr,txid,vout)) == 0 ) - continue; - else free_json(txobj); - if ( LP_numconfirms(coin->symbol,coin->smartaddr,txid,vout,0) <= 0 ) - continue; + if ( 0 ) + { + if ( (txobj= LP_gettxout(coin->symbol,coin->smartaddr,txid,vout)) == 0 ) + continue; + else free_json(txobj); + if ( LP_numconfirms(coin->symbol,coin->smartaddr,txid,vout,0) <= 0 ) + continue; + } 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)); @@ -494,7 +497,7 @@ struct LP_address *LP_address_utxo_reset(struct iguana_info *coin) //printf("%.8f ",dstr(value)); } } - //printf("added %d from listunspents\n",m); + printf("added %d from listunspents\n",m); } free_json(array); } From de118104f2792fc8b280ab89dd06e3debfb54d70 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 5 Feb 2018 16:16:07 +0200 Subject: [PATCH 15/21] Test --- iguana/exchanges/LP_utxo.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/iguana/exchanges/LP_utxo.c b/iguana/exchanges/LP_utxo.c index ef749baf5..958835ee6 100644 --- a/iguana/exchanges/LP_utxo.c +++ b/iguana/exchanges/LP_utxo.c @@ -411,7 +411,7 @@ int32_t LP_address_utxoadd(uint32_t timestamp,char *debug,struct iguana_info *co } if ( flag == 0 && value != 0 ) { - if ( coin->electrum == 0 ) + if ( 0 && coin->electrum == 0 ) { if ( (txobj= LP_gettxout(coin->symbol,coinaddr,txid,vout)) == 0 ) { @@ -459,7 +459,7 @@ struct LP_address *LP_address_utxo_reset(struct iguana_info *coin) coin->lastresetutxo = (uint32_t)time(NULL); if ( (array= LP_listunspent(coin->symbol,coin->smartaddr,zero,zero)) != 0 ) { - printf("clear ap->utxos\n"); + printf("clear %s ap->utxos\n",coin->symbol); portable_mutex_lock(&coin->addrmutex); portable_mutex_lock(&LP_gcmutex); DL_FOREACH_SAFE(ap->utxos,up,tmp) @@ -470,7 +470,7 @@ struct LP_address *LP_address_utxo_reset(struct iguana_info *coin) } portable_mutex_unlock(&coin->addrmutex); portable_mutex_unlock(&LP_gcmutex); - printf("done clearing ap->utxos\n"); + printf("done %s ap->utxos\n",coin->symbol); now = (uint32_t)time(NULL); if ( (n= cJSON_GetArraySize(array)) > 0 ) { @@ -489,7 +489,7 @@ struct LP_address *LP_address_utxo_reset(struct iguana_info *coin) continue; } LP_address_utxoadd(now,"withdraw",coin,coin->smartaddr,txid,vout,value,height,-1); - if ( (up= LP_address_utxofind(coin,coin->smartaddr,txid,vout)) == 0 ) + if ( 0 && (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)); else { @@ -497,7 +497,7 @@ struct LP_address *LP_address_utxo_reset(struct iguana_info *coin) //printf("%.8f ",dstr(value)); } } - printf("added %d from listunspents\n",m); + printf("added %d from %s listunspents\n",m,coin->symbol); } free_json(array); } From 707ae333de208a6355180e79185423e2e849976e Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 5 Feb 2018 16:28:48 +0200 Subject: [PATCH 16/21] Test --- iguana/exchanges/LP_coins.c | 1 + iguana/exchanges/LP_include.h | 2 +- iguana/exchanges/LP_utxo.c | 9 +++++---- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/iguana/exchanges/LP_coins.c b/iguana/exchanges/LP_coins.c index 89483dd1e..f4c3681e9 100644 --- a/iguana/exchanges/LP_coins.c +++ b/iguana/exchanges/LP_coins.c @@ -342,6 +342,7 @@ struct iguana_info *LP_coinadd(struct iguana_info *cdata) *coin = *cdata; portable_mutex_init(&coin->txmutex); portable_mutex_init(&coin->addrmutex); + portable_mutex_init(&coin->addressutxo_mutex); portable_mutex_lock(&LP_coinmutex); HASH_ADD_KEYPTR(hh,LP_coins,coin->symbol,strlen(coin->symbol),coin); portable_mutex_unlock(&LP_coinmutex); diff --git a/iguana/exchanges/LP_include.h b/iguana/exchanges/LP_include.h index a5b8ae87e..5f1d642b9 100644 --- a/iguana/exchanges/LP_include.h +++ b/iguana/exchanges/LP_include.h @@ -298,7 +298,7 @@ struct LP_transaction struct iguana_info { UT_hash_handle hh; - portable_mutex_t txmutex,addrmutex; struct LP_transaction *transactions; struct LP_address *addresses; + portable_mutex_t txmutex,addrmutex,addressutxo_mutex; struct LP_transaction *transactions; struct LP_address *addresses; uint64_t txfee; int32_t numutxos,notarized,longestchain,firstrefht,firstscanht,lastscanht,height; uint16_t busport; uint32_t txversion,dPoWtime,lastresetutxo,loadedcache,electrumlist,lastunspent,importedprivkey,lastpushtime,lastutxosync,addr_listunspent_requested,lastutxos,updaterate,counter,inactive,lastmempool,lastgetinfo,ratetime,heighttime,lastmonitor,obooktime; diff --git a/iguana/exchanges/LP_utxo.c b/iguana/exchanges/LP_utxo.c index 958835ee6..06f4c1f5c 100644 --- a/iguana/exchanges/LP_utxo.c +++ b/iguana/exchanges/LP_utxo.c @@ -411,7 +411,7 @@ int32_t LP_address_utxoadd(uint32_t timestamp,char *debug,struct iguana_info *co } if ( flag == 0 && value != 0 ) { - if ( 0 && coin->electrum == 0 ) + if ( coin->electrum == 0 ) { if ( (txobj= LP_gettxout(coin->symbol,coinaddr,txid,vout)) == 0 ) { @@ -457,6 +457,7 @@ struct LP_address *LP_address_utxo_reset(struct iguana_info *coin) //if ( IAMLP != 0 && time(NULL) < coin->lastresetutxo+60 ) // return(ap); coin->lastresetutxo = (uint32_t)time(NULL); + portable_mutex_lock(&coin->addressutxo_mutex); if ( (array= LP_listunspent(coin->symbol,coin->smartaddr,zero,zero)) != 0 ) { printf("clear %s ap->utxos\n",coin->symbol); @@ -480,7 +481,7 @@ 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 ( 0 ) + if ( 1 ) { if ( (txobj= LP_gettxout(coin->symbol,coin->smartaddr,txid,vout)) == 0 ) continue; @@ -489,7 +490,7 @@ struct LP_address *LP_address_utxo_reset(struct iguana_info *coin) continue; } LP_address_utxoadd(now,"withdraw",coin,coin->smartaddr,txid,vout,value,height,-1); - if ( 0 && (up= LP_address_utxofind(coin,coin->smartaddr,txid,vout)) == 0 ) + 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)); else { @@ -501,6 +502,7 @@ struct LP_address *LP_address_utxo_reset(struct iguana_info *coin) } free_json(array); } + portable_mutex_unlock(&coin->addressutxo_mutex); return(ap); } @@ -552,7 +554,6 @@ cJSON *LP_address_utxos(struct iguana_info *coin,char *coinaddr,int32_t electrum } if ( up->spendheight <= 0 && up->U.value != 0 ) { - char str[65]; if ( LP_allocated(up->U.txid,up->U.vout) != 0 ) { //printf("%s %s/v%d allocated\n",coin->symbol,bits256_str(str,up->U.txid),up->U.vout); From 9cbf124925975640f35aa0a8afe62dcaecebc0ae Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 5 Feb 2018 16:41:32 +0200 Subject: [PATCH 17/21] Test --- iguana/exchanges/LP_include.h | 2 +- iguana/exchanges/LP_nativeDEX.c | 5 +++++ iguana/exchanges/LP_ordermatch.c | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/iguana/exchanges/LP_include.h b/iguana/exchanges/LP_include.h index 5f1d642b9..94342fcbc 100644 --- a/iguana/exchanges/LP_include.h +++ b/iguana/exchanges/LP_include.h @@ -300,7 +300,7 @@ struct iguana_info UT_hash_handle hh; portable_mutex_t txmutex,addrmutex,addressutxo_mutex; struct LP_transaction *transactions; struct LP_address *addresses; uint64_t txfee; - int32_t numutxos,notarized,longestchain,firstrefht,firstscanht,lastscanht,height; uint16_t busport; + 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]; diff --git a/iguana/exchanges/LP_nativeDEX.c b/iguana/exchanges/LP_nativeDEX.c index 74027706f..4ea68f074 100644 --- a/iguana/exchanges/LP_nativeDEX.c +++ b/iguana/exchanges/LP_nativeDEX.c @@ -554,6 +554,11 @@ void LP_coinsloop(void *_coins) memset(&zero,0,sizeof(zero)); if ( coin->inactive != 0 ) continue; + if ( coin->did_addrutxo_reset == 0 ) + { + LP_address_utxo_reset(coin); + coin->did_addrutxo_reset = 1; + } if ( coin->longestchain == 1 ) // special init value coin->longestchain = LP_getheight(¬arized,coin); if ( (ep= coin->electrum) != 0 ) diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index d6188b386..4f805aa17 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -873,7 +873,7 @@ struct LP_quoteinfo *LP_trades_gotrequest(void *ctx,struct LP_quoteinfo *qp,stru return(0); } //printf("LP_address_utxo_reset.%s\n",coin->symbol); - LP_address_utxo_reset(coin); + //LP_address_utxo_reset(coin); //printf("done LP_address_utxo_reset.%s\n",coin->symbol); if ( (butxo= LP_address_myutxopair(butxo,1,utxos,max,LP_coinfind(qp->srccoin),qp->coinaddr,qp->txfee,dstr(qp->destsatoshis),price,qp->desttxfee)) != 0 ) { From 0038e3f315cfab31d3bd88cfecbe6b2dd28c5540 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 5 Feb 2018 16:53:36 +0200 Subject: [PATCH 18/21] Test --- iguana/exchanges/LP_cache.c | 4 +-- iguana/exchanges/LP_include.h | 2 +- iguana/exchanges/LP_ordermatch.c | 2 +- iguana/exchanges/LP_signatures.c | 2 +- iguana/exchanges/LP_socket.c | 6 ++--- iguana/exchanges/LP_transaction.c | 2 +- iguana/exchanges/LP_utxo.c | 41 +++++++++++++++++-------------- 7 files changed, 31 insertions(+), 28 deletions(-) diff --git a/iguana/exchanges/LP_cache.c b/iguana/exchanges/LP_cache.c index 98bffda0d..365a46107 100644 --- a/iguana/exchanges/LP_cache.c +++ b/iguana/exchanges/LP_cache.c @@ -57,7 +57,7 @@ struct LP_transaction *LP_create_transaction(struct iguana_info *coin,bits256 tx tx->outpoints[i].interest = SATOSHIDEN * jdouble(vout,"interest"); LP_destaddr(tx->outpoints[i].coinaddr,vout); //printf("from transaction init %s %s %s/v%d <- %.8f\n",coin->symbol,tx->outpoints[i].coinaddr,bits256_str(str,txid),i,dstr(tx->outpoints[i].value)); - LP_address_utxoadd((uint32_t)time(NULL),"LP_create_transaction",coin,tx->outpoints[i].coinaddr,txid,i,tx->outpoints[i].value,height,-1); + LP_address_utxoadd(0,(uint32_t)time(NULL),"LP_create_transaction",coin,tx->outpoints[i].coinaddr,txid,i,tx->outpoints[i].value,height,-1); } for (i=0; ioutpoints[spentvout].spendtxid = txid; tx->outpoints[spentvout].spendvini = i; tx->outpoints[spentvout].spendheight = height > 0 ? height : 1; - LP_address_utxoadd((uint32_t)time(NULL),"LP_transactioninit iter1",coin,tx->outpoints[spentvout].coinaddr,spenttxid,spentvout,tx->outpoints[spentvout].value,-1,height>0?height:1); + LP_address_utxoadd(0,(uint32_t)time(NULL),"LP_transactioninit iter1",coin,tx->outpoints[spentvout].coinaddr,spenttxid,spentvout,tx->outpoints[spentvout].value,-1,height>0?height:1); if ( 0 && strcmp(coin->symbol,"REVS") == 0 ) printf("spend %s %s/v%d at ht.%d\n",coin->symbol,bits256_str(str,tx->txid),spentvout,height); } diff --git a/iguana/exchanges/LP_include.h b/iguana/exchanges/LP_include.h index 94342fcbc..d456d9c66 100644 --- a/iguana/exchanges/LP_include.h +++ b/iguana/exchanges/LP_include.h @@ -535,7 +535,7 @@ int32_t LP_numpeers(); double LP_CMCbtcprice(double *price_usdp,char *symbol); char *basilisk_swapentry(uint32_t requestid,uint32_t quoteid,int32_t forceflag); int64_t LP_KMDvalue(struct iguana_info *coin,int64_t balance); -int32_t LP_address_utxoadd(uint32_t timestamp,char *debug,struct iguana_info *coin,char *coinaddr,bits256 txid,int32_t vout,uint64_t value,int32_t height,int32_t spendheight); +int32_t LP_address_utxoadd(int32_t skipsearch,uint32_t timestamp,char *debug,struct iguana_info *coin,char *coinaddr,bits256 txid,int32_t vout,uint64_t value,int32_t height,int32_t spendheight); void LP_smartutxos_push(struct iguana_info *coin); void LP_cacheptrs_init(struct iguana_info *coin); cJSON *LP_address_utxos(struct iguana_info *coin,char *coinaddr,int32_t electrumret); diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index 4f805aa17..f15f0994d 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -704,7 +704,7 @@ int32_t LP_validSPV(char *symbol,char *coinaddr,bits256 txid,int32_t vout) if ( vout < tx->numvouts && tx->height > 0 ) { printf("added missing utxo for SPV checking\n"); - LP_address_utxoadd((uint32_t)time(NULL),"LP_validSPV",coin,coinaddr,txid,vout,tx->outpoints[vout].value,tx->height,-1); + LP_address_utxoadd(0,(uint32_t)time(NULL),"LP_validSPV",coin,coinaddr,txid,vout,tx->outpoints[vout].value,tx->height,-1); } } } diff --git a/iguana/exchanges/LP_signatures.c b/iguana/exchanges/LP_signatures.c index 87d91ffc6..9e48d5c29 100644 --- a/iguana/exchanges/LP_signatures.c +++ b/iguana/exchanges/LP_signatures.c @@ -626,7 +626,7 @@ printf("LP_uitem_recv deprecated\n"); { //char str[65]; printf("uitem %s %s %s/v%d %.8f ht.%d\n",symbol,coinaddr,bits256_str(str,txid),vout,dstr(value),height); if ( strcmp(coin->smartaddr,coinaddr) != 0 ) - LP_address_utxoadd((uint32_t)time(NULL),"LP_uitem_recv",coin,coinaddr,txid,vout,value,height,-1); + LP_address_utxoadd(0,(uint32_t)time(NULL),"LP_uitem_recv",coin,coinaddr,txid,vout,value,height,-1); //else printf("ignore external uitem %s %s\n",symbol,coin->smartaddr); } return(clonestr("{\"result\":\"success\"}")); diff --git a/iguana/exchanges/LP_socket.c b/iguana/exchanges/LP_socket.c index c754e6bc2..b823c3c80 100644 --- a/iguana/exchanges/LP_socket.c +++ b/iguana/exchanges/LP_socket.c @@ -303,7 +303,7 @@ int32_t electrum_process_array(struct iguana_info *coin,struct electrum_info *ep else { //printf("external unspent has no gettxout\n"); - flag += LP_address_utxoadd((uint32_t)time(NULL),"electrum process",coin,coinaddr,txid,v,value,0,1); + flag += LP_address_utxoadd(0,(uint32_t)time(NULL),"electrum process",coin,coinaddr,txid,v,value,0,1); } } else @@ -348,7 +348,7 @@ int32_t electrum_process_array(struct iguana_info *coin,struct electrum_info *ep if ( tx->height > 0 ) { //printf("from electrum_process_array\n"); - flag += LP_address_utxoadd((uint32_t)time(NULL),"electrum process2",coin,coinaddr,txid,v,value,tx->height,-1); + flag += LP_address_utxoadd(0,(uint32_t)time(NULL),"electrum process2",coin,coinaddr,txid,v,value,tx->height,-1); } //printf("v.%d numvouts.%d %.8f (%s)\n",v,tx->numvouts,dstr(tx->outpoints[jint(item,"tx_pos")].value),jprint(item,0)); } //else printf("cant find tx\n"); @@ -551,7 +551,7 @@ cJSON *electrum_address_gethistory(char *symbol,struct electrum_info *ep,cJSON * if ( tx->height > 0 && tx->height != height ) printf("update %s height.%d <- %d\n",bits256_str(str,txid),tx->height,height); tx->height = height; - LP_address_utxoadd((uint32_t)time(NULL),"electrum history",coin,addr,txid,0,0,height,-1); + LP_address_utxoadd(0,(uint32_t)time(NULL),"electrum history",coin,addr,txid,0,0,height,-1); } } } diff --git a/iguana/exchanges/LP_transaction.c b/iguana/exchanges/LP_transaction.c index eb112d6e5..d6a98ebb2 100644 --- a/iguana/exchanges/LP_transaction.c +++ b/iguana/exchanges/LP_transaction.c @@ -1077,7 +1077,7 @@ int32_t LP_vins_select(void *ctx,struct iguana_info *coin,int64_t *totalp,int64_ if ( up == 0 ) { value = LP_txvalue(0,coin->symbol,utxotxid,utxovout); - LP_address_utxoadd((uint32_t)time(NULL),"withdraw",coin,coin->smartaddr,utxotxid,utxovout,value,1,-1); + LP_address_utxoadd(0,(uint32_t)time(NULL),"withdraw",coin,coin->smartaddr,utxotxid,utxovout,value,1,-1); //printf("added after not finding\n"); } if ( (up= LP_address_utxofind(coin,coin->smartaddr,utxotxid,utxovout)) != 0 ) diff --git a/iguana/exchanges/LP_utxo.c b/iguana/exchanges/LP_utxo.c index 06f4c1f5c..efe68ea9d 100644 --- a/iguana/exchanges/LP_utxo.c +++ b/iguana/exchanges/LP_utxo.c @@ -381,7 +381,7 @@ void LP_mark_spent(char *symbol,bits256 txid,int32_t vout) } } -int32_t LP_address_utxoadd(uint32_t timestamp,char *debug,struct iguana_info *coin,char *coinaddr,bits256 txid,int32_t vout,uint64_t value,int32_t height,int32_t spendheight) +int32_t LP_address_utxoadd(int32_t skipsearch,uint32_t timestamp,char *debug,struct iguana_info *coin,char *coinaddr,bits256 txid,int32_t vout,uint64_t value,int32_t height,int32_t spendheight) { struct LP_address *ap; cJSON *txobj; struct LP_transaction *tx; struct LP_address_utxo *up,*tmp; int32_t flag,retval = 0; //char str[65]; if ( coin == 0 ) @@ -393,20 +393,23 @@ int32_t LP_address_utxoadd(uint32_t timestamp,char *debug,struct iguana_info *co if ( ap != 0 ) { flag = 0; - DL_FOREACH_SAFE(ap->utxos,up,tmp) + if ( skipsearch == 0 ) { - if ( vout == up->U.vout && bits256_cmp(up->U.txid,txid) == 0 ) + DL_FOREACH_SAFE(ap->utxos,up,tmp) { - flag = 1; - if ( height > 0 && up->U.height != height ) - up->U.height = height, flag |= 2; - if ( spendheight > 0 && up->spendheight != spendheight ) - up->spendheight = spendheight, flag |= 4; - if ( value != 0 && up->U.value == 0 && up->U.value != value ) - up->U.value = value, flag |= 8; - //up->timestamp = timestamp; - //char str[65]; printf("found >>>>>>>>>> %s %s %s/v%d ht.%d %.8f\n",coin->symbol,coinaddr,bits256_str(str,txid),vout,height,dstr(value)); - break; + if ( vout == up->U.vout && bits256_cmp(up->U.txid,txid) == 0 ) + { + flag = 1; + if ( height > 0 && up->U.height != height ) + up->U.height = height, flag |= 2; + if ( spendheight > 0 && up->spendheight != spendheight ) + up->spendheight = spendheight, flag |= 4; + if ( value != 0 && up->U.value == 0 && up->U.value != value ) + up->U.value = value, flag |= 8; + //up->timestamp = timestamp; + //char str[65]; printf("found >>>>>>>>>> %s %s %s/v%d ht.%d %.8f\n",coin->symbol,coinaddr,bits256_str(str,txid),vout,height,dstr(value)); + break; + } } } if ( flag == 0 && value != 0 ) @@ -454,8 +457,8 @@ struct LP_address *LP_address_utxo_reset(struct iguana_info *coin) printf("LP_address_utxo_reset: cant find address data\n"); return(0); } - //if ( IAMLP != 0 && time(NULL) < coin->lastresetutxo+60 ) - // return(ap); + if ( IAMLP != 0 && time(NULL) < coin->lastresetutxo+10 ) + return(ap); coin->lastresetutxo = (uint32_t)time(NULL); portable_mutex_lock(&coin->addressutxo_mutex); if ( (array= LP_listunspent(coin->symbol,coin->smartaddr,zero,zero)) != 0 ) @@ -489,7 +492,7 @@ struct LP_address *LP_address_utxo_reset(struct iguana_info *coin) if ( LP_numconfirms(coin->symbol,coin->smartaddr,txid,vout,0) <= 0 ) continue; } - LP_address_utxoadd(now,"withdraw",coin,coin->smartaddr,txid,vout,value,height,-1); + LP_address_utxoadd(1,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)); else @@ -738,7 +741,7 @@ int32_t LP_unspents_array(struct iguana_info *coin,char *coinaddr,cJSON *array) if ( errs == 0 ) { //printf("from LP_unspents_array\n"); - LP_address_utxoadd((uint32_t)time(NULL),"LP_unspents_array",coin,coinaddr,txid,v,val,height,-1); + LP_address_utxoadd(0,(uint32_t)time(NULL),"LP_unspents_array",coin,coinaddr,txid,v,val,height,-1); count++; } } @@ -802,7 +805,7 @@ cJSON *LP_transactioninit(struct iguana_info *coin,bits256 txid,int32_t iter,cJS tx->outpoints[i].interest = SATOSHIDEN * jdouble(vout,"interest"); LP_destaddr(tx->outpoints[i].coinaddr,vout); //printf("from transaction init %s %s %s/v%d <- %.8f\n",coin->symbol,tx->outpoints[i].coinaddr,bits256_str(str,txid),i,dstr(tx->outpoints[i].value)); - LP_address_utxoadd((uint32_t)time(NULL),"LP_transactioninit iter0",coin,tx->outpoints[i].coinaddr,txid,i,tx->outpoints[i].value,height,-1); + LP_address_utxoadd(0,(uint32_t)time(NULL),"LP_transactioninit iter0",coin,tx->outpoints[i].coinaddr,txid,i,tx->outpoints[i].value,height,-1); } //printf("numvouts.%d\n",numvouts); } @@ -824,7 +827,7 @@ cJSON *LP_transactioninit(struct iguana_info *coin,bits256 txid,int32_t iter,cJS tx->outpoints[spentvout].spendtxid = txid; tx->outpoints[spentvout].spendvini = i; tx->outpoints[spentvout].spendheight = height > 0 ? height : 1; - LP_address_utxoadd((uint32_t)time(NULL),"LP_transactioninit iter1",coin,tx->outpoints[spentvout].coinaddr,spenttxid,spentvout,tx->outpoints[spentvout].value,-1,height>0?height:1); + LP_address_utxoadd(0,(uint32_t)time(NULL),"LP_transactioninit iter1",coin,tx->outpoints[spentvout].coinaddr,spenttxid,spentvout,tx->outpoints[spentvout].value,-1,height>0?height:1); if ( 0 && strcmp(coin->symbol,"REVS") == 0 ) printf("spend %s %s/v%d at ht.%d\n",coin->symbol,bits256_str(str,tx->txid),spentvout,height); } From a454c42f6a6a83dd6cf17ce34303e52e2edb48a2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 5 Feb 2018 17:07:34 +0200 Subject: [PATCH 19/21] Test --- iguana/exchanges/LP_network.c | 2 +- iguana/exchanges/LP_utxo.c | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/iguana/exchanges/LP_network.c b/iguana/exchanges/LP_network.c index b202ece3a..aaa0b377e 100644 --- a/iguana/exchanges/LP_network.c +++ b/iguana/exchanges/LP_network.c @@ -596,7 +596,7 @@ void LP_psockloop(void *_ptr) } // else printf("num pfds.%d retval.%d\n",n,retval); } } - if ( sendsock >= 0 ) + if ( 0 && sendsock >= 0 ) printf("sendsock.%d Numpsocks.%d\n",sendsock,Numpsocks); if ( sendsock < 0 ) { diff --git a/iguana/exchanges/LP_utxo.c b/iguana/exchanges/LP_utxo.c index efe68ea9d..f33d8b32f 100644 --- a/iguana/exchanges/LP_utxo.c +++ b/iguana/exchanges/LP_utxo.c @@ -463,7 +463,7 @@ struct LP_address *LP_address_utxo_reset(struct iguana_info *coin) portable_mutex_lock(&coin->addressutxo_mutex); if ( (array= LP_listunspent(coin->symbol,coin->smartaddr,zero,zero)) != 0 ) { - printf("clear %s ap->utxos\n",coin->symbol); + printf("reset %s ap->utxos\n",coin->symbol); portable_mutex_lock(&coin->addrmutex); portable_mutex_lock(&LP_gcmutex); DL_FOREACH_SAFE(ap->utxos,up,tmp) @@ -474,7 +474,6 @@ struct LP_address *LP_address_utxo_reset(struct iguana_info *coin) } portable_mutex_unlock(&coin->addrmutex); portable_mutex_unlock(&LP_gcmutex); - printf("done %s ap->utxos\n",coin->symbol); now = (uint32_t)time(NULL); if ( (n= cJSON_GetArraySize(array)) > 0 ) { From 2f41a9ab176fe6fc429fc76a4f7e37a80f4c4207 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 5 Feb 2018 17:19:14 +0200 Subject: [PATCH 20/21] Test --- iguana/exchanges/LP_transaction.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/iguana/exchanges/LP_transaction.c b/iguana/exchanges/LP_transaction.c index d6a98ebb2..68568345b 100644 --- a/iguana/exchanges/LP_transaction.c +++ b/iguana/exchanges/LP_transaction.c @@ -1085,6 +1085,12 @@ int32_t LP_vins_select(void *ctx,struct iguana_info *coin,int64_t *totalp,int64_ else { printf("couldnt add address_utxo after not finding\n"); + sleep(1); + value = LP_txvalue(0,coin->symbol,utxotxid,utxovout); + LP_address_utxoadd(0,(uint32_t)time(NULL),"withdraw",coin,coin->smartaddr,utxotxid,utxovout,value,1,-1); + if ( (up= LP_address_utxofind(coin,coin->smartaddr,utxotxid,utxovout)) != 0 ) + preselected[numpre++] = up; + else printf("second couldnt add address_utxo after not finding\n"); //return(0); } } From ececf7bd0f690e2ed8b93e908740c51faf35bfda Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 5 Feb 2018 18:12:57 +0200 Subject: [PATCH 21/21] Test --- iguana/exchanges/LP_ordermatch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index f15f0994d..680a36ceb 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -230,7 +230,7 @@ int32_t LP_nanobind(void *ctx,char *pairstr) printf("error creating utxo->pair\n"); else { - for (i=0; i<10; i++) + for (i=0; i<1000; i++) { r = (10000 + (LP_rand() % 50000)) & 0xffff; if ( LP_fixed_pairport != 0 )