diff --git a/iguana/SuperNET.c b/iguana/SuperNET.c index 7a9a6a2f1..e63317c5e 100755 --- a/iguana/SuperNET.c +++ b/iguana/SuperNET.c @@ -657,19 +657,37 @@ int32_t SuperNET_destination(struct supernet_info *myinfo,uint32_t *destipbitsp, char *SuperNET_JSON(struct supernet_info *myinfo,cJSON *json,char *remoteaddr,uint16_t port) { char hexbuf[8192]; bits256 category,subhash; - int32_t hexlen,destflag,maxdelay,flag=0,newflag=0; uint32_t destipbits,timestamp; //cJSON *retjson; - char *forwardstr=0,*retstr=0,*agent=0,*method=0,*message,*hexmsg=0,*jsonstr=0; uint64_t tag; + int32_t autologin = 0,hexlen,destflag,maxdelay,flag=0,newflag=0; uint32_t destipbits,timestamp; //cJSON *retjson; + char *str,*forwardstr=0,*retstr=0,*agent=0,*method=0,*message,*hexmsg=0,*jsonstr=0; uint64_t tag; //printf("SuperNET_JSON.(%s)\n",jprint(json,0)); if ( remoteaddr != 0 && strcmp(remoteaddr,"127.0.0.1") == 0 ) remoteaddr = 0; if ( (agent = jstr(json,"agent")) == 0 ) agent = "bitcoinrpc"; method = jstr(json,"method"); - if ( agent != 0 && strcmp(agent,"pangea") == 0 && jobj(json,"categoryhash") == 0 ) + if ( agent != 0 ) { - jaddbits256(json,"categoryhash",calc_categoryhashes(0,"pangea",0)); - if ( jobj(json,"subhash") == 0 ) - jaddbits256(json,"subhash",GENESIS_PUBKEY); + if ( strcmp(agent,"pangea") == 0 && jobj(json,"categoryhash") == 0 ) + { + jaddbits256(json,"categoryhash",calc_categoryhashes(0,"pangea",0)); + if ( jobj(json,"subhash") == 0 ) + jaddbits256(json,"subhash",GENESIS_PUBKEY); + } + else if ( strcmp(agent,"InstantDEX") == 0 ) + { + if ( jobj(json,"passphrase") != 0 ) + { + if ( (str= SuperNET_login(myinfo,0,json,remoteaddr,jstr(json,"handle"),0,0,jstr(json,"passphrase"))) != 0 ) + free(str); + autologin = 1; + } + else if ( jobj(json,"password") != 0 ) + { + if ( (str= SuperNET_login(myinfo,0,json,remoteaddr,jstr(json,"handle"),jstr(json,"password"),jstr(json,"permanentfile"),0)) != 0 ) + free(str); + autologin = 1; + } + } } if ( remoteaddr == 0 ) { @@ -715,19 +733,8 @@ char *SuperNET_JSON(struct supernet_info *myinfo,cJSON *json,char *remoteaddr,ui //printf("SuperNET_JSON hexmsgadd\n"); SuperNET_hexmsgadd(myinfo,category,subhash,hexmsg,tai_now(),remoteaddr); } - if ( (retstr= SuperNET_processJSON(myinfo,json,remoteaddr,port)) != 0 ) - { - //printf("retstr.(%s)\n",retstr); - /*if ( retstr[strlen(retstr)-1] != '\n' && (retjson= cJSON_Parse(retstr)) != 0 && is_cJSON_Array(retjson) == 0 ) - { - if ( jobj(retjson,"result") == 0 || jobj(retjson,"error") != 0 || jobj(retjson,"method") != 0 ) - { - free(retstr); - retstr = 0; - } - free_json(retjson); - }*/ - } else printf("null retstr from SuperNET_JSON\n"); + if ( (retstr= SuperNET_processJSON(myinfo,json,remoteaddr,port)) == 0 ) + printf("null retstr from SuperNET_JSON\n"); } if ( flag != 0 && hexmsg != 0 && hexmsg != hexbuf ) free(hexmsg); @@ -737,6 +744,8 @@ char *SuperNET_JSON(struct supernet_info *myinfo,cJSON *json,char *remoteaddr,ui free(forwardstr); if ( jsonstr != 0 ) free(jsonstr); + if ( autologin != 0 ) + SuperNET_logout(myinfo,0,json,remoteaddr); return(retstr); } diff --git a/iguana/iguana_rpc.c b/iguana/iguana_rpc.c index 1d5f7f24b..f398cdc79 100755 --- a/iguana/iguana_rpc.c +++ b/iguana/iguana_rpc.c @@ -842,10 +842,6 @@ char *SuperNET_rpcparse(struct supernet_info *myinfo,char *retbuf,int32_t bufsiz *jsonflagp = 1; i += strlen("/api"); } else *jsonflagp = 0; - if ( strncmp(&url[i],"/data",strlen("/data")) == 0 ) - { - return(clonestr("[{\"date\":\"2016-08-19T21:30:43.878Z\",\"value\":30},{\"date\":\"2016-08-19T21:30:43.878Z\",\"value\":44},{\"date\":\"2016-08-19T21:30:43.878Z\",\"value\":49},{\"date\":\"2016-08-19T21:30:43.878Z\",\"value\":28},{\"date\":\"2016-08-19T21:30:43.878Z\",\"value\":52}]")); - } if ( strncmp(&url[i],"/bitmap",strlen("/bitmap")) == 0 ) { i += strlen("/bitmap"); diff --git a/iguana/m_js b/iguana/m_js index f64f820c5..ae454e2c1 100755 --- a/iguana/m_js +++ b/iguana/m_js @@ -4,3 +4,4 @@ cd secp256k1; ./m_js; cd .. emcc -s USE_PTHREADS=1 -s ALLOW_MEMORY_GROWTH=1 -Wno-deprecated -c -O2 *.c databases/iguana_DB.c #emcc -s USE_PTHREADS=1 -Wno-deprecated -c main.c iguana777.c iguana_bundles.c emcc -s USE_PTHREADS=1 -s ALLOW_MEMORY_GROWTH=1 -o iguana.html -O2 *.o ../agents/libcrypto777.a -lm +cp iguana.html iguana.js pthread-main.js iguana.html.mem /var/www/html diff --git a/includes/iguana_apideclares.h b/includes/iguana_apideclares.h index 45575ad85..bf8af9a19 100755 --- a/includes/iguana_apideclares.h +++ b/includes/iguana_apideclares.h @@ -105,7 +105,6 @@ STRING_AND_INT(iguana,bundlehashes,activecoin,height); TWO_STRINGS_AND_TWO_DOUBLES(InstantDEX,minaccept,base,rel,minprice,basevolume); TWO_STRINGS_AND_TWO_DOUBLES(InstantDEX,maxaccept,base,rel,maxprice,basevolume); -THREE_STRINGS_AND_THREE_INTS(InstantDEX,orderbook,exchange,base,rel,depth,allfields,ignore); THREE_STRINGS_AND_THREE_DOUBLES(InstantDEX,buy,exchange,base,rel,price,volume,dotrade); THREE_STRINGS_AND_THREE_DOUBLES(InstantDEX,sell,exchange,base,rel,price,volume,dotrade); THREE_STRINGS_AND_DOUBLE(InstantDEX,withdraw,exchange,base,destaddr,amount); @@ -117,6 +116,7 @@ TWO_STRINGS(InstantDEX,cancelorder,exchange,orderid); STRING_ARG(InstantDEX,openorders,exchange); STRING_ARG(InstantDEX,tradehistory,exchange); +THREE_STRINGS_AND_THREE_INTS(InstantDEX,orderbook,exchange,base,rel,depth,allfields,ignore); STRING_AND_INT(InstantDEX,pollgap,exchange,pollgap); TWO_STRINGS(InstantDEX,events,base,rel); ZERO_ARGS(InstantDEX,allexchanges);