Browse Source

Test

etomic
jl777 8 years ago
parent
commit
907351af5c
  1. 3
      iguana/exchanges/LP_nativeDEX.c
  2. 2
      iguana/exchanges/LP_remember.c
  3. 21
      iguana/exchanges/LP_swap.c
  4. 4
      iguana/exchanges/LP_transaction.c

3
iguana/exchanges/LP_nativeDEX.c

@ -32,7 +32,7 @@ char USERPASS[65],USERPASS_WIFSTR[64],USERHOME[512] = { "/root" };
char *default_LPnodes[] = { "5.9.253.196", "5.9.253.197", "5.9.253.198", "5.9.253.199", "5.9.253.200", "5.9.253.201", "5.9.253.202", "5.9.253.203", "5.9.253.204" }; //"5.9.253.195", char *default_LPnodes[] = { "5.9.253.196", "5.9.253.197", "5.9.253.198", "5.9.253.199", "5.9.253.200", "5.9.253.201", "5.9.253.202", "5.9.253.203", "5.9.253.204" }; //"5.9.253.195",
portable_mutex_t LP_peermutex,LP_utxomutex,LP_commandmutex,LP_cachemutex; portable_mutex_t LP_peermutex,LP_utxomutex,LP_commandmutex,LP_cachemutex,LP_swaplistmutex;
int32_t LP_mypubsock = -1; int32_t LP_mypubsock = -1;
int32_t Client_connections; int32_t Client_connections;
int32_t USERPASS_COUNTER,IAMCLIENT = 0; int32_t USERPASS_COUNTER,IAMCLIENT = 0;
@ -267,6 +267,7 @@ void LPinit(uint16_t myport,uint16_t mypullport,uint16_t mypubport,double profit
portable_mutex_init(&LP_peermutex); portable_mutex_init(&LP_peermutex);
portable_mutex_init(&LP_utxomutex); portable_mutex_init(&LP_utxomutex);
portable_mutex_init(&LP_commandmutex); portable_mutex_init(&LP_commandmutex);
portable_mutex_init(&LP_swaplistmutex);
portable_mutex_init(&LP_cachemutex); portable_mutex_init(&LP_cachemutex);
if ( amclient == 0 ) if ( amclient == 0 )
{ {

2
iguana/exchanges/LP_remember.c

@ -889,6 +889,7 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti
char *basilisk_swaplist() char *basilisk_swaplist()
{ {
char fname[512]; FILE *fp; cJSON *item,*retjson,*array,*totalsobj; uint32_t quoteid,requestid; int64_t KMDtotals[16],BTCtotals[16],Btotal,Ktotal; int32_t i; char fname[512]; FILE *fp; cJSON *item,*retjson,*array,*totalsobj; uint32_t quoteid,requestid; int64_t KMDtotals[16],BTCtotals[16],Btotal,Ktotal; int32_t i;
portable_mutex_lock(&LP_swaplistmutex);
memset(KMDtotals,0,sizeof(KMDtotals)); memset(KMDtotals,0,sizeof(KMDtotals));
memset(BTCtotals,0,sizeof(BTCtotals)); memset(BTCtotals,0,sizeof(BTCtotals));
//,statebits; int32_t optionduration; struct basilisk_request R; bits256 privkey; //,statebits; int32_t optionduration; struct basilisk_request R; bits256 privkey;
@ -949,6 +950,7 @@ char *basilisk_swaplist()
jaddi(array,linfo_json(&myinfo->linfos[i])); jaddi(array,linfo_json(&myinfo->linfos[i]));
} }
jadd(retjson,"quotes",array);*/ jadd(retjson,"quotes",array);*/
portable_mutex_unlock(&LP_swaplistmutex);
return(jprint(retjson,1)); return(jprint(retjson,1));
} }

21
iguana/exchanges/LP_swap.c

@ -677,15 +677,17 @@ void LP_bobloop(void *_utxo)
printf("error sending bobdeposit\n"); printf("error sending bobdeposit\n");
else if ( LP_waitfor(utxo->pair,swap,10,LP_verify_alicepayment) < 0 ) else if ( LP_waitfor(utxo->pair,swap,10,LP_verify_alicepayment) < 0 )
printf("error waiting for alicepayment\n"); printf("error waiting for alicepayment\n");
else if ( basilisk_bobscripts_set(swap,0,1) < 0 )
printf("error bobscripts payment\n");
else if ( LP_swapdata_rawtxsend(utxo->pair,swap,0x8000,data,maxlen,&swap->bobpayment,0x4000,0) == 0 )
printf("error sending bobpayment\n");
else else
{ {
swap->bobreclaim.utxovout = 0; swap->bobreclaim.utxovout = 0;
swap->bobreclaim.utxotxid = swap->bobpayment.I.signedtxid; swap->bobreclaim.utxotxid = swap->bobpayment.I.signedtxid;
basilisk_bobpayment_reclaim(swap,swap->I.callduration); basilisk_bobpayment_reclaim(swap,swap->I.callduration);
while ( LP_numconfirms(swap,&swap->alicepayment) < 1 )
sleep(3);
if ( basilisk_bobscripts_set(swap,0,1) < 0 )
printf("error bobscripts payment\n");
else if ( LP_swapdata_rawtxsend(utxo->pair,swap,0x8000,data,maxlen,&swap->bobpayment,0x4000,0) == 0 )
printf("error sending bobpayment\n");
LP_swapwait(swap->I.req.requestid,swap->I.req.quoteid,4*3600,600); LP_swapwait(swap->I.req.requestid,swap->I.req.quoteid,4*3600,600);
} }
} }
@ -724,13 +726,22 @@ void LP_aliceloop(void *_qp)
printf("error waiting for bobdeposit\n"); printf("error waiting for bobdeposit\n");
else if ( LP_swapdata_rawtxsend(qp->pair,swap,0x1000,data,maxlen,&swap->alicepayment,0x800,0) == 0 ) else if ( LP_swapdata_rawtxsend(qp->pair,swap,0x1000,data,maxlen,&swap->alicepayment,0x800,0) == 0 )
printf("error sending alicepayment\n"); printf("error sending alicepayment\n");
else if ( LP_waitfor(qp->pair,swap,10,LP_verify_bobpayment) < 0 ) else
{
while ( LP_numconfirms(swap,&swap->alicepayment) < 1 )
sleep(3);
if ( LP_waitfor(qp->pair,swap,10,LP_verify_bobpayment) < 0 )
printf("error waiting for bobpayment\n"); printf("error waiting for bobpayment\n");
else else
{ {
while ( LP_numconfirms(swap,&swap->bobpayment) < 1 )
sleep(3);
if ( LP_swapdata_rawtxsend(qp->pair,swap,0x20000,data,maxlen,&swap->alicespend,0x0,0) == 0 )
printf("error sending alicepayment\n");
LP_swapwait(swap->I.req.requestid,swap->I.req.quoteid,4*3600,600); LP_swapwait(swap->I.req.requestid,swap->I.req.quoteid,4*3600,600);
} }
} }
}
basilisk_swap_finished(swap); basilisk_swap_finished(swap);
free(swap); free(swap);
} }

4
iguana/exchanges/LP_transaction.c

@ -79,7 +79,7 @@ uint64_t oldLP_txvalue(char *symbol,bits256 txid,int32_t vout)
{ {
if ( (interest= jdouble(utxoobj,"interest")) != 0. ) if ( (interest= jdouble(utxoobj,"interest")) != 0. )
{ {
printf("add interest of %.8f to %.8f\n",interest,dstr(value)); //printf("add interest of %.8f to %.8f\n",interest,dstr(value));
value += SATOSHIDEN * interest; value += SATOSHIDEN * interest;
} }
free_json(utxoobj); free_json(utxoobj);
@ -104,7 +104,7 @@ uint64_t LP_txvalue(char *symbol,bits256 txid,int32_t vout)
{ {
if ( (interest= jdouble(txobj,"interest")) != 0. ) if ( (interest= jdouble(txobj,"interest")) != 0. )
{ {
printf("add interest of %.8f to %.8f\n",interest,dstr(value)); //printf("add interest of %.8f to %.8f\n",interest,dstr(value));
value += SATOSHIDEN * interest; value += SATOSHIDEN * interest;
} }
} }

Loading…
Cancel
Save