From 597f9cdafceb291693526750fb0022cfe3c740f5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Nov 2017 16:32:30 +0200 Subject: [PATCH 01/18] Test --- iguana/exchanges/LP_ordermatch.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index 9dbb4e210e..f28c779bd2 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -126,7 +126,7 @@ double LP_quote_validate(struct LP_utxoinfo *autxo,struct LP_utxoinfo *butxo,str { if ( LP_iseligible(&srcvalue,&srcvalue2,1,qp->srccoin,qp->txid,qp->vout,qp->satoshis,qp->txid2,qp->vout2) == 0 ) { - printf("bob not eligible %s (%.8f %.8f)\n",jprint(LP_quotejson(qp),1),dstr(srcvalue),dstr(srcvalue2)); + //printf("bob not eligible %s (%.8f %.8f)\n",jprint(LP_quotejson(qp),1),dstr(srcvalue),dstr(srcvalue2)); return(-2); } if ( (txout= LP_gettxout(qp->srccoin,qp->coinaddr,qp->txid,qp->vout)) != 0 ) @@ -159,7 +159,7 @@ double LP_quote_validate(struct LP_utxoinfo *autxo,struct LP_utxoinfo *butxo,str if ( LP_iseligible(&destvalue,&destvalue2,0,qp->destcoin,qp->desttxid,qp->destvout,qp->destsatoshis,qp->feetxid,qp->feevout) == 0 ) { //alice not eligible 0.36893923 -> dest 0.55020000 1.49130251 (0.61732249 0.00104324) 14b8b74808d2d34a70e5eddd1cad47d855858f8b23cac802576d4d37b5f8af8f/v1 abec6e76169bcb738235ca67fab02cc55390f39e422aa71f1badf8747c290cc4/v1 - char str[65],str2[65]; printf("alice not eligible %.8f -> dest %.8f %.8f (%.8f %.8f) %s/v%d %s/v%d\n",dstr(qp->satoshis),dstr(qp->destsatoshis),(double)qp->destsatoshis/qp->satoshis,dstr(destvalue),dstr(destvalue2),bits256_str(str,qp->desttxid),qp->destvout,bits256_str(str2,qp->feetxid),qp->feevout); + //char str[65],str2[65]; printf("alice not eligible %.8f -> dest %.8f %.8f (%.8f %.8f) %s/v%d %s/v%d\n",dstr(qp->satoshis),dstr(qp->destsatoshis),(double)qp->destsatoshis/qp->satoshis,dstr(destvalue),dstr(destvalue2),bits256_str(str,qp->desttxid),qp->destvout,bits256_str(str2,qp->feetxid),qp->feevout); return(-3); } if ( (txout= LP_gettxout(qp->destcoin,qp->destaddr,qp->desttxid,qp->destvout)) != 0 ) @@ -321,7 +321,7 @@ int32_t LP_nearest_utxovalue(struct iguana_info *coin,char *coinaddr,struct LP_a } if ( replacei >= 0 ) { - printf("REPLACE bestdist %.8f height %d with dist %.8f height %d\n",dstr(bestdist),bestup->U.height,dstr(utxos[replacei]->U.value - targetval),utxos[replacei]->U.height); + //printf("REPLACE bestdist %.8f height %d with dist %.8f height %d\n",dstr(bestdist),bestup->U.height,dstr(utxos[replacei]->U.value - targetval),utxos[replacei]->U.height); return(replacei); } } @@ -396,7 +396,7 @@ struct LP_utxoinfo *LP_address_myutxopair(struct LP_utxoinfo *butxo,int32_t iamb { if ( (m= LP_address_utxo_ptrs(coin,iambob,utxos,max,ap,coinaddr)) > 1 ) { - if ( 1 ) + if ( 0 ) { int32_t i; for (i=0; i Date: Thu, 16 Nov 2017 17:32:03 +0200 Subject: [PATCH 02/18] Test --- iguana/exchanges/LP_include.h | 2 +- iguana/exchanges/LP_utxo.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/iguana/exchanges/LP_include.h b/iguana/exchanges/LP_include.h index 72f99d81f2..7ccde2a10a 100644 --- a/iguana/exchanges/LP_include.h +++ b/iguana/exchanges/LP_include.h @@ -23,7 +23,7 @@ #define LP_MAJOR_VERSION "0" #define LP_MINOR_VERSION "1" -#define LP_BUILD_NUMBER "15000" +#define LP_BUILD_NUMBER "15096" #ifdef FROM_JS #include diff --git a/iguana/exchanges/LP_utxo.c b/iguana/exchanges/LP_utxo.c index 59b8b8b8e8..90a6d016e5 100644 --- a/iguana/exchanges/LP_utxo.c +++ b/iguana/exchanges/LP_utxo.c @@ -999,7 +999,7 @@ int32_t LP_iseligible(uint64_t *valp,uint64_t *val2p,int32_t iambob,char *symbol strcpy(destaddr,destaddr2); if ( coin != 0 ) { - if ( coin->electrum != 0 ) + /*if ( coin->electrum != 0 ) { if ( (tx= LP_transactionfind(coin,txid)) != 0 && vout < tx->numvouts && tx->outpoints[vout].spendheight > 0 ) { @@ -1022,7 +1022,7 @@ int32_t LP_iseligible(uint64_t *valp,uint64_t *val2p,int32_t iambob,char *symbol return(0); } } - else + else*/ { if ( (txobj= LP_gettxout(coin->symbol,destaddr,txid,vout)) == 0 ) return(0); From 4b8b1553227da5c9cd0a4827a4c5134185c6e98a Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Nov 2017 17:48:46 +0200 Subject: [PATCH 03/18] Test --- iguana/exchanges/LP_ordermatch.c | 1 + 1 file changed, 1 insertion(+) diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index f28c779bd2..0d1590bfca 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -1126,6 +1126,7 @@ 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; + LP_address_utxo_reset(relcoin); if ( (autxo= LP_utxo_bestfit(rel,destsatoshis + 2*desttxfee)) == 0 ) return(clonestr("{\"error\":\"cant find alice utxo that is big enough\"}")); //printf("bestfit selected alice (%.8f %.8f) for %.8f sats %.8f\n",dstr(autxo->payment.value),dstr(autxo->fee.value),dstr(destsatoshis),dstr(autxo->S.satoshis)); From 5c15665ca64091e9ec5e30f4836a6e79c73bb98f Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Nov 2017 17:56:47 +0200 Subject: [PATCH 04/18] Test --- iguana/exchanges/LP_signatures.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_signatures.c b/iguana/exchanges/LP_signatures.c index 0008ee1b5e..e729421ad4 100644 --- a/iguana/exchanges/LP_signatures.c +++ b/iguana/exchanges/LP_signatures.c @@ -704,7 +704,7 @@ void LP_query(void *ctx,char *myipaddr,int32_t mypubsock,char *method,struct LP_ jaddnum(reqjson,"timestamp",time(NULL)); msg = jprint(reqjson,1); msg2 = clonestr(msg); - //printf("QUERY.(%s)\n",msg); + printf("QUERY.(%s)\n",msg); memset(&zero,0,sizeof(zero)); portable_mutex_lock(&LP_reservedmutex); if ( num_Reserved_msgs[1] < sizeof(Reserved_msgs[1])/sizeof(*Reserved_msgs[1])-2 ) From 380c7d0ec24d71c982074dd8b11f16860df77f8c Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Nov 2017 18:01:04 +0200 Subject: [PATCH 05/18] Test --- iguana/exchanges/LP_utxo.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iguana/exchanges/LP_utxo.c b/iguana/exchanges/LP_utxo.c index 90a6d016e5..21e89c92a7 100644 --- a/iguana/exchanges/LP_utxo.c +++ b/iguana/exchanges/LP_utxo.c @@ -405,7 +405,7 @@ int32_t LP_address_utxoadd(uint32_t timestamp,char *debug,struct iguana_info *co up->SPV = tx->SPV; } char str[65]; - if ( 0 && strcmp(coin->smartaddr,coinaddr) == 0 && strcmp("KMD",coin->symbol) == 0 ) + if ( strcmp(coin->smartaddr,coinaddr) == 0 && strcmp("KMD",coin->symbol) == 0 ) printf("%s ADD UTXO >> %s %s %s/v%d ht.%d %.8f\n",debug,coin->symbol,coinaddr,bits256_str(str,txid),vout,height,dstr(value)); portable_mutex_lock(&coin->addrmutex); DL_APPEND(ap->utxos,up); @@ -464,7 +464,7 @@ struct LP_address *LP_address_utxo_reset(struct iguana_info *coin) 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)); } - //printf("added %d from listunspents\n",n); + printf("added %d from listunspents\n",n); } free_json(array); } From 6c24e6c05656cbb5e112906f9d7c3fc2ea0f2592 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Nov 2017 18:06:18 +0200 Subject: [PATCH 06/18] 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 0d1590bfca..48fea4b1f1 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -791,6 +791,7 @@ int32_t LP_tradecommand(void *ctx,char *myipaddr,int32_t pubsock,cJSON *argjson, } if ( bits256_cmp(G.LP_mypub25519,Q.desthash) == 0 && bits256_cmp(G.LP_mypub25519,Q.srchash) != 0 && LP_alice_eligible() > 0 ) { + printf("alice %s received RESERVED.(%s)\n",bits256_str(str,G.LP_mypub25519),jprint(argjson,0)); if ( (qprice= LP_quote_validate(autxo,butxo,&Q,0)) <= SMALLVAL ) { printf("reserved quote validate error %.0f\n",qprice); @@ -807,7 +808,6 @@ int32_t LP_tradecommand(void *ctx,char *myipaddr,int32_t pubsock,cJSON *argjson, return(retval); } LP_aliceid(Q.tradeid,Q.aliceid,"reserved",0,0); - //printf("alice %s received RESERVED.(%s)\n",bits256_str(str,G.LP_mypub25519),jprint(argjson,0)); if ( (retstr= LP_quotereceived(argjson)) != 0 ) free(retstr); LP_reserved(ctx,myipaddr,pubsock,&Q); From da4fe5720ad21b6b4abc89da7fcc04773524f782 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Nov 2017 18:12:07 +0200 Subject: [PATCH 07/18] Test --- iguana/exchanges/LP_ordermatch.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index 48fea4b1f1..c00ef313ab 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -532,9 +532,9 @@ void LP_alicequery_clear() Alice_expiration = 0; } -int32_t LP_alice_eligible() +int32_t LP_alice_eligible(uint32_t quotetime) { - if ( Alice_expiration != 0 && time(NULL) > Alice_expiration ) + if ( Alice_expiration != 0 && quotetime > Alice_expiration ) { printf("time expired for Alice_request\n"); LP_alicequery_clear(); @@ -545,7 +545,7 @@ int32_t LP_alice_eligible() void LP_reserved(void *ctx,char *myipaddr,int32_t mypubsock,struct LP_quoteinfo *qp) { double price=0.,maxprice = LP_Alicemaxprice; - if ( LP_alice_eligible() > 0 && LP_quotecmp(qp,&LP_Alicequery) == 0 ) + if ( LP_quotecmp(qp,&LP_Alicequery) == 0 ) { price = LP_pricecache(qp,qp->srccoin,qp->destcoin,qp->txid,qp->vout); if ( LP_pricevalid(price) > 0 && maxprice > SMALLVAL && price <= maxprice ) @@ -555,7 +555,7 @@ void LP_reserved(void *ctx,char *myipaddr,int32_t mypubsock,struct LP_quoteinfo printf("send CONNECT\n"); LP_query(ctx,myipaddr,mypubsock,"connect",qp); } else printf("LP_reserved price %.8f vs maxprice %.8f\n",price,maxprice*1.005); - } else printf("probably a timeout, reject reserved due to not eligible.%d or mismatched quote price %.8f vs maxprice %.8f\n",LP_alice_eligible(),price,maxprice); + } else printf("probably a timeout, reject reserved due to not eligible.%d or mismatched quote price %.8f vs maxprice %.8f\n",LP_alice_eligible(qp->quotetime),price,maxprice); } char *LP_connectedalice(cJSON *argjson) // alice @@ -789,7 +789,7 @@ int32_t LP_tradecommand(void *ctx,char *myipaddr,int32_t pubsock,cJSON *argjson, return(retval); } else printf("got reserved response from destpubkey %s\n",bits256_str(str,Q.srchash)); } - if ( bits256_cmp(G.LP_mypub25519,Q.desthash) == 0 && bits256_cmp(G.LP_mypub25519,Q.srchash) != 0 && LP_alice_eligible() > 0 ) + if ( bits256_cmp(G.LP_mypub25519,Q.desthash) == 0 && bits256_cmp(G.LP_mypub25519,Q.srchash) != 0 && Q.quotetime > time(NULL)-20 && LP_alice_eligible(Q.quotetime) > 0 ) { printf("alice %s received RESERVED.(%s)\n",bits256_str(str,G.LP_mypub25519),jprint(argjson,0)); if ( (qprice= LP_quote_validate(autxo,butxo,&Q,0)) <= SMALLVAL ) From dc259fe34f9894d027d37d346ead41597beaa8ed Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Nov 2017 18:13:25 +0200 Subject: [PATCH 08/18] 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 21e89c92a7..e9ff90d3ad 100644 --- a/iguana/exchanges/LP_utxo.c +++ b/iguana/exchanges/LP_utxo.c @@ -405,7 +405,7 @@ int32_t LP_address_utxoadd(uint32_t timestamp,char *debug,struct iguana_info *co up->SPV = tx->SPV; } char str[65]; - if ( strcmp(coin->smartaddr,coinaddr) == 0 && strcmp("KMD",coin->symbol) == 0 ) + if ( 0 && strcmp(coin->smartaddr,coinaddr) == 0 && strcmp("KMD",coin->symbol) == 0 ) printf("%s ADD UTXO >> %s %s %s/v%d ht.%d %.8f\n",debug,coin->symbol,coinaddr,bits256_str(str,txid),vout,height,dstr(value)); portable_mutex_lock(&coin->addrmutex); DL_APPEND(ap->utxos,up); From 77ffa9bfaa3b64cce3abaefc7fe79da8617cea1c Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Nov 2017 18:22:41 +0200 Subject: [PATCH 09/18] Test --- crypto777/cJSON.c | 4 ++-- iguana/exchanges/LP_nativeDEX.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/crypto777/cJSON.c b/crypto777/cJSON.c index 901e6fc98b..54df964f5a 100755 --- a/crypto777/cJSON.c +++ b/crypto777/cJSON.c @@ -56,8 +56,8 @@ static int32_t cJSON_strcasecmp(const char *s1,const char *s2) void *LP_alloc(uint64_t len); void LP_free(void *ptr); -static void *(*cJSON_malloc)(size_t sz) = (void *)LP_alloc; -static void (*cJSON_free)(void *ptr) = LP_free; +static void *(*cJSON_malloc)(size_t sz) = (void *)malloc;//LP_alloc; +static void (*cJSON_free)(void *ptr) = free;//LP_free; static void *cJSON_mallocstr(int32_t len) { diff --git a/iguana/exchanges/LP_nativeDEX.c b/iguana/exchanges/LP_nativeDEX.c index 30e1d97537..f73c9474f8 100644 --- a/iguana/exchanges/LP_nativeDEX.c +++ b/iguana/exchanges/LP_nativeDEX.c @@ -1043,7 +1043,7 @@ void LPinit(uint16_t myport,uint16_t mypullport,uint16_t mypubport,uint16_t mybu printf("error launching LP_reserved_msgs for (%s)\n",myipaddr); exit(-1); } - if ( 0 && OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)utxosQ_loop,(void *)myipaddr) != 0 ) + if ( OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)utxosQ_loop,(void *)myipaddr) != 0 ) { printf("error launching utxosQ_loop for (%s)\n",myipaddr); exit(-1); @@ -1216,7 +1216,7 @@ int32_t zeroval() { return(0); } void *LP_alloc(uint64_t len) { -return(calloc(1,len)); +//return(calloc(1,len)); LP_cjson_allocated += len; LP_cjson_total += len; LP_cjson_count++; @@ -1235,7 +1235,7 @@ return(calloc(1,len)); void LP_free(void *ptr) { static uint32_t lasttime,unknown; static int64_t lasttotal; -free(ptr); return; +//free(ptr); return; uint32_t now; char str[65]; int32_t n,lagging; uint64_t total = 0; struct LP_memory_list *mp,*tmp; if ( (now= (uint32_t)time(NULL)) > lasttime+1 ) { From 5d0933752975bcc44ae8297761e755b57247bcfd Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Nov 2017 18:28:46 +0200 Subject: [PATCH 10/18] Test --- iguana/exchanges/LP_ordermatch.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index c00ef313ab..fb294d2dc9 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -505,7 +505,7 @@ char *LP_trade(void *ctx,char *myipaddr,int32_t mypubsock,struct LP_quoteinfo *q qp->tradeid = tradeid; LP_query(ctx,myipaddr,mypubsock,"request",qp); LP_Alicequery = *qp, LP_Alicemaxprice = maxprice, Alice_expiration = qp->timestamp + timeout, LP_Alicedestpubkey = destpubkey; - char str[65]; printf("LP_trade %s/%s %.8f vol %.8f dest.(%s)\n",qp->srccoin,qp->destcoin,dstr(qp->satoshis),dstr(qp->destsatoshis),bits256_str(str,LP_Alicedestpubkey)); + char str[65]; printf("LP_trade %s/%s %.8f vol %.8f dest.(%s) maxprice %.8f\n",qp->srccoin,qp->destcoin,dstr(qp->satoshis),dstr(qp->destsatoshis),bits256_str(str,LP_Alicedestpubkey),maxprice); return(LP_recent_swaps(0)); } @@ -778,7 +778,7 @@ int32_t LP_tradecommand(void *ctx,char *myipaddr,int32_t pubsock,cJSON *argjson, if ( strcmp(method,"reserved") == 0 ) { bestprice = LP_bob_competition(&counter,aliceid,qprice,1); - //printf("aliceid.%llu price %.8f -> bestprice %.8f\n",(long long)aliceid,qprice,bestprice); + printf("aliceid.%llu price %.8f -> bestprice %.8f Alice max %.8f\n",(long long)aliceid,qprice,bestprice,LP_Alicemaxprice); if ( LP_Alicemaxprice == 0. ) return(retval); if ( bits256_nonz(LP_Alicedestpubkey) != 0 ) From d00e0b0e8be5264babf39084d0cc165efc74f799 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Nov 2017 18:32:07 +0200 Subject: [PATCH 11/18] 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 fb294d2dc9..a8d8f98c83 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -778,7 +778,7 @@ int32_t LP_tradecommand(void *ctx,char *myipaddr,int32_t pubsock,cJSON *argjson, if ( strcmp(method,"reserved") == 0 ) { bestprice = LP_bob_competition(&counter,aliceid,qprice,1); - printf("aliceid.%llu price %.8f -> bestprice %.8f Alice max %.8f\n",(long long)aliceid,qprice,bestprice,LP_Alicemaxprice); + printf("%s lag %ld: aliceid.%llu price %.8f -> bestprice %.8f Alice max %.8f\n",jprint(argjson,0),Q.quotetime - (time(NULL)-20),(long long)aliceid,qprice,bestprice,LP_Alicemaxprice); if ( LP_Alicemaxprice == 0. ) return(retval); if ( bits256_nonz(LP_Alicedestpubkey) != 0 ) From f3794fe375cff809f3d251e5546b4e875886aaa3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Nov 2017 18:34:14 +0200 Subject: [PATCH 12/18] Test --- iguana/exchanges/LP_ordermatch.c | 1 + 1 file changed, 1 insertion(+) diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index a8d8f98c83..0927b5222a 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -904,6 +904,7 @@ int32_t LP_tradecommand(void *ctx,char *myipaddr,int32_t pubsock,cJSON *argjson, Q.txid2 = butxo->deposit.txid; Q.vout2 = butxo->deposit.vout; Q.satoshis = butxo->S.satoshis; + Q.quotetime = (uint32_t)time(NULL); printf("found %.8f -> %.8f newprice %.8f vs ask %.8f += %.8f qprice %.8f\n",dstr(Q.satoshis),dstr(Q.destsatoshis),(double)Q.destsatoshis/Q.satoshis,ask,price,qprice); } else From 271ef52511e436f219dc12b0a53a3c3ad2d1252c Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Nov 2017 18:34:41 +0200 Subject: [PATCH 13/18] Test --- iguana/exchanges/LP_include.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iguana/exchanges/LP_include.h b/iguana/exchanges/LP_include.h index 7ccde2a10a..e1a8c933d8 100644 --- a/iguana/exchanges/LP_include.h +++ b/iguana/exchanges/LP_include.h @@ -24,6 +24,8 @@ #define LP_MAJOR_VERSION "0" #define LP_MINOR_VERSION "1" #define LP_BUILD_NUMBER "15096" +#define LP_BARTERDEX_VERSION 2 +#define LP_MAGICBITS 8 #ifdef FROM_JS #include @@ -38,8 +40,6 @@ void emscripten_usleep(int32_t x); // returns immediate, no sense for sleeping #endif //#define LP_STRICTPEERS -#define LP_BARTERDEX_VERSION 1 -#define LP_MAGICBITS 8 #define LP_MAXVINS 64 #define LP_HTTP_TIMEOUT 3 // 1 is too small due to edge cases of time(NULL) From 367b9b0dfa37cdae981204509bfd666f3183c8df Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Nov 2017 18:35:21 +0200 Subject: [PATCH 14/18] Test --- iguana/exchanges/LP_include.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_include.h b/iguana/exchanges/LP_include.h index e1a8c933d8..c728dee1fb 100644 --- a/iguana/exchanges/LP_include.h +++ b/iguana/exchanges/LP_include.h @@ -180,7 +180,7 @@ struct basilisk_request int64_t srcamount,unused; // 16 to 31 bits256 srchash; // 32 to 63 bits256 desthash; - char src[65],dest[65]; + char src[68],dest[68]; uint64_t destamount; int32_t optionhours,DEXselector; }; From 05e76ee08b8547895ed5e54a5a8cf626c461101e Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Nov 2017 18:36:55 +0200 Subject: [PATCH 15/18] Test --- iguana/exchanges/LP_network.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iguana/exchanges/LP_network.c b/iguana/exchanges/LP_network.c index d1b147bc8b..5449dc7d76 100644 --- a/iguana/exchanges/LP_network.c +++ b/iguana/exchanges/LP_network.c @@ -204,8 +204,8 @@ int32_t LP_magic_check(uint8_t *msg,int32_t recvlen,char *remoteaddr) vcalc_sha256(0,hash.bytes,msg,recvlen); memcpy(magic.bytes,&msg[recvlen],sizeof(magic)); val = _LP_magic_check(hash,magic); - if ( val != LP_BARTERDEX_VERSION ) - printf("magicval = %x from %s\n",val,remoteaddr); + //if ( val != LP_BARTERDEX_VERSION ) + // printf("magicval = %x from %s\n",val,remoteaddr); return(val == LP_BARTERDEX_VERSION); } return(-1); From ff2c4f62256a7526086ee4b225fb8984687aff21 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Nov 2017 18:41:38 +0200 Subject: [PATCH 16/18] Test --- iguana/exchanges/LP_include.h | 2 +- iguana/exchanges/LP_network.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/iguana/exchanges/LP_include.h b/iguana/exchanges/LP_include.h index c728dee1fb..f66fcc9c1b 100644 --- a/iguana/exchanges/LP_include.h +++ b/iguana/exchanges/LP_include.h @@ -24,7 +24,7 @@ #define LP_MAJOR_VERSION "0" #define LP_MINOR_VERSION "1" #define LP_BUILD_NUMBER "15096" -#define LP_BARTERDEX_VERSION 2 +#define LP_BARTERDEX_VERSION 1 #define LP_MAGICBITS 8 #ifdef FROM_JS diff --git a/iguana/exchanges/LP_network.c b/iguana/exchanges/LP_network.c index 5449dc7d76..d1b147bc8b 100644 --- a/iguana/exchanges/LP_network.c +++ b/iguana/exchanges/LP_network.c @@ -204,8 +204,8 @@ int32_t LP_magic_check(uint8_t *msg,int32_t recvlen,char *remoteaddr) vcalc_sha256(0,hash.bytes,msg,recvlen); memcpy(magic.bytes,&msg[recvlen],sizeof(magic)); val = _LP_magic_check(hash,magic); - //if ( val != LP_BARTERDEX_VERSION ) - // printf("magicval = %x from %s\n",val,remoteaddr); + if ( val != LP_BARTERDEX_VERSION ) + printf("magicval = %x from %s\n",val,remoteaddr); return(val == LP_BARTERDEX_VERSION); } return(-1); From 070cc756eccb63a296fc4fa14d88eeab2a6b3cd7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Nov 2017 18:55:33 +0200 Subject: [PATCH 17/18] Test --- iguana/exchanges/LP_ordermatch.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index 0927b5222a..6ae82acf08 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -778,7 +778,7 @@ int32_t LP_tradecommand(void *ctx,char *myipaddr,int32_t pubsock,cJSON *argjson, if ( strcmp(method,"reserved") == 0 ) { bestprice = LP_bob_competition(&counter,aliceid,qprice,1); - printf("%s lag %ld: aliceid.%llu price %.8f -> bestprice %.8f Alice max %.8f\n",jprint(argjson,0),Q.quotetime - (time(NULL)-20),(long long)aliceid,qprice,bestprice,LP_Alicemaxprice); + //printf("%s lag %ld: aliceid.%llu price %.8f -> bestprice %.8f Alice max %.8f\n",jprint(argjson,0),Q.quotetime - (time(NULL)-20),(long long)aliceid,qprice,bestprice,LP_Alicemaxprice); if ( LP_Alicemaxprice == 0. ) return(retval); if ( bits256_nonz(LP_Alicedestpubkey) != 0 ) @@ -948,9 +948,11 @@ int32_t LP_tradecommand(void *ctx,char *myipaddr,int32_t pubsock,cJSON *argjson, retjson = LP_quotejson(&Q); LP_unavailableset(Q.txid,Q.vout,Q.timestamp + LP_RESERVETIME,Q.desthash); LP_unavailableset(Q.txid2,Q.vout2,Q.timestamp + LP_RESERVETIME,Q.desthash); + if ( Q.quotetime == 0 ) + Q.quotetime = (uint32_t)time(NULL); jaddnum(retjson,"quotetime",Q.quotetime); jaddnum(retjson,"pending",Q.timestamp + LP_RESERVETIME); - jaddbits256(retjson,"desthash",Q.desthash); + //jaddbits256(retjson,"desthash",Q.desthash); jaddstr(retjson,"method","reserved"); msg = jprint(retjson,0); printf("return after queued RESERVED: set swappending.%u accept qprice %.8f, min %.8f\n(%s)\n",Q.timestamp + LP_RESERVETIME,qprice,ask,msg); From eb3d5667eded61cd05aa66b33c24791680549a3a Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Nov 2017 19:03:47 +0200 Subject: [PATCH 18/18] Test --- iguana/exchanges/LP_ordermatch.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index 6ae82acf08..435e32cb18 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -502,7 +502,8 @@ char *LP_trade(void *ctx,char *myipaddr,int32_t mypubsock,struct LP_quoteinfo *q memset(qp->txid.bytes,0,sizeof(qp->txid)); qp->txid2 = qp->txid; qp->aliceid = LP_aliceid_calc(qp->desttxid,qp->destvout,qp->feetxid,qp->feevout); - qp->tradeid = tradeid; + if ( (qp->tradeid= tradeid) == 0 ) + qp->tradeid = LP_rand(); LP_query(ctx,myipaddr,mypubsock,"request",qp); LP_Alicequery = *qp, LP_Alicemaxprice = maxprice, Alice_expiration = qp->timestamp + timeout, LP_Alicedestpubkey = destpubkey; char str[65]; printf("LP_trade %s/%s %.8f vol %.8f dest.(%s) maxprice %.8f\n",qp->srccoin,qp->destcoin,dstr(qp->satoshis),dstr(qp->destsatoshis),bits256_str(str,LP_Alicedestpubkey),maxprice);