diff --git a/basilisk/basilisk.c b/basilisk/basilisk.c index ddb1634a4..59e4480b3 100755 --- a/basilisk/basilisk.c +++ b/basilisk/basilisk.c @@ -1294,7 +1294,7 @@ HASH_ARRAY_STRING(basilisk,rawtx,hash,vals,hexstr) STRING_ARG(jumblr,setpassphrase,passphrase) { cJSON *retjson; char KMDaddr[64],BTCaddr[64],wifstr[64]; bits256 privkey; struct iguana_info *coinbtc; - if ( passphrase == 0 || passphrase[0] == 0 || (coin= iguana_coinfind("KMD")) == 0 || coin->FULLNODE >= 0 ) + if ( passphrase == 0 || passphrase[0] == 0 || (coin= iguana_coinfind("KMD")) == 0 )//|| coin->FULLNODE >= 0 ) return(clonestr("{\"error\":\"no passphrase or no native komodod\"}")); else { diff --git a/basilisk/basilisk_bitcoin.c b/basilisk/basilisk_bitcoin.c index 3e29d422f..cbe759041 100755 --- a/basilisk/basilisk_bitcoin.c +++ b/basilisk/basilisk_bitcoin.c @@ -594,7 +594,7 @@ char *iguana_utxoduplicates(struct supernet_info *myinfo,struct iguana_info *coi for (i=0; i duplicates/4 ) + if ( cJSON_GetArraySize(vins) > duplicates/2 ) { free(rawtx); rawtx = 0; diff --git a/basilisk/jumblr.c b/basilisk/jumblr.c index 0ba6e311b..606e1c5dd 100755 --- a/basilisk/jumblr.c +++ b/basilisk/jumblr.c @@ -170,10 +170,12 @@ char *jumblr_zgetbalance(struct supernet_info *myinfo,struct iguana_info *coin,c return(bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"z_getbalance",params)); } -char *jumblr_listunspent(struct supernet_info *myinfo,struct iguana_info *coin,char *addr) +char *jumblr_listunspent(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr) { char params[1024]; - sprintf(params,"[1, 99999999, [\"%s\"]]",addr); + if ( coin->FULLNODE == 0 ) + return(dex_listunspent(myinfo,coin,0,0,coin->symbol,coinaddr)); + sprintf(params,"[1, 99999999, [\"%s\"]]",coinaddr); return(bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"listunspent",params)); } @@ -364,14 +366,17 @@ void jumblr_opidsupdate(struct supernet_info *myinfo,struct iguana_info *coin) } } -bits256 jumblr_privkey(struct supernet_info *myinfo,char *BTCaddr,uint8_t pubtype,char *KMDaddr,char *prefix) +bits256 jumblr_privkey(struct supernet_info *myinfo,char *coinaddr,uint8_t pubtype,char *KMDaddr,char *prefix) { bits256 privkey,pubkey; uint8_t pubkey33[33]; char passphrase[sizeof(myinfo->jumblr_passphrase) + 64]; sprintf(passphrase,"%s%s",prefix,myinfo->jumblr_passphrase); + if ( myinfo->jumblr_passphrase[0] == 0 ) + strcpy(myinfo->jumblr_passphrase,"password"); conv_NXTpassword(privkey.bytes,pubkey.bytes,(uint8_t *)passphrase,(int32_t)strlen(passphrase)); bitcoin_pubkey33(myinfo->ctx,pubkey33,privkey); - bitcoin_address(BTCaddr,pubtype,pubkey33,33); + bitcoin_address(coinaddr,pubtype,pubkey33,33); bitcoin_address(KMDaddr,60,pubkey33,33); + printf("(%s) -> (%s %s)\n",passphrase,coinaddr,KMDaddr); return(privkey); } @@ -520,9 +525,10 @@ int64_t jumblr_DEXutxoupdate(struct supernet_info *myinfo,struct iguana_info *co fees[3] = (strcmp("BTC",coin->symbol) == 0) ? 50000 : 10000; if ( (ind= jumblr_DEXutxoind(&shouldsplit,targetpriceB,targetpriceM,targetpriceS,amount,margin,dexfeeratio,fees[3])) >= 0 ) { + printf("shouldsplit.%d ind.%d\n",shouldsplit,ind); if ( shouldsplit != 0 ) return(jumblr_DEXsplit(myinfo,coin,splittxidp,coinaddr,txid,vout,value,margin * targetpriceB,margin * targetpriceM,margin * targetpriceS,fees)); - } + } else printf("negative ind\n"); return(0); } @@ -539,21 +545,25 @@ int64_t jumblr_DEXutxoupdate(struct supernet_info *myinfo,struct iguana_info *co int32_t jumblr_utxotxidpending(struct supernet_info *myinfo,bits256 *splittxidp,struct iguana_info *coin,bits256 txid,int32_t vout) { int32_t i; + printf("jumblr_utxotxidpending\n"); memset(splittxidp,0,sizeof(*splittxidp)); for (i=0; iDEXinfo.numpending; i++) { if ( coin->DEXinfo.pending[i].vout == vout && bits256_cmp(coin->DEXinfo.pending[i].txid,txid) == 0 ) { *splittxidp = coin->DEXinfo.pending[i].splittxid; + printf("jumblr_utxotxidpending found txid in slot.%d\n",i); return(i); } } + printf("jumblr_utxotxidpending cant find txid\n"); return(-1); } void jumblr_utxotxidpendingadd(struct supernet_info *myinfo,struct iguana_info *coin,bits256 txid,int32_t vout,bits256 splittxid) { struct jumblr_pending pend; + printf("add txid to pending\n"); memset(&pend,0,sizeof(pend)); pend.splittxid = splittxid; pend.txid = txid; @@ -565,8 +575,9 @@ void jumblr_utxotxidpendingadd(struct supernet_info *myinfo,struct iguana_info * void jumblr_utxoupdate(struct supernet_info *myinfo,struct iguana_info *coin,double price,char *coinaddr) { char *retstr; cJSON *array,*item; int32_t i,n,vout; bits256 txid,splittxid; uint64_t value; - if ( (retstr= _dex_listunspent(myinfo,coin->symbol,coinaddr)) != 0 ) + if ( (retstr= jumblr_listunspent(myinfo,coin,coinaddr)) != 0 ) { + printf("%s.(%s)\n",coin->symbol,retstr); if ( (array= cJSON_Parse(retstr)) != 0 ) { if ( (n= cJSON_GetArraySize(array)) > 0 ) @@ -577,11 +588,13 @@ void jumblr_utxoupdate(struct supernet_info *myinfo,struct iguana_info *coin,dou txid = jbits256(item,"txid"); vout = jint(item,"vout"); value = SATOSHIDEN * jdouble(item,"amount"); + printf("%llx/v%d %.8f %d of %d\n",(long long)txid.txid,vout,dstr(value),i,n); if ( jumblr_utxotxidpending(myinfo,&splittxid,coin,txid,vout) < 0 ) { + printf("call utxoupdate\n"); jumblr_DEXutxoupdate(myinfo,coin,&splittxid,coinaddr,txid,vout,value,myinfo->IAMLP); jumblr_utxotxidpendingadd(myinfo,coin,txid,vout,splittxid); - } + } else printf("already have txid\n"); } } free_json(array); @@ -601,16 +614,21 @@ void jumblr_DEXupdate(struct supernet_info *myinfo,struct iguana_info *coin,char safecopy(ptr->symbol,symbol,sizeof(ptr->symbol)); safecopy(ptr->CMCname,CMCname,sizeof(ptr->CMCname)); } - if ( ptr->depositaddr[0] == 0 ) + //if ( ptr->depositaddr[0] == 0 ) { if ( strcmp("KMD",symbol) == 0 ) ptr->deposit_privkey = jumblr_privkey(myinfo,ptr->depositaddr,0,ptr->KMDdepositaddr,JUMBLR_DEPOSITPREFIX); else ptr->deposit_privkey = jumblr_privkey(myinfo,ptr->depositaddr,ptr->coin->chain->pubtype,ptr->KMDdepositaddr,JUMBLR_DEPOSITPREFIX); } - if ( ptr->jumblraddr[0] == 0 ) - ptr->jumblr_privkey = jumblr_privkey(myinfo,ptr->jumblraddr,ptr->coin->chain->pubtype,ptr->KMDjumblraddr,""); + //if ( ptr->jumblraddr[0] == 0 ) + { + if ( strcmp("KMD",symbol) == 0 ) + ptr->jumblr_privkey = jumblr_privkey(myinfo,ptr->jumblraddr,0,ptr->KMDjumblraddr,""); + else ptr->jumblr_privkey = jumblr_privkey(myinfo,ptr->jumblraddr,ptr->coin->chain->pubtype,ptr->KMDjumblraddr,""); + } ptr->avail = dstr(jumblr_balance(myinfo,ptr->coin,ptr->depositaddr)); ptr->btcprice = get_theoretical(&avebid,&aveask,&highbid,&lowask,&CMC_average,changes,CMCname,symbol,"BTC",&ptr->USD_average); + printf("%s avail %.8f btcprice %.8f deposit.(%s %s) -> jumblr.(%s %s)\n",symbol,ptr->avail,ptr->btcprice,ptr->depositaddr,ptr->KMDdepositaddr,ptr->jumblraddr,ptr->KMDjumblraddr); if ( strcmp("KMD",symbol) == 0 ) { ptr->BTC2KMD = ptr->btcprice; @@ -627,7 +645,7 @@ void jumblr_DEXupdate(struct supernet_info *myinfo,struct iguana_info *coin,char jumblr_utxoupdate(myinfo,ptr->coin,ptr->kmdprice,ptr->depositaddr); } ptr->lasttime = (uint32_t)time(NULL); - } + } else printf("skip\n"); } void jumblr_CMCname(char *CMCname,char *symbol) diff --git a/iguana/dpow/dpow_network.c b/iguana/dpow/dpow_network.c index cadc11faa..94b80c90d 100755 --- a/iguana/dpow/dpow_network.c +++ b/iguana/dpow/dpow_network.c @@ -1154,7 +1154,7 @@ char *_dex_listunspentarg(struct supernet_info *myinfo,char *symbol,char *addres dexreq.func = arg; if ( (retstr= _dex_sendrequeststr(myinfo,&dexreq,address,0,1,"")) != 0 ) { - //printf("UNSPENTS.(%s)\n",retstr); + printf("%s UNSPENTS.(%s)\n",symbol,retstr); } return(_dex_arrayreturn(retstr)); } diff --git a/iguana/exchanges/bittrex.c b/iguana/exchanges/bittrex.c index 227cab9b1..dd7d4be26 100755 --- a/iguana/exchanges/bittrex.c +++ b/iguana/exchanges/bittrex.c @@ -169,7 +169,7 @@ uint64_t TRADE(int32_t dotrade,char **retstrp,struct exchange_info *exchange,cha if ( //CHECKBALANCE(retstrp,dotrade,exchange,dir,base,rel,price,volume,argjson) == 0 && (json= SIGNPOST(&exchange->cHandle,dotrade,retstrp,exchange,payload,payload)) != 0 ) { - if ( *retstrp != 0 ) + if ( 0 && *retstrp != 0 ) printf("SIGNPOST returned.(%s) %s\n",*retstrp,jprint(json,0)); if ( is_cJSON_True(cJSON_GetObjectItem(json,"success")) != 0 && (resultobj= cJSON_GetObjectItem(json,"result")) != 0 ) { diff --git a/iguana/iguana_rpc.c b/iguana/iguana_rpc.c index 20ad9aa78..554624dc2 100755 --- a/iguana/iguana_rpc.c +++ b/iguana/iguana_rpc.c @@ -874,6 +874,8 @@ char *SuperNET_rpcparse(struct supernet_info *myinfo,char *retbuf,int32_t bufsiz originstr = &urlstr[i + strlen(fieldstr)]; if ( strncmp(originstr,"http://127.0.0.",strlen("http://127.0.0.")) == 0 ) originstr = "http://127.0.0.1:"; + else if ( strncmp(originstr,"agama://",strlen("agama://")) == 0 ) + originstr = "http://127.0.0.1:"; else if ( strncmp(originstr,"file://127.0.0.",strlen("file://127.0.0.")) == 0 ) originstr = "http://127.0.0.1:"; else if ( strncmp(originstr,"chrome-extension://",strlen("chrome-extension://")) == 0 ) diff --git a/iguana/main.c b/iguana/main.c index 7b38676f9..71aad6eea 100755 --- a/iguana/main.c +++ b/iguana/main.c @@ -753,17 +753,20 @@ void jumblr_loop(void *ptr) printf("JUMBLR loop\n"); while ( 1 ) { - if ( myinfo->jumblr_passphrase[0] != 0 && (coin= iguana_coinfind("KMD")) != 0 && coin->FULLNODE < 0 ) + if ( (coin= iguana_coinfind("KMD")) != 0 ) { // if BTC has arrived in destination address, invoke DEX -> BTC jumblr_DEXcheck(myinfo,coin); - t = (uint32_t)time(NULL); - if ( (t % (120 * mult)) < 60 ) + if ( myinfo->jumblr_passphrase[0] != 0 && coin->FULLNODE < 0 ) { - // if BTC has arrived in deposit address, invoke DEX -> KMD - jumblr_iteration(myinfo,coin,(t % (360 * mult)) / (120 * mult),t % (120 * mult)); + t = (uint32_t)time(NULL); + if ( (t % (120 * mult)) < 60 ) + { + // if BTC has arrived in deposit address, invoke DEX -> KMD + jumblr_iteration(myinfo,coin,(t % (360 * mult)) / (120 * mult),t % (120 * mult)); + } + //printf("t.%u %p.%d %s\n",t,coin,coin!=0?coin->FULLNODE:0,myinfo->jumblr_passphrase); } - //printf("t.%u %p.%d %s\n",t,coin,coin!=0?coin->FULLNODE:0,myinfo->jumblr_passphrase); } sleep(55); }