diff --git a/basilisk/basilisk_swap.c b/basilisk/basilisk_swap.c index 7affd4813..47722efb9 100755 --- a/basilisk/basilisk_swap.c +++ b/basilisk/basilisk_swap.c @@ -918,7 +918,6 @@ void basilisk_swap01(struct supernet_info *myinfo,struct basilisk_swap *swap,uin void basilisk_swap02(struct supernet_info *myinfo,struct basilisk_swap *swap,uint8_t *data,int32_t maxlen) { - basilisk_swap01(myinfo,swap,data,maxlen); printf("check for other deck\n"); if ( basilisk_swapget(myinfo,swap,0x02,data,maxlen,basilisk_verify_otherdeck) == 0 ) swap->statebits |= 0x02; @@ -927,8 +926,6 @@ void basilisk_swap02(struct supernet_info *myinfo,struct basilisk_swap *swap,uin void basilisk_swap04(struct supernet_info *myinfo,struct basilisk_swap *swap,uint8_t *data,int32_t maxlen) { int32_t i,datalen; char str[65]; - //if ( (rand() % 10) == 0 ) - basilisk_swap02(myinfo,swap,data,maxlen); datalen = iguana_rwnum(1,data,sizeof(swap->choosei),&swap->choosei); if ( swap->iambob != 0 ) { @@ -952,8 +949,6 @@ void basilisk_swap04(struct supernet_info *myinfo,struct basilisk_swap *swap,uin void basilisk_swap08(struct supernet_info *myinfo,struct basilisk_swap *swap,uint8_t *data,int32_t maxlen) { uint8_t pubkey33[33]; char str[65]; - //if ( (rand() % 10) == 0 ) - basilisk_swap04(myinfo,swap,data,maxlen); printf("check otherchoosei\n"); if ( basilisk_swapget(myinfo,swap,0x08,data,maxlen,basilisk_verify_choosei) == 0 ) { @@ -986,8 +981,6 @@ void basilisk_swap08(struct supernet_info *myinfo,struct basilisk_swap *swap,uin void basilisk_swap10(struct supernet_info *myinfo,struct basilisk_swap *swap,uint8_t *data,int32_t maxlen) { int32_t i,j,datalen; - if ( (rand() % 10) == 0 ) - basilisk_swap08(myinfo,swap,data,maxlen); datalen = 0; for (i=0; iprivkeys)/sizeof(*swap->privkeys); i++) { @@ -1027,18 +1020,39 @@ void basilisk_swaploop(void *_swap) data = malloc(maxlen); while ( time(NULL) < swap->expiration ) { - fprintf(stderr,"r%u/q%u swapstate.%x\n",swap->req.requestid,swap->req.quoteid,swap->statebits); - if ( (swap->statebits & 0x01) == 0 ) // send pubkeys - basilisk_swap01(myinfo,swap,data,maxlen); - else if ( (swap->statebits & 0x02) == 0 ) // wait for pubkeys - basilisk_swap02(myinfo,swap,data,maxlen); - else if ( (swap->statebits & 0x04) == 0 ) // send choosei - basilisk_swap04(myinfo,swap,data,maxlen); - else if ( (swap->statebits & 0x08) == 0 ) // wait for choosei - basilisk_swap08(myinfo,swap,data,maxlen); - else if ( (swap->statebits & 0x10) == 0 && swap->otherchoosei >= 0 && swap->otherchoosei < INSTANTDEX_DECKSIZE ) // send all but one privkeys - basilisk_swap10(myinfo,swap,data,maxlen); - else if ( (swap->statebits & 0x20) == 0 ) // wait for all but one privkeys + printf("r%u/q%u swapstate.%x\n",swap->req.requestid,swap->req.quoteid,swap->statebits); + if ( swap->iambob != 0 ) + { + if ( (swap->statebits & 0x08) == 0 ) + { + basilisk_swap01(myinfo,swap,data,maxlen); // send pubkeys + basilisk_swap08(myinfo,swap,data,maxlen); // wait for choosei + } + else + { + basilisk_swap02(myinfo,swap,data,maxlen); // check for other deck + basilisk_swap04(myinfo,swap,data,maxlen); // send choosei + if ( (swap->statebits & 0x10) == 0 && swap->otherchoosei >= 0 && swap->otherchoosei < INSTANTDEX_DECKSIZE ) // send all but one privkeys + basilisk_swap10(myinfo,swap,data,maxlen); + } + } + else + { + if ( (swap->statebits & 0x10) == 0 ) + { + basilisk_swap02(myinfo,swap,data,maxlen); // check for other deck + basilisk_swap04(myinfo,swap,data,maxlen); // send choosei + if ( (swap->statebits & 0x10) == 0 && swap->otherchoosei >= 0 && swap->otherchoosei < INSTANTDEX_DECKSIZE ) // send all but one privkeys + basilisk_swap10(myinfo,swap,data,maxlen); + } + else + { + basilisk_swap04(myinfo,swap,data,maxlen); // send choosei + basilisk_swap01(myinfo,swap,data,maxlen); // send pubkeys + basilisk_swap08(myinfo,swap,data,maxlen); // wait for choosei + } + } + if ( (swap->statebits & 0x20) == 0 ) // wait for all but one privkeys { if ( basilisk_swapget(myinfo,swap,0x20,data,maxlen,basilisk_verify_privkeys) == 0 ) swap->statebits |= 0x20; diff --git a/iguana/SuperNET_keys.c b/iguana/SuperNET_keys.c index 3d8a3c1d3..3e7455b7e 100755 --- a/iguana/SuperNET_keys.c +++ b/iguana/SuperNET_keys.c @@ -218,7 +218,7 @@ cJSON *SuperNET_decryptedjson(char *destfname,char *passphrase,int32_t passsize, wallethash = GENESIS_PRIVKEY; wallet2shared = SuperNET_wallet2shared(wallethash,wallet2priv); wallet2pub = curve25519(wallet2shared,curve25519_basepoint9()); - sprintf(destfname,"confs/%s",bits256_str(str,wallet2pub)); + sprintf(destfname,"%s/%s",GLOBAL_CONFSDIR,bits256_str(str,wallet2pub)); //printf("fname.(%s) wallet2pub.%s < [%s, %s]\n",destfname,bits256_str(str,wallet2pub),passphrase,fname2fa); if ( (confstr= OS_filestr(&allocsize,destfname)) != 0 ) { @@ -268,7 +268,7 @@ int32_t _SuperNET_encryptjson(struct supernet_info *myinfo,char *destfname,char //char str2[65]; printf("ENCRYPT.[%s %s] (%s) 2.%s\n",passphrase,fname2fa,bits256_str(str,wallethash),bits256_str(str2,wallet2priv)); wallet2shared = SuperNET_wallet2shared(wallethash,wallet2priv); wallet2pub = curve25519(wallet2shared,curve25519_basepoint9()); - sprintf(destfname,"confs/%s",bits256_str(str,wallet2pub)); + sprintf(destfname,"%s/%s",GLOBAL_CONFSDIR,bits256_str(str,wallet2pub)); //printf("SAVE ARGJSON.(%s) [%s, %s] -> destfname.(%s)\n",jprint(argjson,0),passphrase,fname2fa,destfname); //printf("shared.%llx -> pub.%s\n",(long long)wallet2shared.txid,bits256_str(str,wallet2pub)); SuperNET_savejsonfile(myinfo,destfname,wallethash,wallet2pub,argjson); diff --git a/iguana/iguana777.c b/iguana/iguana777.c index e7d5fc11e..283e3ea92 100755 --- a/iguana/iguana777.c +++ b/iguana/iguana777.c @@ -852,7 +852,7 @@ struct iguana_info *iguana_setcoin(char *symbol,void *launched,int32_t maxpeers, strcpy(coin->name,"illegalcoin"); coin->symbol[0] = 0; return(0); - } + } if ( jobj(json,"RELAY") != 0 ) coin->RELAYNODE = juint(json,"RELAY"); else coin->RELAYNODE = (strcmp(coin->symbol,"BTCD") == 0); diff --git a/iguana/iguana_chains.c b/iguana/iguana_chains.c index c6127638b..18819ead0 100755 --- a/iguana/iguana_chains.c +++ b/iguana/iguana_chains.c @@ -36,6 +36,7 @@ static struct iguana_chain Chains[] = "0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4adae5494dffff001d1aa4ae180101000000010000000000000000000000000000000000000000000000000000000000000000ffffffff4d04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73ffffffff0100f2052a01000000434104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac00000000", 18333,18334,0, },*/ + // curl --data '{"jsonrpc": "2.0", "method": "get_order_book", "params": [], "id": 1}' http://127.0.0.1:8090/rpc //[CHAIN_BITCOIN] = { //CHAIN_BITCOIN, @@ -291,7 +292,9 @@ void iguana_chainparms(struct iguana_chain *chain,cJSON *argjson) if ( strcmp(chain->symbol,"NXT") != 0 ) { if ( strcmp(chain->symbol,"BTCD") == 0 ) - chain->pubtype = 60, chain->p2shtype = 85; + chain->pubtype = 60, chain->p2shtype = 85, chain->portp2p = 14631, chain->rpcport = 14632; + else if ( strcmp(chain->symbol,"BTC") == 0 ) + chain->pubtype = 0, chain->p2shtype = 5, chain->portp2p = 8333, chain->rpcport = 8332; else chain->do_opreturn = juint(argjson,"do_opreturn"); if ( (chain->minoutput= j64bits(argjson,"minoutput")) == 0 ) chain->minoutput = 10000; @@ -323,6 +326,20 @@ void iguana_chainparms(struct iguana_chain *chain,cJSON *argjson) if ( chain->portp2p != 0 ) chain->rpcport = chain->portp2p-1; } + if ( chain->portp2p == 0 ) + { + if ( strcmp("BTC",chain->symbol) == 0 ) + chain->portp2p = 8333; + else if ( strcmp("BTCD",chain->symbol) == 0 ) + chain->portp2p = 14631; + } + if ( chain->rpcport == 0 ) + { + if ( strcmp("BTC",chain->symbol) == 0 ) + chain->rpcport = 8332; + else if ( strcmp("BTCD",chain->symbol) == 0 ) + chain->rpcport = 14632; + } chain->zcash = juint(argjson,"zcash"); if ( (chain->normal_txversion= juint(argjson,"normal_txversion")) == 0 ) chain->normal_txversion = IGUANA_NORMAL_TXVERSION; @@ -429,7 +446,7 @@ void iguana_chainparms(struct iguana_chain *chain,cJSON *argjson) } } sprintf(chain->messagemagic,"%s Signed Message:\n",chain->name); - printf("COIN.%s serverport.(%s) userpass.(%s) RPCport.%u magic.%08x\n",chain->symbol,chain->serverport,chain->userpass,chain->rpcport,*(uint32_t *)chain->netmagic); + printf("COIN.%s serverport.(%s) userpass.(%s) RPCport.%u P2P.%u magic.%08x\n",chain->symbol,chain->serverport,chain->userpass,chain->rpcport,chain->portp2p,*(uint32_t *)chain->netmagic); } } diff --git a/iguana/iguana_peers.c b/iguana/iguana_peers.c index 8104903b6..9c8e0060a 100755 --- a/iguana/iguana_peers.c +++ b/iguana/iguana_peers.c @@ -715,7 +715,7 @@ void iguana_startconnection(void *arg) if ( addr->usock < 0 || (coin->peers != 0 && coin->peers->shuttingdown != 0) ) { strcpy(ipaddr,addr->ipaddr); - //printf("%s refused PEER KILLED. slot.%d for %s:%d usock.%d\n",coin->symbol,addr->addrind,ipaddr,coin->chain->portp2p,addr->usock); + printf("%s refused PEER KILLED. slot.%d for %s:%d usock.%d\n",coin->symbol,addr->addrind,ipaddr,coin->chain->portp2p,addr->usock); iguana_iAkill(coin,addr,1); } else @@ -740,7 +740,7 @@ void iguana_startconnection(void *arg) coin->peers->ranked[0] = addr; } else n = 0; iguana_iAconnected(coin,addr); - //printf("%s.PEER CONNECTED.%d:%d of max.%d! %s:%d usock.%d\n",coin->symbol,coin->peers->numconnected,n,coin->MAXPEERS,addr->ipaddr,coin->chain->portp2p,addr->usock); + printf("%s.PEER CONNECTED.%d:%d of max.%d! %s:%d usock.%d\n",coin->symbol,coin->peers->numconnected,n,coin->MAXPEERS,addr->ipaddr,coin->chain->portp2p,addr->usock); #ifdef IGUANA_DEDICATED_THREADS //iguana_launch("recv",iguana_dedicatedrecv,addr,IGUANA_RECVTHREAD); iguana_dedicatedloop(SuperNET_MYINFO(0),coin,addr); diff --git a/iguana/main.c b/iguana/main.c index ab1ae2a39..4f4f57715 100755 --- a/iguana/main.c +++ b/iguana/main.c @@ -1458,7 +1458,7 @@ FOUR_STRINGS(SuperNET,login,handle,password,permanentfile,passphrase) void iguana_main(void *arg) { - int32_t usessl = 0, ismainnet = 1; struct supernet_info *myinfo; cJSON *argjson = 0; + int32_t usessl = 0, ismainnet = 1; struct supernet_info *myinfo; //cJSON *argjson = 0; if ( (IGUANA_BIGENDIAN= iguana_isbigendian()) > 0 ) printf("BIGENDIAN\n"); else if ( IGUANA_BIGENDIAN == 0 ) @@ -1525,16 +1525,20 @@ void iguana_main(void *arg) myinfo->tradingexchanges[myinfo->numexchanges++] = exchange_create("bittrex",0); myinfo->tradingexchanges[myinfo->numexchanges++] = exchange_create("btc38",0); myinfo->tradingexchanges[myinfo->numexchanges++] = exchange_create("huobi",0); - argjson = arg != 0 ? cJSON_Parse(arg) : cJSON_Parse("{}"); + //argjson = arg != 0 ? cJSON_Parse(arg) : cJSON_Parse("{}"); //iguana_coinadd("BTC",argjson); dont do this here, coin args not set ///iguana_coinadd("LTC",argjson); - free_json(argjson); + //free_json(argjson); + printf("helpinit\n"); iguana_helpinit(myinfo); + printf("basilisks_init\n"); basilisks_init(myinfo); + printf("iguana_commandline\n"); iguana_commandline(myinfo,arg); #ifdef __APPLE__ iguana_appletests(myinfo); #endif + printf("iguana_launchdaemons\n"); iguana_launchdaemons(myinfo); } diff --git a/includes/iguana_globals.h b/includes/iguana_globals.h index d8b22b016..c5ab2e536 100755 --- a/includes/iguana_globals.h +++ b/includes/iguana_globals.h @@ -27,12 +27,12 @@ char *Iguana_validcommands[] = }; #ifdef __PNACL__ -char GLOBAL_TMPDIR[512] = "/DB/tmp"; -char GLOBAL_DBDIR[512] = "/DB"; -char GLOBAL_GENESISDIR[512] = "/genesis"; -char GLOBAL_HELPDIR[512] = "/DB/help"; -char GLOBAL_VALIDATEDIR[512] = "/DB/purgeable"; -char GLOBAL_CONFSDIR[512] = "/DB/confs"; +char GLOBAL_TMPDIR[512] = "/tmp"; +char GLOBAL_DBDIR[512] = "DB"; +char GLOBAL_GENESISDIR[512] = "genesis"; +char GLOBAL_HELPDIR[512] = "DB/help"; +char GLOBAL_VALIDATEDIR[512] = "DB/purgeable"; +char GLOBAL_CONFSDIR[512] = "DB"; int32_t IGUANA_NUMHELPERS = 1; #else char GLOBAL_TMPDIR[512] = "tmp"; diff --git a/pnacl_main.h b/pnacl_main.h index 97bd076db..be31ff876 100755 --- a/pnacl_main.h +++ b/pnacl_main.h @@ -361,9 +361,9 @@ static PP_Bool Instance_DidCreate(PP_Instance instance,uint32_t argc,const char* umount("/"); mount("", "/", "memfs", 0, ""); //mkdir("/tmp",0755); - mkdir("/DB",0755); + mkdir("DB",0755); //mount("","/tmp","html5fs",0,"type=TEMPORARY,expected_size=2000000000"); - mount("","/DB","html5fs",0,"type=PERSISTENT,expected_size=10000000000"); + mount("","DB","html5fs",0,"type=PERSISTENT,expected_size=10000000000"); /*mount("", // source. Use relative URL "/http", // target "httpfs", // filesystemtype