Browse Source

Merge pull request #12 from jl777/dev

dev update
pass-iguana-arg
ca333 7 years ago
committed by GitHub
parent
commit
7102179532
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      crypto777/inet.c
  2. 4
      iguana/exchanges/LP_NXT.c
  3. 2
      iguana/exchanges/LP_coins.c
  4. 5
      iguana/exchanges/LP_commands.c
  5. 3
      iguana/exchanges/LP_include.h
  6. 3
      iguana/exchanges/LP_instantdex.c
  7. 39
      iguana/exchanges/LP_nativeDEX.c
  8. 20
      iguana/exchanges/LP_ordermatch.c
  9. 5
      iguana/exchanges/LP_signatures.c
  10. 2
      iguana/exchanges/LP_stats.c
  11. 3
      iguana/exchanges/LP_transaction.c
  12. 2
      iguana/exchanges/beertest
  13. 2
      iguana/exchanges/coins
  14. 69
      iguana/exchanges/mm.c
  15. 4
      iguana/exchanges/prices/autoprice

5
crypto777/inet.c

@ -605,7 +605,10 @@ uint16_t parse_endpoint(int32_t *ip6flagp,char *transport,char *ipbuf,char *retb
ipbits = calc_ipbits(ipaddr);
expand_ipbits(tmp,ipbits);
if ( strcmp(tmp,ipaddr) != 0 )
ipaddr = 0, sprintf(retbuf,"{\"result\":\"illegal ipaddr\",\"endpoint\":\"%s\",\"ipaddr\":\"%s\",\"checkaddr\":\"%s\"}",endpoint,ipaddr,tmp);
{
sprintf(retbuf,"{\"result\":\"illegal ipaddr\",\"endpoint\":\"%s\",\"ipaddr\":\"%s\",\"checkaddr\":\"%s\"}",endpoint,ipaddr,tmp);
ipaddr = 0;
}
}
if ( inet != 0 && ipaddr != 0 && port != 0 )
{

4
iguana/exchanges/LP_NXT.c

@ -202,9 +202,7 @@ void NXTventure_liquidation()
cJSON *LP_NXT_redeems()
{
char url[1024],*retstr,*recv,*method,*msgstr,assetname[128]; uint64_t totals[2][sizeof(assetids)/sizeof(*assetids)],mult,txnum,assetid,qty; int32_t i,ind,numtx=0,past_marker=0; cJSON *item,*attach,*decjson,*array,*msgjson,*encjson,*retjson=0;
//sleep 1; fiat/supernet sendtoaddress RNZZuQYu8xJLZHuekhd96hYfoQuiCMz99T 1001.44150000 # txnum.8537615468620726612
//sleep 1; fiat/pangea sendtoaddress RWMdRaUmMZqKkEibwEhY6XS3RLCXJDWHTi 22.10910000 # txnum.2649622877615958504
uint64_t txnum_marker = calc_nxt64bits("8537615468620726612"); // 2649622877615958504"); // set to most recent processed
uint64_t txnum_marker = calc_nxt64bits("4114304329372848717"); // 8537615468620726612"); // set to most recent processed
uint64_t txnum_marker2 = calc_nxt64bits("7256847492742571143"); // dont change, end marker
char *passphrase = "";
char *account = "NXT-MRBN-8DFH-PFMK-A4DBM";

2
iguana/exchanges/LP_coins.c

@ -214,7 +214,7 @@ uint16_t LP_userpass(char *userpass,char *symbol,char *assetname,char *confroot,
cJSON *LP_coinjson(struct iguana_info *coin,int32_t showwif)
{
struct electrum_info *ep; bits256 zero; int32_t notarized; uint64_t balance; char wifstr[128],ipaddr[64]; uint8_t tmptype; bits256 checkkey; cJSON *item = cJSON_CreateObject();
struct electrum_info *ep; bits256 zero; int32_t notarized; uint64_t balance; char wifstr[128],ipaddr[72]; uint8_t tmptype; bits256 checkkey; cJSON *item = cJSON_CreateObject();
jaddstr(item,"coin",coin->symbol);
if ( showwif != 0 )
{

5
iguana/exchanges/LP_commands.c

@ -643,7 +643,10 @@ jpg(srcfile, destfile, power2=7, password, data="", required, ind=0)\n\
if ( strcmp(method,"swapstatus") == 0 )
return(LP_swapstatus_recv(argjson));
else if ( strcmp(method,"gettradestatus") == 0 )
return(LP_gettradestatus(j64bits(argjson,"aliceid"),juint(argjson,"requestid"),juint(argjson,"quoteid")));
{
retstr = clonestr("{\"error\":\"deprecated\"}");
//return(LP_gettradestatus(j64bits(argjson,"aliceid"),juint(argjson,"requestid"),juint(argjson,"quoteid")));
}
else if ( strcmp(method,"postprice") == 0 )
return(LP_postprice_recv(argjson));
else if ( strcmp(method,"uitem") == 0 )

3
iguana/exchanges/LP_include.h

@ -52,10 +52,11 @@ void emscripten_usleep(int32_t x); // returns immediate, no sense for sleeping
#endif
//#define LP_STRICTPEERS
#define LP_DISABLE_DISTCOMBINE
#define LP_MAXVINS 64
#define LP_HTTP_TIMEOUT 3 // 1 is too small due to edge cases of time(NULL)
#define LP_AUTOTRADE_TIMEOUT 30
#define LP_AUTOTRADE_TIMEOUT 60
#define LP_RESERVETIME 600 //(LP_AUTOTRADE_TIMEOUT * 2)
#define ELECTRUM_TIMEOUT 13
#define LP_ELECTRUM_KEEPALIVE 60

3
iguana/exchanges/LP_instantdex.c

@ -596,12 +596,15 @@ cJSON *LP_swapstats_item(struct LP_swapstats *sp,int32_t iambob)
LP_dPoW_request(alice);
}
if ( flag != 0 )
{
if ( 0 )
{
reqjson = cJSON_CreateObject();
jaddstr(reqjson,"method","gettradestatus");
jadd64bits(reqjson,"aliceid",sp->aliceid);
memset(zero.bytes,0,sizeof(zero));
LP_reserved_msg(0,"","",zero,jprint(reqjson,1));
}
if ( (swapstr= basilisk_swapentry(sp->Q.R.requestid,sp->Q.R.quoteid,0)) != 0 )
{
if ( (swapjson= cJSON_Parse(swapstr)) != 0 )

39
iguana/exchanges/LP_nativeDEX.c

@ -891,7 +891,8 @@ void LP_initpeers(int32_t pubsock,struct LP_peerinfo *mypeer,char *myipaddr,uint
{
printf("default seed nodes for netid.%d\n",netid);
OS_randombytes((void *)&r,sizeof(r));
for (j=0; j<sizeof(default_LPnodes)/sizeof(*default_LPnodes)&&j<5; j++)
r = 0;
for (j=0; j<sizeof(default_LPnodes)/sizeof(*default_LPnodes); j++)
{
i = (r + j) % (sizeof(default_LPnodes)/sizeof(*default_LPnodes));
LP_addpeer(mypeer,pubsock,default_LPnodes[i],myport,pushport,subport,0,G.LP_sessionid,netid);
@ -1093,11 +1094,24 @@ void LP_reserved_msgs(void *ignore)
{
nonz = 0;
LP_millistats_update(&LP_reserved_msgs_stats);
if ( num_Reserved_msgs[0] > 0 || num_Reserved_msgs[1] > 0 )
if ( num_Reserved_msgs[1] > 0 )
{
nonz++;
portable_mutex_lock(&LP_reservedmutex);
if ( num_Reserved_msgs[1] > 0 )
{
num_Reserved_msgs[1]--;
//printf("PRIORITY BROADCAST.(%s)\n",Reserved_msgs[1][num_Reserved_msgs[1]]);
LP_broadcast_message(LP_mypubsock,"","",zero,Reserved_msgs[1][num_Reserved_msgs[1]]);
Reserved_msgs[1][num_Reserved_msgs[1]] = 0;
}
portable_mutex_unlock(&LP_reservedmutex);
}
else if ( num_Reserved_msgs[0] > 0 )
{
nonz++;
flag = 0;
if ( LP_mypubsock >= 0 )
if ( flag == 0 && LP_mypubsock >= 0 )
{
memset(&pfd,0,sizeof(pfd));
pfd.fd = LP_mypubsock;
@ -1108,28 +1122,17 @@ void LP_reserved_msgs(void *ignore)
if ( flag == 1 )
{
portable_mutex_lock(&LP_reservedmutex);
if ( num_Reserved_msgs[1] > 0 )
{
num_Reserved_msgs[1]--;
//printf("PRIORITY BROADCAST.(%s)\n",Reserved_msgs[1][num_Reserved_msgs[1]]);
LP_broadcast_message(LP_mypubsock,"","",zero,Reserved_msgs[1][num_Reserved_msgs[1]]);
Reserved_msgs[1][num_Reserved_msgs[1]] = 0;
}
else if ( num_Reserved_msgs[0] > 0 )
{
num_Reserved_msgs[0]--;
//printf("BROADCAST.(%s)\n",Reserved_msgs[0][num_Reserved_msgs[0]]);
//printf("BROADCAST.(%s)\n",Reserved_msgs[0][num_Reserved_msgs[0]]);
LP_broadcast_message(LP_mypubsock,"","",zero,Reserved_msgs[0][num_Reserved_msgs[0]]);
Reserved_msgs[0][num_Reserved_msgs[0]] = 0;
}
portable_mutex_unlock(&LP_reservedmutex);
}
}
if ( ignore == 0 )
break;
if ( nonz != 0 )
usleep(1000);
else usleep(5000);
if ( nonz == 0 )
usleep(5000);
}
}
@ -1147,7 +1150,7 @@ int32_t LP_reserved_msg(int32_t priority,char *base,char *rel,bits256 pubkey,cha
if ( num_Reserved_msgs[priority] > max_Reserved_msgs[priority] )
{
max_Reserved_msgs[priority] = num_Reserved_msgs[priority];
if ( (max_Reserved_msgs[priority] % 100) == 0 )
//if ( (max_Reserved_msgs[priority] % 100) == 0 )
printf("New priority.%d max_Reserved_msgs.%d\n",priority,max_Reserved_msgs[priority]);
}
portable_mutex_unlock(&LP_reservedmutex);

20
iguana/exchanges/LP_ordermatch.c

@ -864,7 +864,7 @@ struct LP_quoteinfo *LP_trades_gotrequest(void *ctx,struct LP_quoteinfo *qp,stru
price = myprice + (r * range) / 100.;
bestprice = LP_bob_competition(&counter,qp->aliceid,price,0);
printf("%llu >>>>>>> qprice %.8f r.%d range %.8f -> %.8f, bestprice %.8f counter.%d\n",(long long)qp->aliceid,qprice,r,range,price,bestprice,counter);
if ( counter > 3 && price >= bestprice+SMALLVAL ) // skip if late or bad price
if ( counter > 3 && price > bestprice+SMALLVAL ) // skip if late or bad price
return(0);
} else return(0);
//LP_RTmetrics_update(qp->srccoin,qp->destcoin);
@ -1028,6 +1028,10 @@ void LP_tradesloop(void *ctx)
DL_DELETE(LP_tradesQ,qtp);
HASH_FIND(hh,LP_trades,&qtp->aliceid,sizeof(qtp->aliceid),tp);
if ( tp == 0 )
{
if ( 0 && now > Q.timestamp+LP_AUTOTRADE_TIMEOUT*20 ) // eat expired
free(qtp);
else
{
tp = qtp;
HASH_ADD(hh,LP_trades,aliceid,sizeof(tp->aliceid),tp);
@ -1043,7 +1047,8 @@ void LP_tradesloop(void *ctx)
}
nonz++;
tp->firstprocessed = tp->lastprocessed = (uint32_t)time(NULL);
//printf("iambob.%d funcid.%d vs %d\n",tp->iambob,funcid,LP_REQUEST);
//printf("iambob.%d funcid.%d vs %d\n",tp->iambob,funcid,LP_REQUEST);
}
continue;
}
portable_mutex_unlock(&LP_tradesmutex);
@ -1120,7 +1125,7 @@ void LP_tradesloop(void *ctx)
}
}
}
else if ( now > tp->firstprocessed+timeout*10 )
if ( now > tp->firstprocessed+timeout*10 )
{
//printf("purge swap aliceid.%llu\n",(long long)tp->aliceid);
portable_mutex_lock(&LP_tradesmutex);
@ -1168,6 +1173,11 @@ int32_t LP_tradecommand(void *ctx,char *myipaddr,int32_t pubsock,cJSON *argjson,
LP_requestinit(&Q.R,Q.srchash,Q.desthash,Q.srccoin,Q.satoshis-Q.txfee,Q.destcoin,Q.destsatoshis-Q.desttxfee,Q.timestamp,Q.quotetime,DEXselector);
LP_tradecommand_log(argjson);
printf("%-4d (%-10u %10u) %12s id.%-20llu %5s/%-5s %12.8f -> %12.8f (%11.8f) | RT.%d %d n%d\n",(uint32_t)time(NULL) % 3600,Q.R.requestid,Q.R.quoteid,method,(long long)Q.aliceid,Q.srccoin,Q.destcoin,dstr(Q.satoshis),dstr(Q.destsatoshis),(double)Q.destsatoshis/Q.satoshis,LP_RTcount,LP_swapscount,G.netid);
if ( Q.timestamp > 0 && time(NULL) > Q.timestamp + LP_AUTOTRADE_TIMEOUT*20 ) // eat expired packets
{
//printf("aliceid.%llu is expired by %d\n",(long long)Q.aliceid,(uint32_t)time(NULL) - (Q.timestamp + LP_AUTOTRADE_TIMEOUT*20));
//return(1);
}
//LP_autoprices_update(method,Q.srccoin,dstr(Q.satoshis),Q.destcoin,dstr(Q.destsatoshis));
retval = 1;
aliceid = j64bits(argjson,"aliceid");
@ -1210,7 +1220,7 @@ int32_t LP_tradecommand(void *ctx,char *myipaddr,int32_t pubsock,cJSON *argjson,
//printf("CONNECTED.(%s)\n",jprint(argjson,0));
if ( (proof= jarray(&num,argjson,"proof")) != 0 && num > 0 )
Q.othercredits = LP_instantdex_proofcheck(Q.srccoin,Q.coinaddr,proof,num);
if ( Qtrades == 0 )
if ( 1 || Qtrades == 0 )
LP_trades_gotconnected(ctx,&Q,&Q2,jstr(argjson,"pair"));
else LP_tradecommandQ(&Q,jstr(argjson,"pair"),LP_CONNECTED);
}
@ -1248,7 +1258,7 @@ int32_t LP_tradecommand(void *ctx,char *myipaddr,int32_t pubsock,cJSON *argjson,
printf("CONNECT.(%s)\n",jprint(argjson,0));
if ( (proof= jarray(&num,argjson,"proof")) != 0 && num > 0 )
Q.othercredits = LP_instantdex_proofcheck(Q.destcoin,Q.destaddr,proof,num);
if ( Qtrades == 0 )
if ( 1 || Qtrades == 0 )
LP_trades_gotconnect(ctx,&Q,&Q2,jstr(argjson,"pair"));
else LP_tradecommandQ(&Q,jstr(argjson,"pair"),LP_CONNECT);
}

5
iguana/exchanges/LP_signatures.c

@ -676,13 +676,12 @@ void LP_query(void *ctx,char *myipaddr,int32_t mypubsock,char *method,struct LP_
{
memset(&zero,0,sizeof(zero));
LP_reserved_msg(1,qp->srccoin,qp->destcoin,zero,clonestr(msg));
//if ( strcmp(method,"request") == 0 )
if ( 0 )
if ( strcmp(method,"connect") == 0 )
{
sleep(1);
LP_reserved_msg(1,qp->srccoin,qp->destcoin,zero,clonestr(msg));
sleep(1);
LP_reserved_msg(1,qp->srccoin,qp->destcoin,zero,clonestr(msg));
LP_reserved_msg(0,qp->srccoin,qp->destcoin,zero,clonestr(msg));
}
free(msg);
/*portable_mutex_lock(&LP_reservedmutex);

2
iguana/exchanges/LP_stats.c

@ -471,7 +471,7 @@ int32_t LP_statslog_parsequote(char *method,cJSON *lineobj)
flag = 1;
break;
}
if ( counter++ < 10 )
if ( counter++ < 1 )
printf("error after delayed match\n");
}
}

3
iguana/exchanges/LP_transaction.c

@ -1211,6 +1211,9 @@ char *LP_createrawtransaction(cJSON **txobjp,int32_t *numvinsp,struct iguana_inf
else if ( coin->numutxos >= LP_MAXDESIRED_UTXOS )
dustcombine = 2;
else dustcombine = 1;
#ifdef LP_DISABLE_DISTCOMBINE
dustcombine = 0;
#endif
amount = txfee;
for (i=0; i<numvouts; i++)
{

2
iguana/exchanges/beertest

@ -0,0 +1,2 @@
source userpass
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"BEER\",\"rel\":\"KMD\",\"fixed\":1.28700,\"margin\":0.00001}"

2
iguana/exchanges/coins

File diff suppressed because one or more lines are too long

69
iguana/exchanges/mm.c

@ -190,6 +190,75 @@ int main(int argc, const char * argv[])
printf("done vanitygen.(%s) done %u elapsed %d\n",argv[2],(uint32_t)time(NULL),(uint32_t)time(NULL) - timestamp);
exit(0);
}
else if ( argv[1] != 0 && strcmp(argv[1],"airdropH") == 0 && argv[2] != 0 )
{
FILE *fp; double val,total = 0.; uint8_t checktype,addrtype,rmd160[21],checkrmd160[21]; char buf[256],checkaddr[64],coinaddr[64],manystrs[64][128],cmd[64*128]; int32_t n,i,num; char *flag;
if ( (fp= fopen(argv[2],"rb")) != 0 )
{
num = 0;
while ( fgets(buf,sizeof(buf),fp) > 0 )
{
if ( (n= (int32_t)strlen(buf)) > 0 )
buf[--n] = 0;
flag = 0;
for (i=0; i<n; i++)
{
if ( buf[i] == ',' )
{
buf[i] = 0;
flag = &buf[i+1];
break;
}
}
if ( flag != 0 )
{
bitcoin_addr2rmd160("HUSH",28,&addrtype,rmd160,buf);
bitcoin_address("KMD",coinaddr,0,addrtype == 184 ? 60 : 85,rmd160,20);
bitcoin_addr2rmd160("KMD",0,&checktype,checkrmd160,coinaddr);
bitcoin_address("HUSH",checkaddr,28,checktype == 60 ? 184 : 189,checkrmd160,20);
if ( memcmp(rmd160,checkrmd160,20) != 0 || strcmp(buf,checkaddr) != 0 )
{
for (i=0; i<20; i++)
printf("%02x",rmd160[i]);
printf(" vs. ");
for (i=0; i<20; i++)
printf("%02x",checkrmd160[i]);
printf(" address calc error (%s).%d -> (%s).%d -> (%s) %.8f?\n",buf,addrtype,coinaddr,checktype,checkaddr,atof(flag));
}
else
{
val = atof(flag);
sprintf(manystrs[num++],"\\\"%s\\\":%0.8f",coinaddr,val);
if ( num >= sizeof(manystrs)/sizeof(*manystrs) )
{
sprintf(cmd,"fiat/btch sendmany \\\"\\\" \"{");
for (i=0; i<num; i++)
sprintf(cmd + strlen(cmd),"%s%s",manystrs[i],i<num-1?",":"");
strcat(cmd,"}\" 0");
printf("%s\n",cmd);
num = 0;
memset(manystrs,0,sizeof(manystrs));
}
total += val;
//printf("(%s).%d (%s) <- %.8f total %.8f\n",buf,addrtype,coinaddr,val,total);
}
} else printf("parse error for (%s)\n",buf);
}
if ( num > 0 )
{
sprintf(cmd,"fiat/btch sendmany \\\"\\\" \"{");
for (i=0; i<num; i++)
sprintf(cmd + strlen(cmd),"%s%s",manystrs[i],i<num-1?",":"");
strcat(cmd,"}\" 0");
printf("%s\n",cmd);
num = 0;
memset(manystrs,0,sizeof(manystrs));
}
printf("close (%s) total %.8f\n",argv[2],total);
fclose(fp);
} else printf("couldnt open (%s)\n",argv[2]);
exit(0);
}
sprintf(dirname,"%s",GLOBAL_DBDIR), OS_ensure_directory(dirname);
sprintf(dirname,"%s/SWAPS",GLOBAL_DBDIR), OS_ensure_directory(dirname);
sprintf(dirname,"%s/PRICES",GLOBAL_DBDIR), OS_ensure_directory(dirname);

4
iguana/exchanges/prices/autoprice

@ -9,8 +9,8 @@ curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\
#curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"KMD\",\"rel\":\"MNZ\",\"offset\":0.0,\"refbase\":\"KMD\",\"refrel\":\"BTC\",\"factor\":15000,\"margin\":-0.2}"
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"HUSH\",\"rel\":\"KMD\",\"margin\":$margin,\"refbase\":\"hush\",\"refrel\":\"coinmarketcap\"}"
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"KMD\",\"rel\":\"BTCH\",\"offset\":0.0,\"refbase\":\"KMD\",\"refrel\":\"HUSH\",\"factor\":1.44,\"buymargin\":0.05,\"sellmargin\":0.05}"
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"BTCH\",\"rel\":\"KMD\",\"offset\":0.0,\"refbase\":\"HUSH\",\"refrel\":\"KMD\",\"factor\":0.7,\"buymargin\":0.05,\"sellmargin\":0.05}"
#curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"KMD\",\"rel\":\"BTCH\",\"offset\":0.0,\"refbase\":\"KMD\",\"refrel\":\"HUSH\",\"factor\":1.44,\"buymargin\":0.05,\"sellmargin\":0.05}"
#curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"BTCH\",\"rel\":\"KMD\",\"offset\":0.0,\"refbase\":\"HUSH\",\"refrel\":\"KMD\",\"factor\":0.7,\"buymargin\":0.05,\"sellmargin\":0.05}"
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"BEER\",\"rel\":\"PIZZA\",\"fixed\":0.0001,\"margin\":0.00001}"

Loading…
Cancel
Save