From ba9a75d779291a53505dde5d8cc51424f5d7ffdc Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 4 Mar 2017 01:46:02 +0200 Subject: [PATCH 01/24] Test --- basilisk/jumblr.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/basilisk/jumblr.c b/basilisk/jumblr.c index b2ae526e4..1b59067a4 100755 --- a/basilisk/jumblr.c +++ b/basilisk/jumblr.c @@ -71,6 +71,13 @@ char *jumblr_zgetoperationresult(struct supernet_info *myinfo,struct iguana_info return(bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"z_getoperationresult",params)); } +char *jumblr_zgetoperationstatus(struct supernet_info *myinfo,struct iguana_info *coin,char *opid) +{ + char params[1024]; + sprintf(params,"[[\"%s\"]]",opid); + return(bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"z_getoperationstatus",params)); +} + char *jumblr_sendt_to_z(struct supernet_info *myinfo,struct iguana_info *coin,char *taddr,char *zaddr,double amount) { char params[1024]; double fee = (amount-3*JUMBLR_TXFEE) * JUMBLR_FEE; @@ -212,7 +219,7 @@ void jumblr_opidupdate(struct supernet_info *myinfo,struct iguana_info *coin,str char *retstr,*status; cJSON *retjson; if ( ptr->status == 0 ) { - if ( (retstr= jumblr_zgetoperationresult(myinfo,coin,ptr->opid)) != 0 ) + if ( (retstr= jumblr_zgetoperationstatus(myinfo,coin,ptr->opid)) != 0 ) { if ( (retjson= cJSON_Parse(retstr)) != 0 ) { From 390ff2af7be584811f5e86d7ccaf9a113571a215 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 4 Mar 2017 02:02:28 +0200 Subject: [PATCH 02/24] Test --- basilisk/jumblr.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/basilisk/jumblr.c b/basilisk/jumblr.c index 1b59067a4..f4126d628 100755 --- a/basilisk/jumblr.c +++ b/basilisk/jumblr.c @@ -374,7 +374,7 @@ STRING_ARG(jumblr,setpassphrase,passphrase) ZERO_ARGS(jumblr,status) { - cJSON *retjson; char KMDaddr[64],BTCaddr[64]; struct jumblr_item *ptr,*tmp; int64_t deposited,step_t2z,step_z2z,step_z2t,finished; + cJSON *retjson; char KMDaddr[64],BTCaddr[64]; struct jumblr_item *ptr,*tmp; int64_t received,deposited,jumblred,step_t2z,step_z2z,step_z2t,finished; if ( strcmp(coin->symbol,"KMD") == 0 && coin->FULLNODE < 0 && myinfo->jumblr_passphrase[0] != 0 ) { jumblr_opidsupdate(myinfo,coin); @@ -383,11 +383,13 @@ ZERO_ARGS(jumblr,status) jumblr_privkey(myinfo,BTCaddr,KMDaddr,JUMBLR_DEPOSITPREFIX); jaddstr(retjson,"BTCdeposit","notyet"); jaddstr(retjson,"KMDdeposit",KMDaddr); - deposited = jumblr_receivedby(myinfo,coin,KMDaddr); + received = jumblr_receivedby(myinfo,coin,KMDaddr); + deposited = SATOSHIDEN * jumblr_balance(myinfo,coin,KMDaddr); jumblr_privkey(myinfo,BTCaddr,KMDaddr,""); jaddstr(retjson,"BTCjumblr","notyet"); jaddstr(retjson,"KMDjumblr",KMDaddr); finished = jumblr_receivedby(myinfo,coin,KMDaddr); + jumblred = SATOSHIDEN * jumblr_balance(myinfo,coin,KMDaddr); HASH_ITER(hh,myinfo->jumblrs,ptr,tmp) { if ( strlen(ptr->src) >= 40 ) @@ -404,7 +406,9 @@ ZERO_ARGS(jumblr,status) jaddnum(retjson,"z_to_z",dstr(step_z2z)); jaddnum(retjson,"z_to_t",dstr(step_z2t)); jaddnum(retjson,"finished",dstr(finished)); - jaddnum(retjson,"pending",dstr(deposited) - dstr(finished)); + jaddnum(retjson,"received",dstr(received)); + jaddnum(retjson,"pending",dstr(received) - dstr(finished)); + jaddnum(retjson,"jumblred",dstr(jumblred)); return(jprint(retjson,1)); } else return(clonestr("{\"error\":\"no passphrase or no native komodod\"}")); } From e3c6793ef1564dab84425fc20ac1d6bf0b1829b1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 4 Mar 2017 02:09:21 +0200 Subject: [PATCH 03/24] Test --- basilisk/jumblr.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/basilisk/jumblr.c b/basilisk/jumblr.c index f4126d628..8ab873903 100755 --- a/basilisk/jumblr.c +++ b/basilisk/jumblr.c @@ -102,14 +102,14 @@ char *jumblr_sendz_to_t(struct supernet_info *myinfo,struct iguana_info *coin,ch char *jumblr_zlistreceivedbyaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *addr) { char params[1024]; - sprintf(params,"[\"%s\", 1]",addr); + sprintf(params,"[\"%s\", 3]",addr); return(bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"z_listreceivedbyaddress",params)); } char *jumblr_getreceivedbyaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *addr) { char params[1024]; - sprintf(params,"[\"%s\", 1]",addr); + sprintf(params,"[\"%s\", 3]",addr); return(bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"getreceivedbyaddress",params)); } @@ -123,10 +123,17 @@ char *jumblr_importprivkey(struct supernet_info *myinfo,struct iguana_info *coin char *jumblr_zgetbalance(struct supernet_info *myinfo,struct iguana_info *coin,char *addr) { char params[1024]; - sprintf(params,"[\"%s\", 1]",addr); + sprintf(params,"[\"%s\", 3]",addr); return(bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"z_getbalance",params)); } +char *jumblr_getbalance(struct supernet_info *myinfo,struct iguana_info *coin,char *addr) +{ + char params[1024]; + sprintf(params,"[\"%s\", 3]",addr); + return(bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"getbalance",params)); +} + int64_t jumblr_receivedby(struct supernet_info *myinfo,struct iguana_info *coin,char *addr) { char *retstr; int64_t total = 0; //cJSON *retjson,*item; int32_t i,n; @@ -153,16 +160,13 @@ int64_t jumblr_receivedby(struct supernet_info *myinfo,struct iguana_info *coin, int64_t jumblr_balance(struct supernet_info *myinfo,struct iguana_info *coin,char *addr) { - char *retstr; double val; cJSON *retjson; int64_t balance = 0; + char *retstr; double val; int64_t balance = 0; if ( strlen(addr) < 40 ) { - if ( (retstr= _dex_getbalance(myinfo,coin->symbol,addr)) != 0 ) + if ( (retstr= jumblr_getbalance(myinfo,coin,addr)) != 0 ) { - if ( (retjson= cJSON_Parse(retstr)) != 0 ) - { - balance = jdouble(retjson,"balance") * SATOSHIDEN; - free_json(retjson); - } + if ( (val= atof(retstr)) > SMALLVAL ) + balance = val * SATOSHIDEN; free(retstr); } } From f6960cbb8880eaebbc6a2aa9eac516ed263f0d5e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 4 Mar 2017 02:13:35 +0200 Subject: [PATCH 04/24] Test --- basilisk/jumblr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basilisk/jumblr.c b/basilisk/jumblr.c index 8ab873903..b3f0dc3ca 100755 --- a/basilisk/jumblr.c +++ b/basilisk/jumblr.c @@ -131,7 +131,7 @@ char *jumblr_getbalance(struct supernet_info *myinfo,struct iguana_info *coin,ch { char params[1024]; sprintf(params,"[\"%s\", 3]",addr); - return(bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"getbalance",params)); + return(bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"getreceivedbyaddress",params)); } int64_t jumblr_receivedby(struct supernet_info *myinfo,struct iguana_info *coin,char *addr) From fcc956f79b6fa9b8de6dac4d649e36c195d442be Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 4 Mar 2017 02:18:40 +0200 Subject: [PATCH 05/24] Test --- basilisk/jumblr.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/basilisk/jumblr.c b/basilisk/jumblr.c index b3f0dc3ca..b40be9279 100755 --- a/basilisk/jumblr.c +++ b/basilisk/jumblr.c @@ -127,11 +127,11 @@ 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_getbalance(struct supernet_info *myinfo,struct iguana_info *coin,char *addr) +char *jumblr_listunspent(struct supernet_info *myinfo,struct iguana_info *coin,char *addr) { char params[1024]; - sprintf(params,"[\"%s\", 3]",addr); - return(bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"getreceivedbyaddress",params)); + sprintf(params,"[3, 99999999, \"%s\"]",addr); + return(bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"listunspent",params)); } int64_t jumblr_receivedby(struct supernet_info *myinfo,struct iguana_info *coin,char *addr) @@ -160,13 +160,18 @@ int64_t jumblr_receivedby(struct supernet_info *myinfo,struct iguana_info *coin, int64_t jumblr_balance(struct supernet_info *myinfo,struct iguana_info *coin,char *addr) { - char *retstr; double val; int64_t balance = 0; + char *retstr; double val; cJSON *retjson; int32_t i,n; int64_t balance = 0; if ( strlen(addr) < 40 ) { - if ( (retstr= jumblr_getbalance(myinfo,coin,addr)) != 0 ) + if ( (retstr= jumblr_listunspent(myinfo,coin,addr)) != 0 ) { - if ( (val= atof(retstr)) > SMALLVAL ) - balance = val * SATOSHIDEN; + if ( (retjson= cJSON_Parse(retstr)) != 0 ) + { + if ( (n= cJSON_GetArraySize(retjson)) > 0 ) + for (i=0; ijumblrs,ptr,tmp) { if ( strlen(ptr->src) >= 40 ) From dcc6d75d09a53a9a7def8ac237d85a95a0628ee8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 4 Mar 2017 02:20:24 +0200 Subject: [PATCH 06/24] Test --- basilisk/jumblr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basilisk/jumblr.c b/basilisk/jumblr.c index b40be9279..46a1bf979 100755 --- a/basilisk/jumblr.c +++ b/basilisk/jumblr.c @@ -130,7 +130,7 @@ 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]; - sprintf(params,"[3, 99999999, \"%s\"]",addr); + sprintf(params,"[3, 99999999, [\"%s\"]]",addr); return(bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"listunspent",params)); } From 2c4081bc578ffba67da7d7ec2ed7ca82249ca63c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 4 Mar 2017 02:21:20 +0200 Subject: [PATCH 07/24] Test --- basilisk/jumblr.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/basilisk/jumblr.c b/basilisk/jumblr.c index 46a1bf979..4cfd89367 100755 --- a/basilisk/jumblr.c +++ b/basilisk/jumblr.c @@ -102,14 +102,14 @@ char *jumblr_sendz_to_t(struct supernet_info *myinfo,struct iguana_info *coin,ch char *jumblr_zlistreceivedbyaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *addr) { char params[1024]; - sprintf(params,"[\"%s\", 3]",addr); + sprintf(params,"[\"%s\", 1]",addr); return(bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"z_listreceivedbyaddress",params)); } char *jumblr_getreceivedbyaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *addr) { char params[1024]; - sprintf(params,"[\"%s\", 3]",addr); + sprintf(params,"[\"%s\", 1]",addr); return(bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"getreceivedbyaddress",params)); } @@ -123,14 +123,14 @@ char *jumblr_importprivkey(struct supernet_info *myinfo,struct iguana_info *coin char *jumblr_zgetbalance(struct supernet_info *myinfo,struct iguana_info *coin,char *addr) { char params[1024]; - sprintf(params,"[\"%s\", 3]",addr); + sprintf(params,"[\"%s\", 1]",addr); 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 params[1024]; - sprintf(params,"[3, 99999999, [\"%s\"]]",addr); + sprintf(params,"[1, 99999999, [\"%s\"]]",addr); return(bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"listunspent",params)); } From 9763b00743378783d5311d59cbea75c899218289 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 4 Mar 2017 09:33:27 +0200 Subject: [PATCH 08/24] Test --- basilisk/jumblr.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/basilisk/jumblr.c b/basilisk/jumblr.c index 4cfd89367..d5b26f1f2 100755 --- a/basilisk/jumblr.c +++ b/basilisk/jumblr.c @@ -136,22 +136,9 @@ char *jumblr_listunspent(struct supernet_info *myinfo,struct iguana_info *coin,c int64_t jumblr_receivedby(struct supernet_info *myinfo,struct iguana_info *coin,char *addr) { - char *retstr; int64_t total = 0; //cJSON *retjson,*item; int32_t i,n; + char *retstr; int64_t total = 0; if ( (retstr= jumblr_getreceivedbyaddress(myinfo,coin,addr)) != 0 ) { - printf("jumblr_getreceivedbyaddress.(%s) -> (%s)\n",addr,retstr); - /*if ( (retjson= cJSON_Parse(retstr)) != 0 ) - { - if ( (n= cJSON_GetArraySize(retjson)) > 0 ) - { - for (i=0; isrc,from,sizeof(ptr->src)); if ( (amounts= jarray(&n,params,"amounts")) != 0 ) @@ -207,6 +197,7 @@ void jumblr_itemset(struct jumblr_item *ptr,cJSON *item,char *status) for (i=0; i 0 ) { if ( strcmp(addr,JUMBLR_ADDR) == 0 ) @@ -246,6 +237,7 @@ void jumblr_opidsupdate(struct supernet_info *myinfo,struct iguana_info *coin) char *retstr; cJSON *array; int32_t i,n; struct jumblr_item *ptr; if ( (retstr= jumblr_zlistoperationids(myinfo,coin)) != 0 ) { + printf("%s\n",retstr); if ( (array= cJSON_Parse(retstr)) != 0 ) { if ( (n= cJSON_GetArraySize(array)) > 0 ) From bfd38344436dd9a083de756e809508c7ccf5b8d8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 4 Mar 2017 09:53:10 +0200 Subject: [PATCH 09/24] Test --- basilisk/jumblr.c | 1 + 1 file changed, 1 insertion(+) diff --git a/basilisk/jumblr.c b/basilisk/jumblr.c index d5b26f1f2..6b57481a6 100755 --- a/basilisk/jumblr.c +++ b/basilisk/jumblr.c @@ -221,6 +221,7 @@ void jumblr_opidupdate(struct supernet_info *myinfo,struct iguana_info *coin,str { if ( (retstr= jumblr_zgetoperationstatus(myinfo,coin,ptr->opid)) != 0 ) { + printf("%s\n",retstr); if ( (retjson= cJSON_Parse(retstr)) != 0 ) { if ( (status= jstr(retjson,"status")) != 0 && strcmp(status,"pending") != 0 ) From a19417c6c8c4d39bae4945f0ddf68159925f61b7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 4 Mar 2017 09:55:54 +0200 Subject: [PATCH 10/24] Test --- basilisk/jumblr.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/basilisk/jumblr.c b/basilisk/jumblr.c index 6b57481a6..6bd80bab7 100755 --- a/basilisk/jumblr.c +++ b/basilisk/jumblr.c @@ -221,10 +221,9 @@ void jumblr_opidupdate(struct supernet_info *myinfo,struct iguana_info *coin,str { if ( (retstr= jumblr_zgetoperationstatus(myinfo,coin,ptr->opid)) != 0 ) { - printf("%s\n",retstr); if ( (retjson= cJSON_Parse(retstr)) != 0 ) { - if ( (status= jstr(retjson,"status")) != 0 && strcmp(status,"pending") != 0 ) + if ( (status= jstr(retjson,"status")) != 0 && strcmp(status,"success") == 0 ) jumblr_itemset(ptr,retjson,status); free_json(retjson); } From 9574d0d83d2a1484d095311875c0727cb9bf66ae Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 4 Mar 2017 09:58:07 +0200 Subject: [PATCH 11/24] Test --- basilisk/jumblr.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/basilisk/jumblr.c b/basilisk/jumblr.c index 6bd80bab7..45e3d8cdd 100755 --- a/basilisk/jumblr.c +++ b/basilisk/jumblr.c @@ -173,7 +173,7 @@ int64_t jumblr_balance(struct supernet_info *myinfo,struct iguana_info *coin,cha return(balance); } -void jumblr_itemset(struct jumblr_item *ptr,cJSON *item,char *status) +int32_t jumblr_itemset(struct jumblr_item *ptr,cJSON *item,char *status) { cJSON *params,*amounts,*dest; char *from,*addr; int32_t i,n; int64_t amount; /*"params" : { @@ -212,6 +212,7 @@ void jumblr_itemset(struct jumblr_item *ptr,cJSON *item,char *status) } ptr->txfee = jdouble(params,"fee") * SATOSHIDEN; } + return(1); } void jumblr_opidupdate(struct supernet_info *myinfo,struct iguana_info *coin,struct jumblr_item *ptr) @@ -223,8 +224,17 @@ void jumblr_opidupdate(struct supernet_info *myinfo,struct iguana_info *coin,str { if ( (retjson= cJSON_Parse(retstr)) != 0 ) { - if ( (status= jstr(retjson,"status")) != 0 && strcmp(status,"success") == 0 ) - jumblr_itemset(ptr,retjson,status); + if ( (status= jstr(retjson,"status")) != 0 ) + { + if ( strcmp(status,"success") == 0 ) + ptr->status = jumblr_itemset(ptr,retjson,status); + else if ( strcmp(status,"failure") == 0 ) + { + printf("%s failed\n",ptr->opid); + free(jumblr_zgetoperationresult(myinfo,coin,ptr->opid)); + ptr->status = -1; + } + } free_json(retjson); } free(retstr); From 0fc2622ce6f3c20b3ba1be88945d30da6f923dea Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 4 Mar 2017 10:01:03 +0200 Subject: [PATCH 12/24] Test --- basilisk/jumblr.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/basilisk/jumblr.c b/basilisk/jumblr.c index 45e3d8cdd..835840b6d 100755 --- a/basilisk/jumblr.c +++ b/basilisk/jumblr.c @@ -217,22 +217,28 @@ int32_t jumblr_itemset(struct jumblr_item *ptr,cJSON *item,char *status) void jumblr_opidupdate(struct supernet_info *myinfo,struct iguana_info *coin,struct jumblr_item *ptr) { - char *retstr,*status; cJSON *retjson; + char *retstr,*status; cJSON *retjson,*item; if ( ptr->status == 0 ) { if ( (retstr= jumblr_zgetoperationstatus(myinfo,coin,ptr->opid)) != 0 ) { if ( (retjson= cJSON_Parse(retstr)) != 0 ) { - if ( (status= jstr(retjson,"status")) != 0 ) + if ( cJSON_GetArraySize(retjson) == 1 ) { - if ( strcmp(status,"success") == 0 ) - ptr->status = jumblr_itemset(ptr,retjson,status); - else if ( strcmp(status,"failure") == 0 ) + item = jitem(retjson,0); + if ( (status= jstr(item,"status")) != 0 ) { - printf("%s failed\n",ptr->opid); - free(jumblr_zgetoperationresult(myinfo,coin,ptr->opid)); - ptr->status = -1; + if ( strcmp(status,"success") == 0 ) + { + ptr->status = jumblr_itemset(ptr,item,status); + } + else if ( strcmp(status,"failure") == 0 ) + { + printf("%s failed\n",ptr->opid); + free(jumblr_zgetoperationresult(myinfo,coin,ptr->opid)); + ptr->status = -1; + } } } free_json(retjson); From 65e2efa1bb3bcfce67e2ea723d99771851633b67 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 4 Mar 2017 10:03:49 +0200 Subject: [PATCH 13/24] Test --- iguana/iguana777.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/iguana777.h b/iguana/iguana777.h index 8e33594a5..aa85d607c 100755 --- a/iguana/iguana777.h +++ b/iguana/iguana777.h @@ -96,7 +96,7 @@ struct jumblr_item UT_hash_handle hh; int64_t amount,fee,txfee; uint32_t spent; - char opid[65],src[65],dest[65],status; + char opid[66],src[66],dest[66],status; }; struct liquidity_info From c7a42536e55b144858cc7bb3733198a4912a0494 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 4 Mar 2017 10:05:51 +0200 Subject: [PATCH 14/24] Test --- iguana/iguana777.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iguana/iguana777.h b/iguana/iguana777.h index aa85d607c..89d25f734 100755 --- a/iguana/iguana777.h +++ b/iguana/iguana777.h @@ -95,8 +95,8 @@ struct jumblr_item { UT_hash_handle hh; int64_t amount,fee,txfee; - uint32_t spent; - char opid[66],src[66],dest[66],status; + uint32_t spent,pad; + char opid[64],src[128],dest[128],status; }; struct liquidity_info From b91196347b40e87aadaa28e31c0b98e43bacecce Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 4 Mar 2017 10:08:29 +0200 Subject: [PATCH 15/24] Test --- basilisk/jumblr.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/basilisk/jumblr.c b/basilisk/jumblr.c index 835840b6d..bb28fa0a4 100755 --- a/basilisk/jumblr.c +++ b/basilisk/jumblr.c @@ -27,7 +27,7 @@ z_sendmany "fromaddress" [{"address":... ,"amount":..., "memo":""},...] ( minconf ) ( fee ) */ -#define JUMBLR_INCR 99 +#define JUMBLR_INCR 99.5 #define JUMBLR_TXFEE 0.01 #define JUMBLR_ADDR "RGhxXpXSSBTBm9EvNsXnTQczthMCxHX91t" #define JUMBLR_BTCADDR "18RmTJe9qMech8siuhYfMtHo8RtcN1obC6" @@ -159,8 +159,8 @@ int64_t jumblr_balance(struct supernet_info *myinfo,struct iguana_info *coin,cha balance += SATOSHIDEN * jdouble(jitem(retjson,i),"amount"); free_json(retjson); } - if ( balance == 0 ) - printf("listunspent.(%s)\n",addr); + //if ( balance == 0 ) + // printf("listunspent.(%s)\n",addr); free(retstr); } } @@ -189,7 +189,7 @@ int32_t jumblr_itemset(struct jumblr_item *ptr,cJSON *item,char *status) }*/ if ( (params= jobj(item,"params")) != 0 ) { - printf("params.(%s)\n",jprint(params,0)); + //printf("params.(%s)\n",jprint(params,0)); if ( (from= jstr(params,"fromaddress")) != 0 ) safecopy(ptr->src,from,sizeof(ptr->src)); if ( (amounts= jarray(&n,params,"amounts")) != 0 ) @@ -227,6 +227,7 @@ void jumblr_opidupdate(struct supernet_info *myinfo,struct iguana_info *coin,str if ( cJSON_GetArraySize(retjson) == 1 ) { item = jitem(retjson,0); + printf("%s\n",jprint(item,0)); if ( (status= jstr(item,"status")) != 0 ) { if ( strcmp(status,"success") == 0 ) From ed6b926d5649950987a21d83a10a77f9b1bae552 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 4 Mar 2017 10:12:32 +0200 Subject: [PATCH 16/24] Test --- basilisk/jumblr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/basilisk/jumblr.c b/basilisk/jumblr.c index bb28fa0a4..ccb90f81d 100755 --- a/basilisk/jumblr.c +++ b/basilisk/jumblr.c @@ -227,14 +227,14 @@ void jumblr_opidupdate(struct supernet_info *myinfo,struct iguana_info *coin,str if ( cJSON_GetArraySize(retjson) == 1 ) { item = jitem(retjson,0); - printf("%s\n",jprint(item,0)); + //printf("%s\n",jprint(item,0)); if ( (status= jstr(item,"status")) != 0 ) { if ( strcmp(status,"success") == 0 ) { ptr->status = jumblr_itemset(ptr,item,status); } - else if ( strcmp(status,"failure") == 0 ) + else if ( strcmp(status,"failed") == 0 ) { printf("%s failed\n",ptr->opid); free(jumblr_zgetoperationresult(myinfo,coin,ptr->opid)); From 80d74e755b893d2898ad6465dbd39537af54e373 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 4 Mar 2017 10:21:28 +0200 Subject: [PATCH 17/24] Test --- basilisk/jumblr.c | 8 +++++--- iguana/main.c | 8 ++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/basilisk/jumblr.c b/basilisk/jumblr.c index ccb90f81d..13ab787e9 100755 --- a/basilisk/jumblr.c +++ b/basilisk/jumblr.c @@ -322,6 +322,7 @@ r = 0; { if ( strlen(ptr->src) < 40 ) { + printf("%s -> %s check for z to z\n",ptr->src,ptr->dest); if ( (r & 7) == 0 && ptr->spent == 0 && (total= jumblr_balance(myinfo,coin,ptr->dest)) >= (fee + JUMBLR_FEE)*SATOSHIDEN ) { if ( (zaddr= jumblr_zgetnewaddress(myinfo,coin)) != 0 ) @@ -345,6 +346,7 @@ r = 0; { if ( strlen(ptr->src) >= 40 ) { + printf("%s -> %s check for z to t\n",ptr->src,ptr->dest); if ( (r & 7) == 0 && ptr->spent == 0 && (total= jumblr_balance(myinfo,coin,ptr->dest)) >= (fee + JUMBLR_FEE)*SATOSHIDEN ) { priv0 = jumblr_privkey(myinfo,BTCaddr,KMDaddr,""); @@ -423,10 +425,10 @@ ZERO_ARGS(jumblr,status) jaddnum(retjson,"t_to_z",dstr(step_t2z)); jaddnum(retjson,"z_to_z",dstr(step_z2z)); jaddnum(retjson,"z_to_t",dstr(step_z2t)); - jaddnum(retjson,"finished",dstr(finished)); - jaddnum(retjson,"received",dstr(received)); - jaddnum(retjson,"pending",dstr(received) - dstr(finished)); + jaddnum(retjson,"pending",dstr(deposited) + dstr(step_t2z) + dstr(step_z2z) + dstr(step_z2t)); jaddnum(retjson,"jumblred",dstr(jumblred)); + jaddnum(retjson,"received",dstr(received)); + jaddnum(retjson,"finished",dstr(finished)); return(jprint(retjson,1)); } else return(clonestr("{\"error\":\"no passphrase or no native komodod\"}")); } diff --git a/iguana/main.c b/iguana/main.c index fc9ed1609..86742ee04 100755 --- a/iguana/main.c +++ b/iguana/main.c @@ -747,17 +747,17 @@ void iguana_urlinit(struct supernet_info *myinfo,int32_t ismainnet,int32_t usess void jumblr_loop(void *ptr) { - struct iguana_info *coin; uint32_t t; struct supernet_info *myinfo = ptr; + struct iguana_info *coin; uint32_t t; struct supernet_info *myinfo = ptr; int32_t mult = 1; printf("JUMBLR loop\n"); while ( 1 ) { t = (uint32_t)time(NULL); - if ( (coin= iguana_coinfind("KMD")) != 0 && coin->FULLNODE < 0 && myinfo->jumblr_passphrase[0] != 0 && (t % 1200) < 60 ) + if ( (coin= iguana_coinfind("KMD")) != 0 && coin->FULLNODE < 0 && myinfo->jumblr_passphrase[0] != 0 && (t % (120 * mult)) < 60 ) { - jumblr_iteration(myinfo,coin,(t % 3600) / 1200,t % 1200); + 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); - sleep(20); + sleep(40); } } From bb745350f86419b6c4bc8f58c19043b6b3246f52 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 4 Mar 2017 10:22:30 +0200 Subject: [PATCH 18/24] Test --- basilisk/jumblr.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/basilisk/jumblr.c b/basilisk/jumblr.c index 13ab787e9..f1a84ff43 100755 --- a/basilisk/jumblr.c +++ b/basilisk/jumblr.c @@ -159,8 +159,8 @@ int64_t jumblr_balance(struct supernet_info *myinfo,struct iguana_info *coin,cha balance += SATOSHIDEN * jdouble(jitem(retjson,i),"amount"); free_json(retjson); } - //if ( balance == 0 ) - // printf("listunspent.(%s)\n",addr); + if ( balance == 0 ) + printf("listunspent.(%s)\n",addr); free(retstr); } } @@ -197,7 +197,7 @@ int32_t jumblr_itemset(struct jumblr_item *ptr,cJSON *item,char *status) for (i=0; i 0 ) { if ( strcmp(addr,JUMBLR_ADDR) == 0 ) @@ -254,7 +254,6 @@ void jumblr_opidsupdate(struct supernet_info *myinfo,struct iguana_info *coin) char *retstr; cJSON *array; int32_t i,n; struct jumblr_item *ptr; if ( (retstr= jumblr_zlistoperationids(myinfo,coin)) != 0 ) { - printf("%s\n",retstr); if ( (array= cJSON_Parse(retstr)) != 0 ) { if ( (n= cJSON_GetArraySize(array)) > 0 ) From cd433621215d2be1de5c9536d2fe1e83d0deb25e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 4 Mar 2017 10:30:47 +0200 Subject: [PATCH 19/24] Test --- basilisk/jumblr.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/basilisk/jumblr.c b/basilisk/jumblr.c index f1a84ff43..560fa8552 100755 --- a/basilisk/jumblr.c +++ b/basilisk/jumblr.c @@ -393,12 +393,12 @@ STRING_ARG(jumblr,setpassphrase,passphrase) ZERO_ARGS(jumblr,status) { - cJSON *retjson; char KMDaddr[64],BTCaddr[64]; struct jumblr_item *ptr,*tmp; int64_t received,deposited,jumblred,step_t2z,step_z2z,step_z2t,finished; + cJSON *retjson; char KMDaddr[64],BTCaddr[64]; struct jumblr_item *ptr,*tmp; int64_t pending,received,deposited,jumblred,step_t2z,step_z2z,step_z2t,finished; if ( strcmp(coin->symbol,"KMD") == 0 && coin->FULLNODE < 0 && myinfo->jumblr_passphrase[0] != 0 ) { jumblr_opidsupdate(myinfo,coin); retjson = cJSON_CreateObject(); - step_t2z = step_z2z = step_z2t = deposited = finished = 0; + step_t2z = step_z2z = step_z2t = deposited = finished = pending = 0; jumblr_privkey(myinfo,BTCaddr,KMDaddr,JUMBLR_DEPOSITPREFIX); jaddstr(retjson,"BTCdeposit","notyet"); jaddstr(retjson,"KMDdeposit",KMDaddr); @@ -416,15 +416,16 @@ ZERO_ARGS(jumblr,status) if ( strlen(ptr->dest) >= 40 ) step_z2z += ptr->amount; else step_z2t += ptr->amount; - } - else step_t2z += ptr->amount; + } else step_t2z += ptr->amount; + if ( ptr->spent == 0 ) + pending += ptr->amount; } jaddstr(retjson,"result","success"); jaddnum(retjson,"deposited",dstr(deposited)); jaddnum(retjson,"t_to_z",dstr(step_t2z)); jaddnum(retjson,"z_to_z",dstr(step_z2z)); jaddnum(retjson,"z_to_t",dstr(step_z2t)); - jaddnum(retjson,"pending",dstr(deposited) + dstr(step_t2z) + dstr(step_z2z) + dstr(step_z2t)); + jaddnum(retjson,"pending",dstr(pending)); jaddnum(retjson,"jumblred",dstr(jumblred)); jaddnum(retjson,"received",dstr(received)); jaddnum(retjson,"finished",dstr(finished)); From cad9d1b0d638f0f06ecb42fe77e0694601dd4115 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 4 Mar 2017 10:53:31 +0200 Subject: [PATCH 20/24] Test --- basilisk/jumblr.c | 50 ++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 7 deletions(-) diff --git a/basilisk/jumblr.c b/basilisk/jumblr.c index 560fa8552..05151401f 100755 --- a/basilisk/jumblr.c +++ b/basilisk/jumblr.c @@ -33,6 +33,15 @@ #define JUMBLR_BTCADDR "18RmTJe9qMech8siuhYfMtHo8RtcN1obC6" #define JUMBLR_FEE 0.001 +int32_t jumblr_addresstype(struct supernet_info *myinfo,struct iguana_info *coin,char *addr) +{ + if ( addr[0] == 'z' && addr[1] == 'c' && strlen(addr) >= 40 ) + return('z'); + else if ( strlen(addr) < 40 ) + return('t'); + else return(-1); +} + struct jumblr_item *jumblr_opidfind(struct supernet_info *myinfo,char *opid) { struct jumblr_item *ptr; @@ -81,6 +90,8 @@ char *jumblr_zgetoperationstatus(struct supernet_info *myinfo,struct iguana_info char *jumblr_sendt_to_z(struct supernet_info *myinfo,struct iguana_info *coin,char *taddr,char *zaddr,double amount) { char params[1024]; double fee = (amount-3*JUMBLR_TXFEE) * JUMBLR_FEE; + if ( jumblr_addresstype(myinfo,coin,zaddr) != 'z' || jumblr_addresstype(myinfo,coin,taddr) != 't' ) + return(clonestr("{\"error\":\"illegal address in t to z\"}")); sprintf(params,"[\"%s\", [{\"address\":\"%s\",\"amount\":%.8f}, {\"address\":\"%s\",\"amount\":%.8f}], 1, %.8f]",taddr,zaddr,amount-fee-JUMBLR_TXFEE,JUMBLR_ADDR,fee,JUMBLR_TXFEE); return(bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"z_sendmany",params)); } @@ -88,6 +99,8 @@ char *jumblr_sendt_to_z(struct supernet_info *myinfo,struct iguana_info *coin,ch char *jumblr_sendz_to_z(struct supernet_info *myinfo,struct iguana_info *coin,char *zaddrS,char *zaddrD,double amount) { char params[1024]; double fee = (amount-2*JUMBLR_TXFEE) * JUMBLR_FEE; + if ( jumblr_addresstype(myinfo,coin,zaddrS) != 'z' || jumblr_addresstype(myinfo,coin,zaddrD) != 'z' ) + return(clonestr("{\"error\":\"illegal address in z to z\"}")); sprintf(params,"[\"%s\", [{\"address\":\"%s\",\"amount\":%.8f}, {\"address\":\"%s\",\"amount\":%.8f}], 1, %.8f]",zaddrS,zaddrD,amount-fee-JUMBLR_TXFEE,JUMBLR_ADDR,fee,JUMBLR_TXFEE); return(bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"z_sendmany",params)); } @@ -95,6 +108,8 @@ char *jumblr_sendz_to_z(struct supernet_info *myinfo,struct iguana_info *coin,ch char *jumblr_sendz_to_t(struct supernet_info *myinfo,struct iguana_info *coin,char *zaddr,char *taddr,double amount) { char params[1024]; double fee = (amount-JUMBLR_TXFEE) * JUMBLR_FEE; + if ( jumblr_addresstype(myinfo,coin,zaddr) != 'z' || jumblr_addresstype(myinfo,coin,taddr) != 't' ) + return(clonestr("{\"error\":\"illegal address in z to t\"}")); sprintf(params,"[\"%s\", [{\"address\":\"%s\",\"amount\":%.8f}, {\"address\":\"%s\",\"amount\":%.8f}], 1, %.8f]",zaddr,taddr,amount-fee-JUMBLR_TXFEE,JUMBLR_ADDR,fee,JUMBLR_TXFEE); return(bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"z_sendmany",params)); } @@ -148,7 +163,7 @@ int64_t jumblr_receivedby(struct supernet_info *myinfo,struct iguana_info *coin, int64_t jumblr_balance(struct supernet_info *myinfo,struct iguana_info *coin,char *addr) { char *retstr; double val; cJSON *retjson; int32_t i,n; int64_t balance = 0; - if ( strlen(addr) < 40 ) + if ( jumblr_addresstype(myinfo,coin,addr) == 't' ) { if ( (retstr= jumblr_listunspent(myinfo,coin,addr)) != 0 ) { @@ -259,8 +274,14 @@ void jumblr_opidsupdate(struct supernet_info *myinfo,struct iguana_info *coin) if ( (n= cJSON_GetArraySize(array)) > 0 ) { for (i=0; istatus == 0 ) - jumblr_opidupdate(myinfo,coin,ptr); + { + if ( (ptr= jumblr_opidadd(myinfo,coin,jstri(array,i))) != 0 ) + { + if ( ptr->status == 0 ) + jumblr_opidupdate(myinfo,coin,ptr); + printf("%d: %s -> %s %.8f\n",ptr->status,ptr->src,ptr->dest,dstr(ptr->amount)); + } + } } free_json(array); } @@ -279,6 +300,22 @@ bits256 jumblr_privkey(struct supernet_info *myinfo,char *BTCaddr,char *KMDaddr, return(privkey); } +void jumblr_prune(struct supernet_info *myinfo,struct iguana_info *coin,struct jumblr_item *ptr) +{ + struct jumblr_item *tmp; char oldsrc[128]; + strcpy(oldsrc,ptr->src); + free(jumblr_zgetoperationresult(myinfo,coin,ptr->opid)); + HASH_ITER(hh,myinfo->jumblrs,ptr,tmp) + { + if ( strcmp(oldsrc,ptr->dest) == 0 ) + { + printf("%s (%s -> %s) matched oldsrc\n",ptr->opid,ptr->src,ptr->dest); + free(jumblr_zgetoperationresult(myinfo,coin,ptr->opid)); + strcpy(oldsrc,ptr->src); + } + } +} + void jumblr_iteration(struct supernet_info *myinfo,struct iguana_info *coin,int32_t selector,int32_t modval) { char BTCaddr[64],KMDaddr[64],*zaddr,*retstr; bits256 priv0; uint64_t amount=0,total=0; double fee; struct jumblr_item *ptr,*tmp; uint8_t r; @@ -319,9 +356,8 @@ r = 0; jumblr_opidsupdate(myinfo,coin); HASH_ITER(hh,myinfo->jumblrs,ptr,tmp) { - if ( strlen(ptr->src) < 40 ) + if ( jumblr_addresstype(myinfo,coin,ptr->src) == 't' && jumblr_addresstype(myinfo,coin,ptr->dest) == 'z' ) { - printf("%s -> %s check for z to z\n",ptr->src,ptr->dest); if ( (r & 7) == 0 && ptr->spent == 0 && (total= jumblr_balance(myinfo,coin,ptr->dest)) >= (fee + JUMBLR_FEE)*SATOSHIDEN ) { if ( (zaddr= jumblr_zgetnewaddress(myinfo,coin)) != 0 ) @@ -343,9 +379,8 @@ r = 0; jumblr_opidsupdate(myinfo,coin); HASH_ITER(hh,myinfo->jumblrs,ptr,tmp) { - if ( strlen(ptr->src) >= 40 ) + if ( jumblr_addresstype(myinfo,coin,ptr->src) == 'z' && jumblr_addresstype(myinfo,coin,ptr->dest) == 'z' ) { - printf("%s -> %s check for z to t\n",ptr->src,ptr->dest); if ( (r & 7) == 0 && ptr->spent == 0 && (total= jumblr_balance(myinfo,coin,ptr->dest)) >= (fee + JUMBLR_FEE)*SATOSHIDEN ) { priv0 = jumblr_privkey(myinfo,BTCaddr,KMDaddr,""); @@ -353,6 +388,7 @@ r = 0; { printf("sendz_to_t.(%s)\n",retstr); free(retstr); + jumblr_prune(myinfo,coin,ptr); } ptr->spent = (uint32_t)time(NULL); break; From 18100ada9ed7f00997533bbcd9f6cf169d223abe Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 4 Mar 2017 11:05:23 +0200 Subject: [PATCH 21/24] Test --- basilisk/jumblr.c | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/basilisk/jumblr.c b/basilisk/jumblr.c index 05151401f..f66fa2a0e 100755 --- a/basilisk/jumblr.c +++ b/basilisk/jumblr.c @@ -27,7 +27,7 @@ z_sendmany "fromaddress" [{"address":... ,"amount":..., "memo":""},...] ( minconf ) ( fee ) */ -#define JUMBLR_INCR 99.5 +#define JUMBLR_INCR 99.65 #define JUMBLR_TXFEE 0.01 #define JUMBLR_ADDR "RGhxXpXSSBTBm9EvNsXnTQczthMCxHX91t" #define JUMBLR_BTCADDR "18RmTJe9qMech8siuhYfMtHo8RtcN1obC6" @@ -264,6 +264,22 @@ void jumblr_opidupdate(struct supernet_info *myinfo,struct iguana_info *coin,str } } +void jumblr_prune(struct supernet_info *myinfo,struct iguana_info *coin,struct jumblr_item *ptr) +{ + struct jumblr_item *tmp; char oldsrc[128]; + strcpy(oldsrc,ptr->src); + free(jumblr_zgetoperationresult(myinfo,coin,ptr->opid)); + HASH_ITER(hh,myinfo->jumblrs,ptr,tmp) + { + if ( strcmp(oldsrc,ptr->dest) == 0 ) + { + printf("prune %s (%s -> %s) matched oldsrc\n",ptr->opid,ptr->src,ptr->dest); + free(jumblr_zgetoperationresult(myinfo,coin,ptr->opid)); + strcpy(oldsrc,ptr->src); + } + } +} + void jumblr_opidsupdate(struct supernet_info *myinfo,struct iguana_info *coin) { char *retstr; cJSON *array; int32_t i,n; struct jumblr_item *ptr; @@ -280,6 +296,8 @@ void jumblr_opidsupdate(struct supernet_info *myinfo,struct iguana_info *coin) if ( ptr->status == 0 ) jumblr_opidupdate(myinfo,coin,ptr); printf("%d: %s -> %s %.8f\n",ptr->status,ptr->src,ptr->dest,dstr(ptr->amount)); + if ( jumblr_addresstype(myinfo,coin,ptr->src) == 'z' && strcmp(ptr->dest,JUMBLR_ADDR) == 0 ) + jumblr_prune(myinfo,coin,ptr); } } } @@ -300,22 +318,6 @@ bits256 jumblr_privkey(struct supernet_info *myinfo,char *BTCaddr,char *KMDaddr, return(privkey); } -void jumblr_prune(struct supernet_info *myinfo,struct iguana_info *coin,struct jumblr_item *ptr) -{ - struct jumblr_item *tmp; char oldsrc[128]; - strcpy(oldsrc,ptr->src); - free(jumblr_zgetoperationresult(myinfo,coin,ptr->opid)); - HASH_ITER(hh,myinfo->jumblrs,ptr,tmp) - { - if ( strcmp(oldsrc,ptr->dest) == 0 ) - { - printf("%s (%s -> %s) matched oldsrc\n",ptr->opid,ptr->src,ptr->dest); - free(jumblr_zgetoperationresult(myinfo,coin,ptr->opid)); - strcpy(oldsrc,ptr->src); - } - } -} - void jumblr_iteration(struct supernet_info *myinfo,struct iguana_info *coin,int32_t selector,int32_t modval) { char BTCaddr[64],KMDaddr[64],*zaddr,*retstr; bits256 priv0; uint64_t amount=0,total=0; double fee; struct jumblr_item *ptr,*tmp; uint8_t r; @@ -388,7 +390,6 @@ r = 0; { printf("sendz_to_t.(%s)\n",retstr); free(retstr); - jumblr_prune(myinfo,coin,ptr); } ptr->spent = (uint32_t)time(NULL); break; From 66f24aea41bc5f8f94167c8f918acd3517e04c25 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 4 Mar 2017 11:07:10 +0200 Subject: [PATCH 22/24] Test --- basilisk/jumblr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basilisk/jumblr.c b/basilisk/jumblr.c index f66fa2a0e..87ee3ed71 100755 --- a/basilisk/jumblr.c +++ b/basilisk/jumblr.c @@ -296,7 +296,7 @@ void jumblr_opidsupdate(struct supernet_info *myinfo,struct iguana_info *coin) if ( ptr->status == 0 ) jumblr_opidupdate(myinfo,coin,ptr); printf("%d: %s -> %s %.8f\n",ptr->status,ptr->src,ptr->dest,dstr(ptr->amount)); - if ( jumblr_addresstype(myinfo,coin,ptr->src) == 'z' && strcmp(ptr->dest,JUMBLR_ADDR) == 0 ) + if ( jumblr_addresstype(myinfo,coin,ptr->src) == 'z' && jumblr_addresstype(myinfo,coin,ptr->dest) == 't' ) jumblr_prune(myinfo,coin,ptr); } } From 8289832e696b3cef5b198dad11dc3a5c26cfbcb2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 4 Mar 2017 11:36:53 +0200 Subject: [PATCH 23/24] Test --- basilisk/jumblr.c | 36 ++++++++++++++++++++---------------- iguana/main.c | 2 +- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/basilisk/jumblr.c b/basilisk/jumblr.c index 87ee3ed71..739f249c6 100755 --- a/basilisk/jumblr.c +++ b/basilisk/jumblr.c @@ -266,16 +266,23 @@ void jumblr_opidupdate(struct supernet_info *myinfo,struct iguana_info *coin,str void jumblr_prune(struct supernet_info *myinfo,struct iguana_info *coin,struct jumblr_item *ptr) { - struct jumblr_item *tmp; char oldsrc[128]; + struct jumblr_item *tmp; char oldsrc[128]; int32_t flag = 1; + printf("PRUNE %s\n",ptr->opid); strcpy(oldsrc,ptr->src); free(jumblr_zgetoperationresult(myinfo,coin,ptr->opid)); - HASH_ITER(hh,myinfo->jumblrs,ptr,tmp) + while ( flag != 0 ) { - if ( strcmp(oldsrc,ptr->dest) == 0 ) + flag = 0; + HASH_ITER(hh,myinfo->jumblrs,ptr,tmp) { - printf("prune %s (%s -> %s) matched oldsrc\n",ptr->opid,ptr->src,ptr->dest); - free(jumblr_zgetoperationresult(myinfo,coin,ptr->opid)); - strcpy(oldsrc,ptr->src); + if ( strcmp(oldsrc,ptr->dest) == 0 ) + { + printf("prune %s (%s -> %s) matched oldsrc\n",ptr->opid,ptr->src,ptr->dest); + free(jumblr_zgetoperationresult(myinfo,coin,ptr->opid)); + strcpy(oldsrc,ptr->src); + flag = 1; + break; + } } } } @@ -335,7 +342,7 @@ r = 0; priv0 = jumblr_privkey(myinfo,BTCaddr,KMDaddr,JUMBLR_DEPOSITPREFIX); if ( (total= jumblr_balance(myinfo,coin,KMDaddr)) >= (JUMBLR_INCR + 3*(fee+JUMBLR_TXFEE))*SATOSHIDEN ) { - if ( (r & 7) == 0 ) + if ( (r & 1) == 0 ) { if ( (zaddr= jumblr_zgetnewaddress(myinfo,coin)) != 0 ) { @@ -352,7 +359,7 @@ r = 0; free(zaddr); } else printf("no zaddr from jumblr_zgetnewaddress\n"); } - } else printf("%s total %.8f vs %.8f\n",KMDaddr,dstr(total),(JUMBLR_INCR + 3*(fee+JUMBLR_TXFEE))); + } //else printf("%s total %.8f vs %.8f\n",KMDaddr,dstr(total),(JUMBLR_INCR + 3*(fee+JUMBLR_TXFEE))); break; case 1: // z -> z jumblr_opidsupdate(myinfo,coin); @@ -360,7 +367,7 @@ r = 0; { if ( jumblr_addresstype(myinfo,coin,ptr->src) == 't' && jumblr_addresstype(myinfo,coin,ptr->dest) == 'z' ) { - if ( (r & 7) == 0 && ptr->spent == 0 && (total= jumblr_balance(myinfo,coin,ptr->dest)) >= (fee + JUMBLR_FEE)*SATOSHIDEN ) + if ( (r & 1) == 0 && ptr->spent == 0 && (total= jumblr_balance(myinfo,coin,ptr->dest)) >= (fee + JUMBLR_FEE)*SATOSHIDEN ) { if ( (zaddr= jumblr_zgetnewaddress(myinfo,coin)) != 0 ) { @@ -383,7 +390,7 @@ r = 0; { if ( jumblr_addresstype(myinfo,coin,ptr->src) == 'z' && jumblr_addresstype(myinfo,coin,ptr->dest) == 'z' ) { - if ( (r & 7) == 0 && ptr->spent == 0 && (total= jumblr_balance(myinfo,coin,ptr->dest)) >= (fee + JUMBLR_FEE)*SATOSHIDEN ) + if ( (r & 1) == 0 && ptr->spent == 0 && (total= jumblr_balance(myinfo,coin,ptr->dest)) >= (fee + JUMBLR_FEE)*SATOSHIDEN ) { priv0 = jumblr_privkey(myinfo,BTCaddr,KMDaddr,""); if ( (retstr= jumblr_sendz_to_t(myinfo,coin,ptr->dest,KMDaddr,dstr(total))) != 0 ) @@ -430,12 +437,12 @@ STRING_ARG(jumblr,setpassphrase,passphrase) ZERO_ARGS(jumblr,status) { - cJSON *retjson; char KMDaddr[64],BTCaddr[64]; struct jumblr_item *ptr,*tmp; int64_t pending,received,deposited,jumblred,step_t2z,step_z2z,step_z2t,finished; + cJSON *retjson; char KMDaddr[64],BTCaddr[64]; struct jumblr_item *ptr,*tmp; int64_t received,deposited,jumblred,step_t2z,step_z2z,step_z2t,finished; if ( strcmp(coin->symbol,"KMD") == 0 && coin->FULLNODE < 0 && myinfo->jumblr_passphrase[0] != 0 ) { jumblr_opidsupdate(myinfo,coin); retjson = cJSON_CreateObject(); - step_t2z = step_z2z = step_z2t = deposited = finished = pending = 0; + step_t2z = step_z2z = step_z2t = deposited = finished = 0; jumblr_privkey(myinfo,BTCaddr,KMDaddr,JUMBLR_DEPOSITPREFIX); jaddstr(retjson,"BTCdeposit","notyet"); jaddstr(retjson,"KMDdeposit",KMDaddr); @@ -454,15 +461,12 @@ ZERO_ARGS(jumblr,status) step_z2z += ptr->amount; else step_z2t += ptr->amount; } else step_t2z += ptr->amount; - if ( ptr->spent == 0 ) - pending += ptr->amount; } jaddstr(retjson,"result","success"); - jaddnum(retjson,"deposited",dstr(deposited)); + jaddnum(retjson,"deposits",dstr(deposited)); jaddnum(retjson,"t_to_z",dstr(step_t2z)); jaddnum(retjson,"z_to_z",dstr(step_z2z)); jaddnum(retjson,"z_to_t",dstr(step_z2t)); - jaddnum(retjson,"pending",dstr(pending)); jaddnum(retjson,"jumblred",dstr(jumblred)); jaddnum(retjson,"received",dstr(received)); jaddnum(retjson,"finished",dstr(finished)); diff --git a/iguana/main.c b/iguana/main.c index 86742ee04..55ca8824c 100755 --- a/iguana/main.c +++ b/iguana/main.c @@ -757,7 +757,7 @@ void jumblr_loop(void *ptr) 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); - sleep(40); + sleep(55); } } From e04f8891e47407b33ed6cb72139c0cefc1c48927 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 4 Mar 2017 11:37:16 +0200 Subject: [PATCH 24/24] Test --- basilisk/jumblr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/basilisk/jumblr.c b/basilisk/jumblr.c index 739f249c6..ab01e1637 100755 --- a/basilisk/jumblr.c +++ b/basilisk/jumblr.c @@ -174,8 +174,8 @@ int64_t jumblr_balance(struct supernet_info *myinfo,struct iguana_info *coin,cha balance += SATOSHIDEN * jdouble(jitem(retjson,i),"amount"); free_json(retjson); } - if ( balance == 0 ) - printf("listunspent.(%s)\n",addr); + //if ( balance == 0 ) + // printf("listunspent.(%s)\n",addr); free(retstr); } }