jl777 7 years ago
parent
commit
51dbfd1554
  1. 58
      iguana/exchanges/LP_ordermatch.c
  2. 2
      iguana/exchanges/LP_prices.c
  3. 4
      iguana/exchanges/LP_utxos.c

58
iguana/exchanges/LP_ordermatch.c

@ -437,6 +437,34 @@ int32_t LP_connectstartbob(void *ctx,int32_t pubsock,struct LP_utxoinfo *utxo,cJ
return(retval);
}
void LP_abutxo_set(struct LP_utxoinfo *autxo,struct LP_utxoinfo *butxo,struct LP_quoteinfo *qp)
{
memset(butxo,0,sizeof(*butxo));
butxo->pubkey = qp->srchash;
safecopy(butxo->coin,qp->srccoin,sizeof(butxo->coin));
safecopy(butxo->coinaddr,qp->coinaddr,sizeof(butxo->coinaddr));
butxo->payment.txid = qp->txid;
butxo->payment.vout = qp->vout;
//butxo->payment.value = qp->value;
butxo->iambob = 1;
butxo->deposit.txid = qp->txid2;
butxo->deposit.vout = qp->vout2;
//butxo->deposit.value = up2->U.value;
butxo->S.satoshis = qp->satoshis;
memset(autxo,0,sizeof(*autxo));
autxo->pubkey = qp->desthash;
safecopy(autxo->coin,qp->destcoin,sizeof(autxo->coin));
safecopy(autxo->coinaddr,qp->destaddr,sizeof(autxo->coinaddr));
autxo->payment.txid = qp->desttxid;
autxo->payment.vout = qp->destvout;
//autxo->payment.value = qp->value;
autxo->iambob = 0;
autxo->deposit.txid = qp->feetxid;
autxo->deposit.vout = qp->feevout;
//autxo->deposit.value = up2->U.value;
autxo->S.satoshis = qp->destsatoshis;
}
char *LP_connectedalice(cJSON *argjson) // alice
{
cJSON *retjson; double bid,ask,price,qprice; int32_t pairsock = -1; char *pairstr; int32_t DEXselector = 0; struct LP_utxoinfo A,B,*autxo,*butxo; struct LP_quoteinfo Q; struct basilisk_swap *swap; struct iguana_info *coin;
@ -445,10 +473,9 @@ char *LP_connectedalice(cJSON *argjson) // alice
if ( bits256_cmp(Q.desthash,LP_mypub25519) != 0 )
return(clonestr("{\"result\",\"update stats\"}"));
printf("CONNECTED.(%s)\n",jprint(argjson,0));
memset(&A,0,sizeof(A));
memset(&B,0,sizeof(B));
autxo = &A;
butxo = &B;
LP_abutxo_set(autxo,butxo,&Q);
if ( (qprice= LP_quote_validate(autxo,butxo,&Q,0)) <= SMALLVAL )
{
LP_availableset(autxo);
@ -525,32 +552,9 @@ int32_t LP_tradecommand(void *ctx,char *myipaddr,int32_t pubsock,cJSON *argjson,
return(-3);
}
price = ask;
memset(&B,0,sizeof(B));
butxo = &B;
butxo->pubkey = Q.srchash;
safecopy(butxo->coin,Q.srccoin,sizeof(butxo->coin));
safecopy(butxo->coinaddr,Q.coinaddr,sizeof(butxo->coinaddr));
butxo->payment.txid = Q.txid;
butxo->payment.vout = Q.vout;
//butxo->payment.value = Q.value;
butxo->iambob = 1;
butxo->deposit.txid = Q.txid2;
butxo->deposit.vout = Q.vout2;
//butxo->deposit.value = up2->U.value;
butxo->S.satoshis = Q.satoshis;
memset(&A,0,sizeof(A));
autxo = &A;
autxo->pubkey = Q.desthash;
safecopy(autxo->coin,Q.destcoin,sizeof(autxo->coin));
safecopy(autxo->coinaddr,Q.destaddr,sizeof(autxo->coinaddr));
autxo->payment.txid = Q.desttxid;
autxo->payment.vout = Q.destvout;
//autxo->payment.value = Q.value;
autxo->iambob = 0;
autxo->deposit.txid = Q.feetxid;
autxo->deposit.vout = Q.feevout;
//autxo->deposit.value = up2->U.value;
autxo->S.satoshis = Q.destsatoshis;
butxo = &B;
LP_abutxo_set(autxo,butxo,&Q);
if ( (qprice= LP_quote_validate(autxo,butxo,&Q,1)) <= SMALLVAL )
{
printf("quote validate error %.0f\n",qprice);

2
iguana/exchanges/LP_prices.c

@ -929,7 +929,7 @@ void LP_pricefeedupdate(bits256 pubkey,char *base,char *rel,double price)
{
if ( fabs(pubp->matrix[basepp->ind][relpp->ind] - price) > SMALLVAL )
{
if ( (rand() % 100) == 0 )
if ( (rand() % 5000) == 0 )
printf("PRICEFEED UPDATE.(%-6s/%6s) %12.8f %s %12.8f\n",base,rel,price,bits256_str(str,pubkey),1./price);
pubp->matrix[basepp->ind][relpp->ind] = price;
dxblend(&basepp->relvals[relpp->ind],price,0.9);

4
iguana/exchanges/LP_utxos.c

@ -394,7 +394,7 @@ struct LP_utxoinfo *LP_utxoadd(int32_t iambob,int32_t mypubsock,char *symbol,bit
tmpsatoshis = (((value2 - 2*txfee) / 9) << 3);
else return(0);
} else tmpsatoshis = (value - txfee);
char str[65],str2[65],dispflag = (iambob == 0);
char str[65],str2[65],dispflag = 0;//(iambob == 0);
if ( iambob == 0 && bits256_cmp(pubkey,LP_mypub25519) != 0 )
{
printf("trying to add Alice utxo when not mine? %s/v%d\n",bits256_str(str,txid),vout);
@ -681,7 +681,7 @@ int32_t LP_privkey_init(int32_t mypubsock,struct iguana_info *coin,bits256 mypri
txid = jbits256(item,"txid");
vout = juint(item,"vout");
value = LP_value_extract(item,0);
height = coin->height - jint(item,"confirmations");
height = LP_getheight(coin) - jint(item,"confirmations");
}
else
{

Loading…
Cancel
Save