From 58e9d6725b736a67b8a64e89b4c48e27f4b92b32 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 25 Feb 2018 20:16:18 +0200 Subject: [PATCH 1/7] Test --- iguana/exchanges/LP_signatures.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/iguana/exchanges/LP_signatures.c b/iguana/exchanges/LP_signatures.c index 1c400bf4c..fadbc3693 100644 --- a/iguana/exchanges/LP_signatures.c +++ b/iguana/exchanges/LP_signatures.c @@ -674,21 +674,11 @@ void LP_query(void *ctx,char *myipaddr,int32_t mypubsock,char *method,struct LP_ jadd(reqjson,"proof",LP_instantdex_txids(0,coin->smartaddr)); } msg = jprint(reqjson,1); - //printf("QUERY.(%s)\n",msg); - //if ( bits256_nonz(qp->srchash) == 0 || strcmp(method,"request") != 0 ) - { - memset(&zero,0,sizeof(zero)); - if ( bits256_nonz(qp->srchash) != 0 ) - LP_reserved_msg(1,qp->srccoin,qp->destcoin,qp->srchash,clonestr(msg)); - LP_reserved_msg(1,qp->srccoin,qp->destcoin,zero,clonestr(msg)); - LP_reserved_msg(0,qp->srccoin,qp->destcoin,zero,clonestr(msg)); - free(msg); - /*portable_mutex_lock(&LP_reservedmutex); - if ( num_Reserved_msgs[1] < sizeof(Reserved_msgs[1])/sizeof(*Reserved_msgs[1])-2 ) - Reserved_msgs[1][num_Reserved_msgs[1]++] = msg; - if ( num_Reserved_msgs[0] < sizeof(Reserved_msgs[0])/sizeof(*Reserved_msgs[0])-2 ) - Reserved_msgs[0][num_Reserved_msgs[0]++] = msg2; - portable_mutex_unlock(&LP_reservedmutex);*/ - } //else LP_broadcast_message(LP_mypubsock,qp->srccoin,qp->destcoin,qp->srchash,msg); + memset(&zero,0,sizeof(zero)); + if ( bits256_nonz(qp->srchash) != 0 ) + LP_reserved_msg(1,qp->srccoin,qp->destcoin,qp->srchash,clonestr(msg)); + printf("QUERY.(%s)\n",msg); + LP_reserved_msg(1,qp->srccoin,qp->destcoin,zero,clonestr(msg)); + free(msg); } From c70734ad047e74dabe5a4b17854d5eec50302bb8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 25 Feb 2018 20:17:39 +0200 Subject: [PATCH 2/7] Remove insync check --- iguana/exchanges/LP_commands.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iguana/exchanges/LP_commands.c b/iguana/exchanges/LP_commands.c index f5f0c8eca..562e17b6a 100644 --- a/iguana/exchanges/LP_commands.c +++ b/iguana/exchanges/LP_commands.c @@ -460,12 +460,12 @@ jpg(srcfile, destfile, power2=7, password, data="", required, ind=0)\n\ { ptr->inactive = 0; cJSON *array; int32_t notarized; - if ( strcmp(ptr->symbol,"ETH") != 0 && LP_getheight(¬arized,ptr) <= 0 ) + /*if ( strcmp(ptr->symbol,"ETH") != 0 && LP_getheight(¬arized,ptr) <= 0 ) { ptr->inactive = (uint32_t)time(NULL); return(clonestr("{\"error\":\"coin cant be activated till synced\"}")); } - else + else*/ { if ( ptr->smartaddr[0] != 0 ) LP_unspents_load(coin,ptr->smartaddr); From b86894f93753ca2e17ee525520a0347f820ab081 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 25 Feb 2018 20:19:36 +0200 Subject: [PATCH 3/7] Test --- iguana/exchanges/LP_commands.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_commands.c b/iguana/exchanges/LP_commands.c index 562e17b6a..b2c71b850 100644 --- a/iguana/exchanges/LP_commands.c +++ b/iguana/exchanges/LP_commands.c @@ -459,7 +459,7 @@ jpg(srcfile, destfile, power2=7, password, data="", required, ind=0)\n\ if ( LP_conflicts_find(ptr) == 0 ) { ptr->inactive = 0; - cJSON *array; int32_t notarized; + cJSON *array; //int32_t notarized; /*if ( strcmp(ptr->symbol,"ETH") != 0 && LP_getheight(¬arized,ptr) <= 0 ) { ptr->inactive = (uint32_t)time(NULL); From 266bf0fa12ba3c19dba8aa738b0dc6a9003cadf0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 25 Feb 2018 20:26:44 +0200 Subject: [PATCH 4/7] Test --- iguana/exchanges/LP_ordermatch.c | 2 +- iguana/exchanges/LP_rpc.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index 1a1f2054f..e9d6c41c3 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -190,7 +190,7 @@ double LP_quote_validate(struct LP_utxoinfo *autxo,struct LP_utxoinfo *butxo,str //printf("qprice %.8f <- %.8f/%.8f txfees.(%.8f %.8f) vs (%.8f %.8f)\n",qprice,dstr(qp->destsatoshis),dstr(qp->satoshis),dstr(qp->txfee),dstr(qp->desttxfee),dstr(txfee),dstr(desttxfee)); if ( qp->txfee < LP_REQUIRED_TXFEE*txfee || qp->desttxfee < LP_REQUIRED_TXFEE*desttxfee ) { - printf("error -14: txfee %.8f >= %.8f or desttxfee %.8f >= %.8f\n",dstr(qp->txfee),dstr(LP_REQUIRED_TXFEE*txfee),dstr(qp->desttxfee),dstr(LP_REQUIRED_TXFEE*desttxfee)); + printf("error -14: txfee %.8f < %.8f or desttxfee %.8f < %.8f\n",dstr(qp->txfee),dstr(LP_REQUIRED_TXFEE*txfee),dstr(qp->desttxfee),dstr(LP_REQUIRED_TXFEE*desttxfee)); return(-14); } if ( butxo != 0 ) diff --git a/iguana/exchanges/LP_rpc.c b/iguana/exchanges/LP_rpc.c index a134e03c1..2a881379f 100644 --- a/iguana/exchanges/LP_rpc.c +++ b/iguana/exchanges/LP_rpc.c @@ -687,7 +687,7 @@ again: rate = atof(retstr) / 1024.; if ( rate != 0. ) { - rate *= 1.25; + //rate *= 1.25; if ( rate < 0.00000005 ) rate = 0.00000005; //if ( coin->electrum != 0 ) From acd597681ffad5c2a8f4720860c6c370902a0600 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 25 Feb 2018 20:38:11 +0200 Subject: [PATCH 5/7] test --- iguana/exchanges/LP_rpc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iguana/exchanges/LP_rpc.c b/iguana/exchanges/LP_rpc.c index 2a881379f..5e4fbdf63 100644 --- a/iguana/exchanges/LP_rpc.c +++ b/iguana/exchanges/LP_rpc.c @@ -650,8 +650,8 @@ again: fastest = jint(retjson,"fastestFee"); half = jint(retjson,"halfHourFee"); hour = jint(retjson,"hourFee"); - if ( hour*2 > half ) - best = hour*2; + if ( hour*3 > half ) + best = hour*3; else best = half; if ( fastest < best ) best = fastest; From bba9ce385d55dad4698b4fe550c5381499f84959 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 25 Feb 2018 20:41:12 +0200 Subject: [PATCH 6/7] Test --- iguana/exchanges/LP_rpc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_rpc.c b/iguana/exchanges/LP_rpc.c index 5e4fbdf63..490808be3 100644 --- a/iguana/exchanges/LP_rpc.c +++ b/iguana/exchanges/LP_rpc.c @@ -634,7 +634,7 @@ double _LP_getestimatedrate(struct iguana_info *coin) { if ( coin->estimatefeestr[0] == 0 ) strcpy(coin->estimatefeestr,"estimatefee"); - numblocks = 2;//strcmp(coin->symbol,"BTC") == 0 ? 6 : 2; + numblocks = 3;//strcmp(coin->symbol,"BTC") == 0 ? 6 : 2; again: if ( coin->electrum == 0 ) { From ffbdfc75a3a622b537f89db9598909ee915cd462 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 25 Feb 2018 20:59:48 +0200 Subject: [PATCH 7/7] Test --- iguana/exchanges/LP_include.h | 2 +- iguana/exchanges/LP_ordermatch.c | 17 +++++++++++------ iguana/exchanges/LP_swap.c | 1 + 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/iguana/exchanges/LP_include.h b/iguana/exchanges/LP_include.h index 069263a2c..4605ad978 100644 --- a/iguana/exchanges/LP_include.h +++ b/iguana/exchanges/LP_include.h @@ -390,7 +390,7 @@ struct basilisk_swap struct LP_endpoint N; void (*balancingtrade)(struct basilisk_swap *swap,int32_t iambob); int32_t subsock,pushsock,connected,aliceunconf,depositunconf,paymentunconf; - uint32_t lasttime,aborted,tradeid; + uint32_t lasttime,aborted,tradeid,received; FILE *fp; bits256 persistent_privkey,persistent_pubkey; struct basilisk_swapinfo I; diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index e9d6c41c3..ae28b6e82 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -451,7 +451,7 @@ struct LP_utxoinfo *LP_address_myutxopair(struct LP_utxoinfo *butxo,int32_t iamb int32_t LP_connectstartbob(void *ctx,int32_t pubsock,char *base,char *rel,double price,struct LP_quoteinfo *qp) { - char pairstr[512],otheraddr[64]; cJSON *reqjson; bits256 privkey; int32_t pair=-1,retval = -1,DEXselector = 0; int64_t dtrust; struct basilisk_swap *swap; struct iguana_info *coin,*kmdcoin; + char pairstr[512],otheraddr[64]; cJSON *reqjson; bits256 privkey; int32_t i,pair=-1,retval = -1,DEXselector = 0; int64_t dtrust; struct basilisk_swap *swap; struct iguana_info *coin,*kmdcoin; qp->quotetime = (uint32_t)time(NULL); if ( (coin= LP_coinfind(qp->srccoin)) == 0 ) { @@ -486,12 +486,17 @@ int32_t LP_connectstartbob(void *ctx,int32_t pubsock,char *base,char *rel,double //char str[65]; printf("BOB pubsock.%d binds to %d (%s)\n",pubsock,pair,bits256_str(str,qp->desthash)); bits256 zero; memset(zero.bytes,0,sizeof(zero)); - LP_reserved_msg(1,qp->srccoin,qp->destcoin,qp->desthash,jprint(reqjson,0)); - LP_reserved_msg(1,qp->srccoin,qp->destcoin,zero,jprint(reqjson,0)); - if ( 0 ) + for (i=0; i<10; i++) { - LP_reserved_msg(1,base,rel,zero,jprint(reqjson,0)); - LP_reserved_msg(0,base,rel,zero,jprint(reqjson,0)); + LP_reserved_msg(1,qp->srccoin,qp->destcoin,qp->desthash,jprint(reqjson,0)); + sleep(3); + if ( swap->received != 0 ) + { + printf("swap %u-%u has started t%u\n",swap->I.req.requestid,swap->I.req.quoteid,swap->received); + break; + } + printf("bob tries %u-%u again i.%d\n",swap->I.req.requestid,swap->I.req.quoteid,i); + LP_reserved_msg(1,qp->srccoin,qp->destcoin,zero,jprint(reqjson,0)); } free_json(reqjson); LP_importaddress(qp->destcoin,qp->destaddr); diff --git a/iguana/exchanges/LP_swap.c b/iguana/exchanges/LP_swap.c index 54381b613..bb6c50dda 100644 --- a/iguana/exchanges/LP_swap.c +++ b/iguana/exchanges/LP_swap.c @@ -473,6 +473,7 @@ int32_t LP_waitfor(int32_t pairsock,struct basilisk_swap *swap,int32_t timeout,i { //printf("wait for got.%d\n",datalen); retval = (*verify)(swap,data,datalen); + swap->received = (uint32_t)time(NULL); nn_freemsg(data); //printf("retval.%d\n",retval); return(retval);