STRING_ARG(iguana,addcoin,newcoin) { char *symbol,*seedip; int32_t retval; if ( (symbol= newcoin) == 0 && coin != 0 ) symbol = coin->symbol; if ( symbol != 0 ) { if ( (seedip= jstr(json,"seedipaddr")) != 0 ) safecopy(myinfo->seedipaddr,seedip,sizeof(myinfo->seedipaddr)); printf(">> addcoin.%s seedipaddr.%s\n",symbol,myinfo->seedipaddr); #ifdef __PNACL__ // if ( strcmp(symbol,"BTC") == 0 ) // return(clonestr("{\"result\":\"BTC for chrome app is not yet\"}")); #endif if ( (retval= iguana_launchcoin(myinfo,symbol,json,0)) > 0 ) { if ( myinfo->rpcsymbol[0] == 0 ) safecopy(myinfo->rpcsymbol,symbol,sizeof(myinfo->rpcsymbol)); return(clonestr("{\"result\":\"coin added\"}")); } else if ( retval == 0 ) return(clonestr("{\"result\":\"coin already there\"}")); else return(clonestr("{\"error\":\"error adding coin\"}")); } else return(clonestr("{\"error\":\"addcoin needs newcoin\"}")); }
STRING_ARG(SuperNET,bitcoinrpc,setcoin) { char buf[1024]; if ( setcoin != 0 && setcoin[0] != 0 ) { strcpy(myinfo->rpcsymbol,setcoin); touppercase(myinfo->rpcsymbol); printf("bitcoinrpc.%s\n",myinfo->rpcsymbol); if ( iguana_launchcoin(myinfo,myinfo->rpcsymbol,json,0) < 0 ) return(clonestr("{\"error\":\"error creating coin\"}")); else { sprintf(buf,"{\"result\":\"success\",\"setcoin\":\"%s\"}",setcoin); return(clonestr(buf)); } } else return(clonestr("{\"error\":\"bitcoinrpc needs setcoin value\"}")); }
int maingen(int argc, char** argv) { uint8_t logs[256]; uint8_t exps[255]; unsigned int x; unsigned int i; x = 1; for( i = 0; i < 255; ++i ) { exps[i] = x; logs[x] = i; x <<= 1; if( x & 0x100 ) x ^= 0x11d; /* Unset the 8th bit and mix in 0x1d */ } logs[0] = 0; /* can't log(0) so just set it neatly to 0 */ /* The above generation algorithm clearly demonstrates that * logs[exps[i]] == i for 0 <= i <= 254 * exps[logs[i]] == i for 1 <= i <= 255 */ /* Spew out the tables */ fprintf(stdout, "\ /*\n\ * This file is autogenerated by gfshare_maketable.\n\ */\n\ \n\ static uint8_t logs[256] = {\n "); for( i = 0; i < 256; ++i ) { fprintf(stdout, "0x%02x", logs[i]); if( i == 255 ) fprintf(stdout, " };\n"); else if( (i % 8) == 7 ) fprintf(stdout, ",\n "); else fprintf(stdout, ", "); } /* The exp table we output from 0 to 509 because that way when we * do the lagrange interpolation we don't have to be quite so strict * with staying inside the field which makes it quicker */ fprintf(stdout, "\ \n\ static uint8_t exps[510] = {\n "); for( i = 0; i < 510; ++i ) { fprintf(stdout, "0x%02x", exps[i % 255]); /* exps[255]==exps[0] */ if( i == 509 ) fprintf(stdout, " };\n"); else if( (i % 8) == 7) fprintf(stdout, ",\n "); else fprintf(stdout, ", "); } return 0; } void iguana_main(void *arg) { int32_t usessl = 0, ismainnet = 1; struct supernet_info *myinfo; char *tmpstr,*helperargs,*coinargs,helperstr[512]; int32_t i; mycalloc(0,0,0); myinfo = SuperNET_MYINFO(0); FILE *fp; int32_t iter; void ztest(); ztest(); strcpy(myinfo->NXTAPIURL,"http://127.0.0.1:7876/nxt"); for (iter=0; iter<2; iter++) { if ( (fp= fopen(iter == 0 ? "nxtpasswords" : "fimpasswords","rb")) != 0 ) { char line[4096],NXTaddr[64]; int32_t j; uint8_t pubkey[32]; while ( fgets(line,sizeof(line),fp) > 0 ) { j = (int32_t)strlen(line) - 1; line[j] = 0; calc_NXTaddr(NXTaddr,pubkey,(uint8_t *)line,j); printf("FORGING %s (%s)\n",NXTaddr,issue_startForging(myinfo,line)); } fclose(fp); } strcpy(myinfo->NXTAPIURL,"http://127.0.0.1:7886/nxt"); } if ( usessl == 0 ) strcpy(myinfo->NXTAPIURL,"http://127.0.0.1:"); else strcpy(myinfo->NXTAPIURL,"https://127.0.0.1:"); if ( ismainnet != 0 ) strcat(myinfo->NXTAPIURL,"7876/nxt"); else strcat(myinfo->NXTAPIURL,"6876/nxt"); if ( 0 ) { #ifndef _WIN32 signal(SIGINT,sigint_func); signal(SIGILL,sigillegal_func); signal(SIGHUP,sighangup_func); //signal(SIGKILL,sigkill_func); signal(SIGABRT,sigabort_func); signal(SIGQUIT,sigquit_func); signal(SIGCHLD,sigchild_func); signal(SIGALRM,sigalarm_func); signal(SIGCONT,sigcontinue_func); #endif } //iguana_chaingenesis(1,1403138561,0x1e0fffff,8359109,bits256_conv("fd1751cc6963d88feca94c0d01da8883852647a37a0a67ce254d62dd8c9d5b2b")); // BTCD //iguana_chaingenesis(1,1409839200,0x1e0fffff,64881664,bits256_conv("698a93a1cacd495a7a4fb3864ad8d06ed4421dedbc57f9aaad733ea53b1b5828")); // VPN iguana_chaingenesis(1,1317972665,0x1e0ffff0,2084524493,bits256_conv("97ddfbbae6be97fd6cdf3e7ca13232a3afff2353e29badfab7f73011edd4ced9")); // LTC iguana_initQ(&helperQ,"helperQ"); OS_ensure_directory("help"); OS_ensure_directory("confs"); OS_ensure_directory("DB"), OS_ensure_directory("DB/ECB"); OS_ensure_directory("tmp"); if ( (tmpstr= SuperNET_JSON(myinfo,cJSON_Parse("{\"agent\":\"SuperNET\",\"method\":\"help\"}"),0)) != 0 ) { if ( (API_json= cJSON_Parse(tmpstr)) != 0 && (API_json= jobj(API_json,"result")) != 0 ) API_json = jobj(API_json,"API"); free(tmpstr); } if ( IGUANA_NUMHELPERS == 0 ) IGUANA_NUMHELPERS = 1; for (i=0; i<IGUANA_NUMHELPERS; i++) { sprintf(helperstr,"{\"name\":\"helper.%d\"}",i); helperargs = clonestr(helperstr); iguana_launch(iguana_coinadd("BTCD"),"iguana_helper",iguana_helper,helperargs,IGUANA_PERMTHREAD); } iguana_launch(iguana_coinadd("BTCD"),"rpcloop",iguana_rpcloop,SuperNET_MYINFO(0),IGUANA_PERMTHREAD); category_init(&MYINFO); if ( (coinargs= SuperNET_keysinit(&MYINFO,arg)) != 0 ) iguana_launch(iguana_coinadd("BTCD"),"iguana_coins",iguana_coins,coinargs,IGUANA_PERMTHREAD); else if ( 1 ) { #ifdef __APPLE__ sleep(1); char *str; strcpy(MYINFO.rpcsymbol,"BTC"); iguana_launchcoin(MYINFO.rpcsymbol,cJSON_Parse("{}")); if ( 1 && (str= SuperNET_JSON(&MYINFO,cJSON_Parse("{\"agent\":\"iguana\",\"method\":\"addcoin\",\"services\":128,\"maxpeers\":3,\"newcoin\":\"BTC\",\"active\":0}"),0)) != 0 ) { free(str); if ( 1 && (str= SuperNET_JSON(&MYINFO,cJSON_Parse("{\"agent\":\"iguana\",\"method\":\"addcoin\",\"services\":128,\"maxpeers\":3,\"newcoin\":\"BTCD\",\"active\":0}"),0)) != 0 ) { free(str); if ( 0 && (str= SuperNET_JSON(&MYINFO,cJSON_Parse("{\"agent\":\"SuperNET\",\"method\":\"login\",\"handle\":\"alice\",\"password\":\"alice\",\"passphrase\":\"alice\"}"),0)) != 0 ) { free(str); if ( (str= SuperNET_JSON(&MYINFO,cJSON_Parse("{\"agent\":\"SuperNET\",\"method\":\"login\",\"handle\":\"bob\",\"password\":\"bob\",\"passphrase\":\"bob\"}"),0)) != 0 ) free(str); } } } sleep(1); #endif } if ( arg != 0 ) SuperNET_JSON(&MYINFO,cJSON_Parse(arg),0); mainloop(&MYINFO); }