|
|
@ -307,7 +307,7 @@ int32_t LP_nearest_utxovalue(struct iguana_info *coin,char *coinaddr,struct LP_a |
|
|
|
} |
|
|
|
if ( replacei >= 0 ) |
|
|
|
{ |
|
|
|
printf("REPLACE bestdist %.8f height %d with dist %.8f height %d\n",dstr(bestdist),bestup->U.height,dstr(utxos[replacei]->U.value - targetval),utxos[replacei]->U.height); |
|
|
|
//printf("REPLACE bestdist %.8f height %d with dist %.8f height %d\n",dstr(bestdist),bestup->U.height,dstr(utxos[replacei]->U.value - targetval),utxos[replacei]->U.height);
|
|
|
|
return(replacei); |
|
|
|
} |
|
|
|
} |
|
|
@ -842,7 +842,7 @@ struct LP_quoteinfo *LP_trades_gotrequest(void *ctx,struct LP_quoteinfo *qp,stru |
|
|
|
double price=0.,p=0.,qprice,myprice,bestprice,range,bid,ask; struct iguana_info *coin; struct LP_utxoinfo A,B,*autxo,*butxo; cJSON *reqjson; char str[65]; struct LP_address_utxo *utxos[1000]; int32_t i,r,counter,max = (int32_t)(sizeof(utxos)/sizeof(*utxos)); |
|
|
|
*newqp = *qp; |
|
|
|
qp = newqp; |
|
|
|
printf("bob %s received REQUEST.(%llu)\n",bits256_str(str,G.LP_mypub25519),(long long)qp->aliceid); |
|
|
|
//printf("bob %s received REQUEST.(%llu)\n",bits256_str(str,G.LP_mypub25519),(long long)qp->aliceid);
|
|
|
|
if ( (coin= LP_coinfind(qp->srccoin)) == 0 ) |
|
|
|
return(0); |
|
|
|
if ( (myprice= LP_trades_bobprice(&bid,&ask,qp)) == 0. ) |
|
|
@ -920,6 +920,7 @@ struct LP_quoteinfo *LP_trades_gotrequest(void *ctx,struct LP_quoteinfo *qp,stru |
|
|
|
printf("i.%d qprice %.8f myprice %.8f price %.8f [%.8f]\n",i,qprice,myprice,price,p); |
|
|
|
if ( LP_allocated(qp->txid,qp->vout) == 0 && LP_allocated(qp->txid2,qp->vout2) == 0 ) |
|
|
|
{ |
|
|
|
printf("found unallocated txids\n"); |
|
|
|
reqjson = LP_quotejson(qp); |
|
|
|
LP_unavailableset(qp->txid,qp->vout,qp->timestamp + LP_RESERVETIME,qp->desthash); |
|
|
|
LP_unavailableset(qp->txid2,qp->vout2,qp->timestamp + LP_RESERVETIME,qp->desthash); |
|
|
@ -928,12 +929,12 @@ struct LP_quoteinfo *LP_trades_gotrequest(void *ctx,struct LP_quoteinfo *qp,stru |
|
|
|
jaddnum(reqjson,"quotetime",qp->quotetime); |
|
|
|
jaddnum(reqjson,"pending",qp->timestamp + LP_RESERVETIME); |
|
|
|
jaddstr(reqjson,"method","reserved"); |
|
|
|
//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)); |
|
|
|
bits256 zero; |
|
|
|
memset(zero.bytes,0,sizeof(zero)); |
|
|
|
LP_reserved_msg(1,qp->srccoin,qp->destcoin,zero,jprint(reqjson,0)); |
|
|
|
free_json(reqjson); |
|
|
|
//printf("Send RESERVED id.%llu\n",(long long)qp->aliceid);
|
|
|
|
printf("Send RESERVED id.%llu\n",(long long)qp->aliceid); |
|
|
|
return(qp); |
|
|
|
} else printf("request processing selected ineligible utxos?\n"); |
|
|
|
return(0); |
|
|
|