|
|
@ -514,13 +514,7 @@ int32_t LP_connectstartbob(void *ctx,int32_t pubsock,char *base,char *rel,double |
|
|
|
|
|
|
|
char *LP_trade(void *ctx,char *myipaddr,int32_t mypubsock,struct LP_quoteinfo *qp,double maxprice,int32_t timeout,int32_t duration,uint32_t tradeid,bits256 destpubkey) |
|
|
|
{ |
|
|
|
//struct LP_utxoinfo *aliceutxo;
|
|
|
|
double price; |
|
|
|
/*if ( (aliceutxo= LP_utxopairfind(0,qp->desttxid,qp->destvout,qp->feetxid,qp->feevout)) == 0 )
|
|
|
|
{ |
|
|
|
char str[65],str2[65]; printf("dest.(%s)/v%d fee.(%s)/v%d\n",bits256_str(str,qp->desttxid),qp->destvout,bits256_str(str2,qp->feetxid),qp->feevout); |
|
|
|
return(clonestr("{\"error\":\"cant find alice utxopair\"}")); |
|
|
|
}*/ |
|
|
|
double price; int32_t changed; |
|
|
|
price = 0.; |
|
|
|
memset(qp->txid.bytes,0,sizeof(qp->txid)); |
|
|
|
qp->txid2 = qp->txid; |
|
|
@ -529,6 +523,7 @@ char *LP_trade(void *ctx,char *myipaddr,int32_t mypubsock,struct LP_quoteinfo *q |
|
|
|
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; |
|
|
|
LP_mypriceset(&changed,qp->destcoin,qp->srccoin,1. / maxprice); |
|
|
|
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)); |
|
|
|
} |
|
|
@ -837,7 +832,7 @@ double LP_trades_bobprice(double *bidp,double *askp,struct LP_quoteinfo *qp) |
|
|
|
return(0.); |
|
|
|
} |
|
|
|
price = *askp; |
|
|
|
printf("MYPRICE %s/%s %.8f vs qprice %.8f\n",qp->srccoin,qp->destcoin,price,(double)qp->destsatoshis/qp->satoshis); |
|
|
|
//printf("MYPRICE %s/%s %.8f vs qprice %.8f\n",qp->srccoin,qp->destcoin,price,(double)qp->destsatoshis/qp->satoshis);
|
|
|
|
if ( LP_validSPV(qp->destcoin,qp->destaddr,qp->desttxid,qp->destvout) < 0 ) |
|
|
|
{ |
|
|
|
printf("%s dest %s failed SPV check\n",qp->destcoin,bits256_str(str,qp->desttxid)); |
|
|
@ -1056,7 +1051,7 @@ void LP_tradesloop(void *ctx) |
|
|
|
now = (uint32_t)time(NULL); |
|
|
|
Q = qtp->Q; |
|
|
|
funcid = qtp->funcid; |
|
|
|
//printf("dequeue %p funcid.%d aliceid.%llu iambob.%d\n",qtp,funcid,(long long)qtp->aliceid,qtp->iambob);
|
|
|
|
printf("dequeue %p funcid.%d aliceid.%llu iambob.%d\n",qtp,funcid,(long long)qtp->aliceid,qtp->iambob); |
|
|
|
portable_mutex_lock(&LP_tradesmutex); |
|
|
|
DL_DELETE(LP_tradesQ,qtp); |
|
|
|
HASH_FIND(hh,LP_trades,&qtp->aliceid,sizeof(qtp->aliceid),tp); |
|
|
|