Browse Source

Merge pull request #612 from jl777/beta

Beta
patch-1
jl777 7 years ago
committed by GitHub
parent
commit
269a589c9f
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      iguana/exchanges/LP_commands.c
  2. 2
      iguana/exchanges/LP_include.h
  3. 17
      iguana/exchanges/LP_ordermatch.c
  4. 8
      iguana/exchanges/LP_rpc.c
  5. 12
      iguana/exchanges/LP_signatures.c
  6. 1
      iguana/exchanges/LP_swap.c

6
iguana/exchanges/LP_commands.c

@ -459,13 +459,13 @@ jpg(srcfile, destfile, power2=7, password, data="", required, ind=0)\n\
if ( LP_conflicts_find(ptr) == 0 ) if ( LP_conflicts_find(ptr) == 0 )
{ {
ptr->inactive = 0; ptr->inactive = 0;
cJSON *array; int32_t notarized; cJSON *array; //int32_t notarized;
if ( strcmp(ptr->symbol,"ETH") != 0 && LP_getheight(&notarized,ptr) <= 0 ) /*if ( strcmp(ptr->symbol,"ETH") != 0 && LP_getheight(&notarized,ptr) <= 0 )
{ {
ptr->inactive = (uint32_t)time(NULL); ptr->inactive = (uint32_t)time(NULL);
return(clonestr("{\"error\":\"coin cant be activated till synced\"}")); return(clonestr("{\"error\":\"coin cant be activated till synced\"}"));
} }
else else*/
{ {
if ( ptr->smartaddr[0] != 0 ) if ( ptr->smartaddr[0] != 0 )
LP_unspents_load(coin,ptr->smartaddr); LP_unspents_load(coin,ptr->smartaddr);

2
iguana/exchanges/LP_include.h

@ -390,7 +390,7 @@ struct basilisk_swap
struct LP_endpoint N; struct LP_endpoint N;
void (*balancingtrade)(struct basilisk_swap *swap,int32_t iambob); void (*balancingtrade)(struct basilisk_swap *swap,int32_t iambob);
int32_t subsock,pushsock,connected,aliceunconf,depositunconf,paymentunconf; int32_t subsock,pushsock,connected,aliceunconf,depositunconf,paymentunconf;
uint32_t lasttime,aborted,tradeid; uint32_t lasttime,aborted,tradeid,received;
FILE *fp; FILE *fp;
bits256 persistent_privkey,persistent_pubkey; bits256 persistent_privkey,persistent_pubkey;
struct basilisk_swapinfo I; struct basilisk_swapinfo I;

17
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)); //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 ) 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); return(-14);
} }
if ( butxo != 0 ) if ( butxo != 0 )
@ -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) 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); qp->quotetime = (uint32_t)time(NULL);
if ( (coin= LP_coinfind(qp->srccoin)) == 0 ) 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)); //char str[65]; printf("BOB pubsock.%d binds to %d (%s)\n",pubsock,pair,bits256_str(str,qp->desthash));
bits256 zero; bits256 zero;
memset(zero.bytes,0,sizeof(zero)); memset(zero.bytes,0,sizeof(zero));
for (i=0; i<10; i++)
{
LP_reserved_msg(1,qp->srccoin,qp->destcoin,qp->desthash,jprint(reqjson,0)); 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)); sleep(3);
if ( 0 ) if ( swap->received != 0 )
{ {
LP_reserved_msg(1,base,rel,zero,jprint(reqjson,0)); printf("swap %u-%u has started t%u\n",swap->I.req.requestid,swap->I.req.quoteid,swap->received);
LP_reserved_msg(0,base,rel,zero,jprint(reqjson,0)); 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); free_json(reqjson);
LP_importaddress(qp->destcoin,qp->destaddr); LP_importaddress(qp->destcoin,qp->destaddr);

8
iguana/exchanges/LP_rpc.c

@ -634,7 +634,7 @@ double _LP_getestimatedrate(struct iguana_info *coin)
{ {
if ( coin->estimatefeestr[0] == 0 ) if ( coin->estimatefeestr[0] == 0 )
strcpy(coin->estimatefeestr,"estimatefee"); strcpy(coin->estimatefeestr,"estimatefee");
numblocks = 2;//strcmp(coin->symbol,"BTC") == 0 ? 6 : 2; numblocks = 3;//strcmp(coin->symbol,"BTC") == 0 ? 6 : 2;
again: again:
if ( coin->electrum == 0 ) if ( coin->electrum == 0 )
{ {
@ -650,8 +650,8 @@ again:
fastest = jint(retjson,"fastestFee"); fastest = jint(retjson,"fastestFee");
half = jint(retjson,"halfHourFee"); half = jint(retjson,"halfHourFee");
hour = jint(retjson,"hourFee"); hour = jint(retjson,"hourFee");
if ( hour*2 > half ) if ( hour*3 > half )
best = hour*2; best = hour*3;
else best = half; else best = half;
if ( fastest < best ) if ( fastest < best )
best = fastest; best = fastest;
@ -687,7 +687,7 @@ again:
rate = atof(retstr) / 1024.; rate = atof(retstr) / 1024.;
if ( rate != 0. ) if ( rate != 0. )
{ {
rate *= 1.25; //rate *= 1.25;
if ( rate < 0.00000005 ) if ( rate < 0.00000005 )
rate = 0.00000005; rate = 0.00000005;
//if ( coin->electrum != 0 ) //if ( coin->electrum != 0 )

12
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)); jadd(reqjson,"proof",LP_instantdex_txids(0,coin->smartaddr));
} }
msg = jprint(reqjson,1); msg = jprint(reqjson,1);
//printf("QUERY.(%s)\n",msg);
//if ( bits256_nonz(qp->srchash) == 0 || strcmp(method,"request") != 0 )
{
memset(&zero,0,sizeof(zero)); memset(&zero,0,sizeof(zero));
if ( bits256_nonz(qp->srchash) != 0 ) 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,qp->srchash,clonestr(msg));
printf("QUERY.(%s)\n",msg);
LP_reserved_msg(1,qp->srccoin,qp->destcoin,zero,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); 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);
} }

1
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); //printf("wait for got.%d\n",datalen);
retval = (*verify)(swap,data,datalen); retval = (*verify)(swap,data,datalen);
swap->received = (uint32_t)time(NULL);
nn_freemsg(data); nn_freemsg(data);
//printf("retval.%d\n",retval); //printf("retval.%d\n",retval);
return(retval); return(retval);

Loading…
Cancel
Save