From 3efa457f7d0ff6f63e71d650a49d6d2fd691ecc4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 30 Mar 2017 18:25:37 +0300 Subject: [PATCH 1/9] Test --- basilisk/basilisk.c | 2 +- basilisk/basilisk_bitcoin.c | 2 +- basilisk/jumblr.c | 21 +++++++++++++++------ iguana/exchanges/bittrex.c | 2 +- iguana/main.c | 15 +++++++++------ iguana/wp | 4 ++++ 6 files changed, 31 insertions(+), 15 deletions(-) create mode 100755 iguana/wp 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..fcae77073 100755 --- a/basilisk/jumblr.c +++ b/basilisk/jumblr.c @@ -364,14 +364,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); } @@ -567,6 +570,7 @@ void jumblr_utxoupdate(struct supernet_info *myinfo,struct iguana_info *coin,dou 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 ) { + printf("%s.(%s)\n",coin->symbol,retstr); if ( (array= cJSON_Parse(retstr)) != 0 ) { if ( (n= cJSON_GetArraySize(array)) > 0 ) @@ -601,16 +605,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 +636,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/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/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); } diff --git a/iguana/wp b/iguana/wp new file mode 100755 index 000000000..089af663c --- /dev/null +++ b/iguana/wp @@ -0,0 +1,4 @@ +#!/bin/bash +#curl --url "http://127.0.0.1:7778" --data "{\"method\":\"walletpassphrase\",\"params\":[\"test\", 600]}" +curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"bitcoinrpc\",\"method\":\"walletpassphrase\",\"password\":\"3809853923098test\",\"timeout\":86444}" +curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"jumblr\",\"method\":\"setpassphrase\",\"passphrase\":\"jumblr 3809853923098test\"}" From 7ba62c4a5bfb2393642878fd6ac64fb7ba4d5dd1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 30 Mar 2017 18:26:06 +0300 Subject: [PATCH 2/9] Test --- iguana/wp | 4 ---- 1 file changed, 4 deletions(-) delete mode 100755 iguana/wp diff --git a/iguana/wp b/iguana/wp deleted file mode 100755 index 089af663c..000000000 --- a/iguana/wp +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -#curl --url "http://127.0.0.1:7778" --data "{\"method\":\"walletpassphrase\",\"params\":[\"test\", 600]}" -curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"bitcoinrpc\",\"method\":\"walletpassphrase\",\"password\":\"3809853923098test\",\"timeout\":86444}" -curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"jumblr\",\"method\":\"setpassphrase\",\"passphrase\":\"jumblr 3809853923098test\"}" From 479fac14527476206caf2c2948b56c6451224ffa Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 30 Mar 2017 18:46:20 +0300 Subject: [PATCH 3/9] Test --- iguana/dpow/dpow_network.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/dpow/dpow_network.c b/iguana/dpow/dpow_network.c index cadc11faa..9a12103f9 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("UNSPENTS.(%s)\n",retstr); } return(_dex_arrayreturn(retstr)); } From cacf188f6366c073182bc694293785f038c06236 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 30 Mar 2017 18:50:31 +0300 Subject: [PATCH 4/9] Test --- basilisk/jumblr.c | 4 +++- iguana/dpow/dpow_network.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/basilisk/jumblr.c b/basilisk/jumblr.c index fcae77073..d20d58a99 100755 --- a/basilisk/jumblr.c +++ b/basilisk/jumblr.c @@ -173,6 +173,8 @@ char *jumblr_zgetbalance(struct supernet_info *myinfo,struct iguana_info *coin,c char *jumblr_listunspent(struct supernet_info *myinfo,struct iguana_info *coin,char *addr) { char params[1024]; + if ( coin->FULLNODE == 0 ) + return(_dex_listunspent(myinfo,coin->symbol,addr)); sprintf(params,"[1, 99999999, [\"%s\"]]",addr); return(bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"listunspent",params)); } @@ -568,7 +570,7 @@ 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 ) diff --git a/iguana/dpow/dpow_network.c b/iguana/dpow/dpow_network.c index 9a12103f9..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)); } From 113e95e98dc86eda1d66722aa4d9a6c4bf759c09 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 30 Mar 2017 19:04:47 +0300 Subject: [PATCH 5/9] Test --- basilisk/jumblr.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/basilisk/jumblr.c b/basilisk/jumblr.c index d20d58a99..b987b7126 100755 --- a/basilisk/jumblr.c +++ b/basilisk/jumblr.c @@ -170,12 +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]; if ( coin->FULLNODE == 0 ) - return(_dex_listunspent(myinfo,coin->symbol,addr)); - sprintf(params,"[1, 99999999, [\"%s\"]]",addr); + 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)); } From 6b7d6af3eaabc12c6198207f4e6dc803a6cfc07c Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 30 Mar 2017 19:11:11 +0300 Subject: [PATCH 6/9] Test --- basilisk/jumblr.c | 1 + 1 file changed, 1 insertion(+) diff --git a/basilisk/jumblr.c b/basilisk/jumblr.c index b987b7126..1eb937a08 100755 --- a/basilisk/jumblr.c +++ b/basilisk/jumblr.c @@ -583,6 +583,7 @@ 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 ) { jumblr_DEXutxoupdate(myinfo,coin,&splittxid,coinaddr,txid,vout,value,myinfo->IAMLP); From 8790db453d6bc391637e158988b5ee8ffe36e596 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 30 Mar 2017 19:26:39 +0300 Subject: [PATCH 7/9] Test --- basilisk/jumblr.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/basilisk/jumblr.c b/basilisk/jumblr.c index 1eb937a08..606e1c5dd 100755 --- a/basilisk/jumblr.c +++ b/basilisk/jumblr.c @@ -525,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); } @@ -544,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; @@ -586,9 +591,10 @@ void jumblr_utxoupdate(struct supernet_info *myinfo,struct iguana_info *coin,dou 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); From 9be6578f324210ed8a91b5472e0642b3975139d3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 31 Mar 2017 09:58:35 +0300 Subject: [PATCH 8/9] File:// --- iguana/iguana_rpc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/iguana_rpc.c b/iguana/iguana_rpc.c index 20ad9aa78..26fc9ac0b 100755 --- a/iguana/iguana_rpc.c +++ b/iguana/iguana_rpc.c @@ -874,7 +874,7 @@ 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,"file://127.0.0.",strlen("file://127.0.0.")) == 0 ) + else if ( strncmp(originstr,"file://",strlen("file://")) == 0 ) //127.0.0. originstr = "http://127.0.0.1:"; else if ( strncmp(originstr,"chrome-extension://",strlen("chrome-extension://")) == 0 ) originstr = "http://127.0.0.1:"; From 0fee3ebfd9bdd188051874c4cb38f98b9dec6d75 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 31 Mar 2017 10:24:47 +0300 Subject: [PATCH 9/9] Agama:// --- iguana/iguana_rpc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/iguana/iguana_rpc.c b/iguana/iguana_rpc.c index 26fc9ac0b..554624dc2 100755 --- a/iguana/iguana_rpc.c +++ b/iguana/iguana_rpc.c @@ -874,7 +874,9 @@ 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,"file://",strlen("file://")) == 0 ) //127.0.0. + 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 ) originstr = "http://127.0.0.1:";