Browse Source

Test

etomic
jl777 7 years ago
parent
commit
79a69bb4a1
  1. 11
      iguana/exchanges/LP_instantdex.c
  2. 18
      iguana/exchanges/LP_ordermatch.c

11
iguana/exchanges/LP_instantdex.c

@ -41,7 +41,7 @@ void LP_instantdex_txidadd(bits256 txid)
cJSON *array; int32_t i,n; char fname[1024],*filestr; FILE *fp;
if ( (array= LP_instantdex_txidaddjson()) == 0 )
array = cJSON_CreateArray();
if ( (n= cJSON_GetArraySize(array)) > 0 )
if ( (n= cJSON_GetArraySize(array)) >= 0 )
{
for (i=0; i<n; i++)
if ( bits256_cmp(jbits256i(array,i),txid) == 0 )
@ -240,7 +240,7 @@ char *LP_instantdex_claim(struct iguana_info *coin,char *depositaddr,uint32_t ex
return(clonestr("{\"error\":\"no instantdex deposits to claim\"}"));
}
int64_t LP_instantdex_credit(int32_t dispflag,char *coinaddr,int64_t satoshis,int32_t weeki,char *p2shaddr)
int64_t LP_instantdex_credit(int32_t dispflag,char *coinaddr,int64_t satoshis,int32_t weeki,char *p2shaddr,bits256 txid)
{
uint32_t timestamp; struct LP_address *ap; struct iguana_info *coin = LP_coinfind("KMD");
if ( coin != 0 )
@ -250,6 +250,8 @@ int64_t LP_instantdex_credit(int32_t dispflag,char *coinaddr,int64_t satoshis,in
{
ap->instantdex_credits += satoshis;
ap->didinstantdex = 1;
if ( strcmp(coinaddr,coin->smartaddr) == 0 )
LP_instantdex_txidadd(txid);
if ( dispflag != 0 )
printf("InstantDEX credit.(%s) %.8f weeki.%d (%s) -> sum %.8f\n",coinaddr,dstr(satoshis),weeki,p2shaddr,dstr(ap->instantdex_credits));
return(satoshis);
@ -282,10 +284,7 @@ int64_t LP_instantdex_creditcalc(struct iguana_info *coin,int32_t dispflag,bits2
if ( (txobj= LP_gettxout(coin->symbol,p2shaddr,txid,0)) != 0 )
{
free_json(txobj);
if ( LP_instantdex_credit(dispflag,destaddr,satoshis,weeki,p2shaddr) > 0 && strcmp(coin->symbol,"KMD") == 0 && strcmp(destaddr,coin->smartaddr) == 0 )
{
LP_instantdex_txidadd(txid);
}
LP_instantdex_credit(dispflag,destaddr,satoshis,weeki,p2shaddr,txid);
}
}
}

18
iguana/exchanges/LP_ordermatch.c

@ -456,7 +456,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]; cJSON *retjson; bits256 privkey; int32_t pair=-1,retval = -1,DEXselector = 0; struct basilisk_swap *swap; struct iguana_info *coin;
char pairstr[512]; cJSON *reqjson; bits256 privkey; int32_t pair=-1,retval = -1,DEXselector = 0; struct basilisk_swap *swap; struct iguana_info *coin;
qp->quotetime = (uint32_t)time(NULL);
if ( (coin= LP_coinfind(qp->srccoin)) == 0 )
{
@ -484,17 +484,18 @@ int32_t LP_connectstartbob(void *ctx,int32_t pubsock,char *base,char *rel,double
//swap->utxo = utxo;
if ( OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)LP_bobloop,(void *)swap) == 0 )
{
retjson = LP_quotejson(qp);
jaddstr(retjson,"method","connected");
jaddstr(retjson,"pair",pairstr);
reqjson = LP_quotejson(qp);
jaddstr(reqjson,"method","connected");
jaddstr(reqjson,"pair",pairstr);
jadd(reqjson,"proof",LP_instantdex_txidaddjson());
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,base,rel,zero,jprint(retjson,0));
LP_reserved_msg(1,base,rel,zero,jprint(reqjson,0));
//sleep(1);
//LP_reserved_msg(1,base,rel,qp->desthash,jprint(retjson,0));
//LP_reserved_msg(0,base,rel,zero,jprint(retjson,0));
free_json(retjson);
//LP_reserved_msg(1,base,rel,qp->desthash,jprint(reqjson,0));
//LP_reserved_msg(0,base,rel,zero,jprint(reqjson,0));
free_json(reqjson);
retval = 0;
} else printf("error launching swaploop\n");
} else printf("couldnt bind to any port %s\n",pairstr);
@ -887,7 +888,6 @@ struct LP_quoteinfo *LP_trades_gotrequest(void *ctx,struct LP_quoteinfo *qp,stru
if ( LP_allocated(qp->txid,qp->vout) == 0 && LP_allocated(qp->txid2,qp->vout2) == 0 )
{
reqjson = LP_quotejson(qp);
jadd(reqjson,"proof",LP_instantdex_txidaddjson());
LP_unavailableset(qp->txid,qp->vout,qp->timestamp + LP_RESERVETIME,qp->desthash);
LP_unavailableset(qp->txid2,qp->vout2,qp->timestamp + LP_RESERVETIME,qp->desthash);
if ( qp->quotetime == 0 )

Loading…
Cancel
Save