Browse Source

Nonce

etomic
jl777 7 years ago
parent
commit
46326bf42b
  1. 7
      iguana/exchanges/LP_commands.c
  2. 1
      iguana/exchanges/LP_nativeDEX.c
  3. 12
      iguana/exchanges/LP_ordermatch.c
  4. 2
      iguana/exchanges/LP_portfolio.c

7
iguana/exchanges/LP_commands.c

@ -104,7 +104,8 @@ enable(coin)\n\
disable(coin)\n\ disable(coin)\n\
inventory(coin)\n\ inventory(coin)\n\
bestfit(rel, relvolume)\n\ bestfit(rel, relvolume)\n\
buy(base, rel, price, relvolume, timeout=10, duration=3600)\n\ buy(base, rel, price, relvolume, timeout=10, duration=3600, nonce)\n\
sell(base, rel, price, basevolume, timeout=10, duration=3600, nonce)\n\
swapstatus()\n\ swapstatus()\n\
swapstatus(requestid, quoteid)\n\ swapstatus(requestid, quoteid)\n\
public API:\n \ public API:\n \
@ -233,14 +234,14 @@ dividends(coin, height, <args>)\n\
{ {
if ( price > SMALLVAL ) if ( price > SMALLVAL )
{ {
return(LP_autobuy(ctx,myipaddr,pubsock,base,rel,price,jdouble(argjson,"relvolume"),jint(argjson,"timeout"),jint(argjson,"duration"),jstr(argjson,"gui"))); return(LP_autobuy(ctx,myipaddr,pubsock,base,rel,price,jdouble(argjson,"relvolume"),jint(argjson,"timeout"),jint(argjson,"duration"),jstr(argjson,"gui"),juint(argjson,"nonce")));
} else return(clonestr("{\"error\":\"no price set\"}")); } else return(clonestr("{\"error\":\"no price set\"}"));
} }
else if ( strcmp(method,"sell") == 0 ) else if ( strcmp(method,"sell") == 0 )
{ {
if ( price > SMALLVAL ) if ( price > SMALLVAL )
{ {
return(LP_autobuy(ctx,myipaddr,pubsock,rel,base,1./price,jdouble(argjson,"basevolume"),jint(argjson,"timeout"),jint(argjson,"duration"),jstr(argjson,"gui"))); return(LP_autobuy(ctx,myipaddr,pubsock,rel,base,1./price,jdouble(argjson,"basevolume"),jint(argjson,"timeout"),jint(argjson,"duration"),jstr(argjson,"gui"),juint(argjson,"nonce")));
} else return(clonestr("{\"error\":\"no price set\"}")); } else return(clonestr("{\"error\":\"no price set\"}"));
} }
} }

1
iguana/exchanges/LP_nativeDEX.c

@ -47,6 +47,7 @@ char *default_LPnodes[] = { "5.9.253.195", "5.9.253.196", "5.9.253.197", "5.9.25
//uint32_t LP_deadman_switch; //uint32_t LP_deadman_switch;
uint16_t LP_fixed_pairport,LP_publicport; uint16_t LP_fixed_pairport,LP_publicport;
uint32_t LP_lastnonce;
int32_t LP_mybussock = -1; int32_t LP_mybussock = -1;
int32_t LP_mypubsock = -1; int32_t LP_mypubsock = -1;
int32_t LP_mypullsock = -1; int32_t LP_mypullsock = -1;

12
iguana/exchanges/LP_ordermatch.c

@ -1024,10 +1024,16 @@ struct LP_utxoinfo *LP_buyutxo(double *ordermatchpricep,int64_t *bestsatoshisp,i
return(bestutxo); return(bestutxo);
} }
char *LP_autobuy(void *ctx,char *myipaddr,int32_t mypubsock,char *base,char *rel,double maxprice,double relvolume,int32_t timeout,int32_t duration,char *gui) char *LP_autobuy(void *ctx,char *myipaddr,int32_t mypubsock,char *base,char *rel,double maxprice,double relvolume,int32_t timeout,int32_t duration,char *gui,uint32_t nonce)
{ {
uint64_t desttxfee,txfee; int32_t i,maxiters,numpubs = 0; int64_t bestsatoshis=0,destsatoshis,bestdestsatoshis=0; struct LP_utxoinfo *autxo,*bestutxo = 0; double qprice,ordermatchprice=0.; struct LP_quoteinfo Q; bits256 pubkeys[100]; uint64_t desttxfee,txfee; uint32_t lastnonce; int32_t i,maxiters,numpubs = 0; int64_t bestsatoshis=0,destsatoshis,bestdestsatoshis=0; struct LP_utxoinfo *autxo,*bestutxo = 0; double qprice,ordermatchprice=0.; struct LP_quoteinfo Q; bits256 pubkeys[100];
printf("LP_autobuy %s/%s price %.8f vol %.8f\n",base,rel,maxprice,relvolume); printf("LP_autobuy %s/%s price %.8f vol %.8f nonce %u\n",base,rel,maxprice,relvolume,nonce);
if ( (lastnonce= LP_lastnonce) != 0 && nonce <= lastnonce )
{
printf("nonce.%u not bigger than lastnonce.%u\n",nonce,lastnonce);
return(clonestr("{\"error\":\"invalid nonce\"}"));
}
LP_lastnonce = nonce;
if ( duration <= 0 ) if ( duration <= 0 )
duration = LP_ORDERBOOK_DURATION; duration = LP_ORDERBOOK_DURATION;
if ( timeout <= 0 ) if ( timeout <= 0 )

2
iguana/exchanges/LP_portfolio.c

@ -441,7 +441,7 @@ int32_t LP_portfolio_trade(void *ctx,uint32_t *requestidp,uint32_t *quoteidp,str
break; break;
if ( LP_utxo_bestfit(sell->symbol,SATOSHIDEN * relvolume) != 0 ) if ( LP_utxo_bestfit(sell->symbol,SATOSHIDEN * relvolume) != 0 )
{ {
if ( (retstr2= LP_autobuy(ctx,"127.0.0.1",-1,buy->symbol,sell->symbol,maxprice,relvolume,60,24*3600,gui)) != 0 ) if ( (retstr2= LP_autobuy(ctx,"127.0.0.1",-1,buy->symbol,sell->symbol,maxprice,relvolume,60,24*3600,gui,LP_lastnonce+1)) != 0 )
{ {
if ( (retjson2= cJSON_Parse(retstr2)) != 0 ) if ( (retjson2= cJSON_Parse(retstr2)) != 0 )
{ {

Loading…
Cancel
Save