From 3d25ac4764202191bf71e1c45a1d76965be84f0e Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 12 Oct 2017 17:36:47 +0300 Subject: [PATCH 01/24] Test --- iguana/exchanges/LP_rpc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_rpc.c b/iguana/exchanges/LP_rpc.c index 8def0e8e3..a0f7a2151 100644 --- a/iguana/exchanges/LP_rpc.c +++ b/iguana/exchanges/LP_rpc.c @@ -255,7 +255,8 @@ cJSON *LP_gettx(char *symbol,bits256 txid) { sprintf(buf,"[\"%s\", 1]",bits256_str(str,txid)); retjson = bitcoin_json(coin,"getrawtransaction",buf); - printf("%s getrawtransaction %s -> %s\n",symbol,buf,jprint(retjson,0)); + if ( jobj(retjson,"vin") == 0 ) + printf("%s getrawtransaction %s -> %s\n",symbol,buf,jprint(retjson,0)); return(retjson); } else From cb6ac53b2f057ded5fa94fdfc45f1ec1750a4783 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 12 Oct 2017 17:46:18 +0300 Subject: [PATCH 02/24] Test --- iguana/exchanges/LP_remember.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index e1754ffb4..2fac6667e 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -771,11 +771,12 @@ int32_t LP_rswap_checktx(struct LP_swap_remember *rswap,char *symbol,int32_t txi if ( rswap->sentflags[txi] == 0 && bits256_nonz(rswap->txids[txi]) != 0 ) { printf("[%s] txbytes.%p Apayment.%s\n",txnames[txi],rswap->txbytes[txi],bits256_str(str,rswap->txids[txi])); - if ( rswap->txbytes[txi] != 0 ) + /*if ( rswap->txbytes[txi] != 0 ) rswap->sentflags[txi] = 1; - else if ( (sentobj= LP_gettx(symbol,rswap->txids[txi])) != 0 ) + else*/ if ( (sentobj= LP_gettx(symbol,rswap->txids[txi])) != 0 ) { rswap->sentflags[txi] = 1; + printf("CHECKTX.(%s)\n",jprint(sentobj,0)); free_json(sentobj); LP_refht_update(symbol,rswap->txids[txi]); return(1); From cdf13ab0721c5f79b27a869021783d998a691c85 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 12 Oct 2017 18:12:04 +0300 Subject: [PATCH 03/24] Test --- iguana/exchanges/LP_remember.c | 46 ++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index 2fac6667e..47907d8c5 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -622,22 +622,30 @@ int32_t LP_rswap_init(struct LP_swap_remember *rswap,uint32_t requestid,uint32_t return(rswap->iambob); } -void LP_refht_update(char *symbol,bits256 txid) +int32_t _LP_refht_update(struct iguana_info *coin,int32_t refht) { - int32_t ht; struct iguana_info *coin; + if ( refht > 0 && (coin->firstrefht == 0 || refht < coin->firstrefht) ) + { + if ( coin->firstscanht == 0 || refht < coin->firstscanht ) + coin->firstscanht = coin->lastscanht = refht; + coin->firstrefht = refht; + return(1); + } + return(0); +} + +int32_t LP_refht_update(char *symbol,bits256 txid) +{ + int32_t refht; struct iguana_info *coin; if ( (coin= LP_coinfind(symbol)) != 0 ) // && coin->electrum == 0 { - if ( (ht= LP_txheight(coin,txid)) > 0 && ht > 0 ) + if ( (refht= LP_txheight(coin,txid)) > 0 && refht > 0 ) { - if ( coin->firstrefht == 0 || ht < coin->firstrefht ) - { - if ( coin->firstscanht == 0 || ht < coin->firstscanht ) - coin->firstscanht = coin->lastscanht = ht; - coin->firstrefht = ht; - char str[65]; printf(">>>>>>>>. 1st refht %s %s <- %d, scan %d %d\n",coin->symbol,bits256_str(str,txid),ht,coin->firstscanht,coin->lastscanht); - } + char str[65]; printf(">>>>>>>>. 1st refht %s %s <- %d, scan %d %d\n",coin->symbol,bits256_str(str,txid),refht,coin->firstscanht,coin->lastscanht); + return(_LP_refht_update(coin,refht)); } } + return(0); } int32_t LP_swap_load(struct LP_swap_remember *rswap) @@ -712,7 +720,6 @@ int32_t LP_swap_load(struct LP_swap_remember *rswap) safecopy(rswap->alicecoin,symbol,sizeof(rswap->alicecoin)); if ( rswap->finishedflag == 0 ) { - LP_refht_update(symbol,txid); if ( (sentobj= LP_gettx(symbol,txid)) == 0 ) { char str2[65]; printf("%s %s ready to broadcast\n",symbol,bits256_str(str2,txid)); @@ -722,6 +729,7 @@ int32_t LP_swap_load(struct LP_swap_remember *rswap) checktxid = jbits256(sentobj,"txid"); if ( bits256_nonz(checktxid) == 0 ) checktxid = jbits256(sentobj,"hash"); + LP_refht_update(symbol,txid); if ( bits256_cmp(checktxid,txid) == 0 ) { //printf(">>>>>> %s txid %s\n",jprint(sentobj,0),bits256_str(str,txid)); @@ -767,20 +775,16 @@ void LP_txbytes_update(char *name,char *symbol,char *txbytes,bits256 *txidp,bits int32_t LP_rswap_checktx(struct LP_swap_remember *rswap,char *symbol,int32_t txi) { - cJSON *sentobj; char str[65]; + struct LP_transaction *tx; struct iguana_info *coin; char str[65]; if ( rswap->sentflags[txi] == 0 && bits256_nonz(rswap->txids[txi]) != 0 ) { - printf("[%s] txbytes.%p Apayment.%s\n",txnames[txi],rswap->txbytes[txi],bits256_str(str,rswap->txids[txi])); - /*if ( rswap->txbytes[txi] != 0 ) - rswap->sentflags[txi] = 1; - else*/ if ( (sentobj= LP_gettx(symbol,rswap->txids[txi])) != 0 ) + coin = LP_coinfind(symbol); + printf("[%s] %s txbytes.%p %s\n",txnames[txi],txnames[txi],rswap->txbytes[txi],bits256_str(str,rswap->txids[txi])); + if ( coin != 0 && (tx= LP_transactionfind(coin,rswap->txids[txi])) != 0 && tx->height > 0 ) { rswap->sentflags[txi] = 1; - printf("CHECKTX.(%s)\n",jprint(sentobj,0)); - free_json(sentobj); - LP_refht_update(symbol,rswap->txids[txi]); - return(1); - } + _LP_refht_update(coin,tx->height); + } else LP_refht_update(symbol,rswap->txids[txi]); } return(0); } From 92652b2da6fcdfbe086a4188392e2f63f6764467 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 12 Oct 2017 18:34:57 +0300 Subject: [PATCH 04/24] Test --- iguana/exchanges/LP_remember.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index 47907d8c5..93df5b907 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -244,7 +244,7 @@ bits256 basilisk_swap_privBn_extract(bits256 *bobrefundp,char *bobcoin,bits256 b return(privBn); } -bits256 basilisk_swap_spendupdate(char *symbol,char *spentaddr,int32_t *sentflags,bits256 *txids,int32_t utxoind,int32_t alicespent,int32_t bobspent,int32_t vout,char *aliceaddr,char *bobaddr) +bits256 basilisk_swap_spendupdate(char *symbol,char *spentaddr,int32_t *sentflags,bits256 *txids,int32_t utxoind,int32_t alicespent,int32_t bobspent,int32_t vout,char *aliceaddr,char *bobaddr,char *Adest,char *dest) { bits256 spendtxid,txid; char destaddr[64],str[65]; struct iguana_info *coin; cJSON *histobj; if ( (coin= LP_coinfind(symbol)) != 0 && coin->electrum != 0 ) @@ -265,14 +265,14 @@ bits256 basilisk_swap_spendupdate(char *symbol,char *spentaddr,int32_t *sentflag { sentflags[utxoind] = 1; printf("utxoind.%d Alice.(%s) Bob.(%s)\n",utxoind,aliceaddr,bobaddr); - if ( aliceaddr != 0 && strcmp(destaddr,aliceaddr) == 0 ) + if ( aliceaddr != 0 && (strcmp(destaddr,aliceaddr) == 0 || strcmp(Adest,destaddr) == 0) ) { printf("ALICE spent.(%s) -> %s\n",bits256_str(str,txid),destaddr); sentflags[alicespent] = 1; sentflags[bobspent] = 0; txids[alicespent] = spendtxid; } - else if ( bobaddr != 0 && strcmp(destaddr,bobaddr) == 0 ) + else if ( bobaddr != 0 && (strcmp(destaddr,bobaddr) == 0 || strcmp(dest,destaddr) == 0) ) { printf("BOB spent.(%s) -> %s\n",bits256_str(str,txid),destaddr); sentflags[bobspent] = 1; @@ -284,13 +284,13 @@ bits256 basilisk_swap_spendupdate(char *symbol,char *spentaddr,int32_t *sentflag printf("OTHER dest spent.(%s) -> %s\n",bits256_str(str,txid),destaddr); if ( aliceaddr != 0 ) { - sentflags[bobspent] = 1; + sentflags[bobspent] = 0; sentflags[alicespent] = 0; txids[bobspent] = spendtxid; } else if ( bobaddr != 0 ) { - sentflags[alicespent] = 1; + sentflags[alicespent] = 0; sentflags[bobspent] = 0; txids[alicespent] = spendtxid; } @@ -840,8 +840,8 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti printf("Bob.%p is null or Alice.%p is null\n",bob,alice); return(cJSON_Parse("{\"error\":\"null bob or alice coin\"}")); } - printf("ALICE 1st refht %s <- %d, scan %d %d\n",alice->symbol,alice->firstrefht,alice->firstscanht,alice->lastscanht); - printf("BOB 1st refht %s <- %d, scan %d %d\n",bob->symbol,bob->firstrefht,bob->firstscanht,bob->lastscanht); + printf("ALICE.(%s) 1st refht %s <- %d, scan %d %d\n",rswap.Adestaddr,alice->symbol,alice->firstrefht,alice->firstscanht,alice->lastscanht); + printf("BOB.(%s) 1st refht %s <- %d, scan %d %d\n",rswap.destaddr,bob->symbol,bob->firstrefht,bob->firstscanht,bob->lastscanht); //printf("iambob.%d finishedflag.%d %s %.8f txfee, %s %.8f txfee\n",rswap.iambob,rswap.finishedflag,rswap.alicecoin,dstr(rswap.Atxfee),rswap.bobcoin,dstr(rswap.Btxfee)); //printf("privAm.(%s) %p/%p\n",bits256_str(str,rswap.privAm),Adest,AAdest); //printf("privBn.(%s) %p/%p\n",bits256_str(str,rswap.privBn),Bdest,ABdest); @@ -855,9 +855,9 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti LP_rswap_checktx(&rswap,rswap.alicecoin,BASILISK_ALICEPAYMENT); LP_rswap_checktx(&rswap,rswap.bobcoin,BASILISK_BOBPAYMENT); LP_rswap_checktx(&rswap,rswap.bobcoin,BASILISK_BOBDEPOSIT); - rswap.paymentspent = basilisk_swap_spendupdate(rswap.bobcoin,rswap.bobpaymentaddr,rswap.sentflags,rswap.txids,BASILISK_BOBPAYMENT,BASILISK_ALICESPEND,BASILISK_BOBRECLAIM,0,Adest,Bdest); - rswap.Apaymentspent = basilisk_swap_spendupdate(rswap.alicecoin,rswap.alicepaymentaddr,rswap.sentflags,rswap.txids,BASILISK_ALICEPAYMENT,BASILISK_ALICERECLAIM,BASILISK_BOBSPEND,0,AAdest,ABdest); - rswap.depositspent = basilisk_swap_spendupdate(rswap.bobcoin,rswap.bobdepositaddr,rswap.sentflags,rswap.txids,BASILISK_BOBDEPOSIT,BASILISK_ALICECLAIM,BASILISK_BOBREFUND,0,Adest,Bdest); + rswap.paymentspent = basilisk_swap_spendupdate(rswap.bobcoin,rswap.bobpaymentaddr,rswap.sentflags,rswap.txids,BASILISK_BOBPAYMENT,BASILISK_ALICESPEND,BASILISK_BOBRECLAIM,0,Adest,Bdest,rswap.Adestaddr,rswap.destaddr); + rswap.Apaymentspent = basilisk_swap_spendupdate(rswap.alicecoin,rswap.alicepaymentaddr,rswap.sentflags,rswap.txids,BASILISK_ALICEPAYMENT,BASILISK_ALICERECLAIM,BASILISK_BOBSPEND,0,AAdest,ABdest,rswap.Adestaddr,rswap.destaddr); + rswap.depositspent = basilisk_swap_spendupdate(rswap.bobcoin,rswap.bobdepositaddr,rswap.sentflags,rswap.txids,BASILISK_BOBDEPOSIT,BASILISK_ALICECLAIM,BASILISK_BOBREFUND,0,Adest,Bdest,rswap.Adestaddr,rswap.destaddr); rswap.finishedflag = basilisk_swap_isfinished(rswap.iambob,rswap.txids,rswap.sentflags,rswap.paymentspent,rswap.Apaymentspent,rswap.depositspent); if ( rswap.iambob == 0 ) { From 5b570d0f95d4ec58f7faff07b61bad8d4ac36dc4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 12 Oct 2017 18:38:48 +0300 Subject: [PATCH 05/24] Test --- iguana/exchanges/LP_utxo.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_utxo.c b/iguana/exchanges/LP_utxo.c index d33889a7b..85f5cd9db 100644 --- a/iguana/exchanges/LP_utxo.c +++ b/iguana/exchanges/LP_utxo.c @@ -671,7 +671,9 @@ int32_t LP_txheight(struct iguana_info *coin,bits256 txid) if ( bits256_nonz(blockhash) != 0 && (blockobj= LP_getblock(coin->symbol,blockhash)) != 0 ) { height = jint(blockobj,"height"); - char str[65]; printf("%s %s LP_txheight.%d\n",coin->symbol,bits256_str(str,txid),height); + char str[65]; + if ( strcmp(coin->symbol,"CHIPS") != 0 && strcmp(coin->symbol,"BTC") != 0 ) + printf("%s %s LP_txheight.%d\n",coin->symbol,bits256_str(str,txid),height); free_json(blockobj); } // else printf("%s LP_txheight error (%s)\n",coin->symbol,jprint(txobj,0)); likely just unconfirmed free_json(txobj); From 94be3c821f346d9851de0e7e64f40c15c352e179 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 12 Oct 2017 18:42:52 +0300 Subject: [PATCH 06/24] Test --- iguana/exchanges/LP_rpc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_rpc.c b/iguana/exchanges/LP_rpc.c index a0f7a2151..611085e48 100644 --- a/iguana/exchanges/LP_rpc.c +++ b/iguana/exchanges/LP_rpc.c @@ -255,8 +255,11 @@ cJSON *LP_gettx(char *symbol,bits256 txid) { sprintf(buf,"[\"%s\", 1]",bits256_str(str,txid)); retjson = bitcoin_json(coin,"getrawtransaction",buf); - if ( jobj(retjson,"vin") == 0 ) + if ( strcmp(coin->symbol,"CHIPS") != 0 && strcmp(coin->symbol,"BTC") != 0 ) + { + //if ( jobj(retjson,"vin") == 0 ) printf("%s getrawtransaction %s -> %s\n",symbol,buf,jprint(retjson,0)); + } return(retjson); } else From e8b82b871eae18216cfe0f3fb247849470bbaabd Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 12 Oct 2017 18:49:28 +0300 Subject: [PATCH 07/24] Test --- iguana/exchanges/LP_rpc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/iguana/exchanges/LP_rpc.c b/iguana/exchanges/LP_rpc.c index 611085e48..2c0d49888 100644 --- a/iguana/exchanges/LP_rpc.c +++ b/iguana/exchanges/LP_rpc.c @@ -133,7 +133,8 @@ cJSON *bitcoin_json(struct iguana_info *coin,char *method,char *params) retstr = bitcoind_passthru(coin->symbol,coin->serverport,coin->userpass,method,params); if ( retstr != 0 && retstr[0] != 0 ) { - //printf("%s: %s.%s -> (%s)\n",coin->symbol,method,params,retstr); + if ( strcmp("KMD",coin->symbol) == 0 ) + printf("%s: %s.%s -> (%s)\n",coin->symbol,method,params,retstr); retjson = cJSON_Parse(retstr); free(retstr); } @@ -255,7 +256,7 @@ cJSON *LP_gettx(char *symbol,bits256 txid) { sprintf(buf,"[\"%s\", 1]",bits256_str(str,txid)); retjson = bitcoin_json(coin,"getrawtransaction",buf); - if ( strcmp(coin->symbol,"CHIPS") != 0 && strcmp(coin->symbol,"BTC") != 0 ) + if ( strcmp(symbol,"CHIPS") != 0 && strcmp(symbol,"BTC") != 0 ) { //if ( jobj(retjson,"vin") == 0 ) printf("%s getrawtransaction %s -> %s\n",symbol,buf,jprint(retjson,0)); From 831733604d1cdd04f7dc863d6d3ea5ebd6c64354 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 12 Oct 2017 19:04:53 +0300 Subject: [PATCH 08/24] Test --- iguana/exchanges/LP_rpc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iguana/exchanges/LP_rpc.c b/iguana/exchanges/LP_rpc.c index 2c0d49888..08aec9037 100644 --- a/iguana/exchanges/LP_rpc.c +++ b/iguana/exchanges/LP_rpc.c @@ -131,10 +131,10 @@ cJSON *bitcoin_json(struct iguana_info *coin,char *method,char *params) if ( coin->electrum == 0 ) { retstr = bitcoind_passthru(coin->symbol,coin->serverport,coin->userpass,method,params); + if ( strcmp("KMD",coin->symbol) == 0 ) + printf("%s: %s.%s -> (%s)\n",coin->symbol,method,params,retstr); if ( retstr != 0 && retstr[0] != 0 ) { - if ( strcmp("KMD",coin->symbol) == 0 ) - printf("%s: %s.%s -> (%s)\n",coin->symbol,method,params,retstr); retjson = cJSON_Parse(retstr); free(retstr); } From 6b3d37be0a785945be427fe5ef0d63ab717c4fa5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 12 Oct 2017 19:08:15 +0300 Subject: [PATCH 09/24] Test --- iguana/exchanges/LP_rpc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_rpc.c b/iguana/exchanges/LP_rpc.c index 08aec9037..b2c7cf73c 100644 --- a/iguana/exchanges/LP_rpc.c +++ b/iguana/exchanges/LP_rpc.c @@ -132,7 +132,7 @@ cJSON *bitcoin_json(struct iguana_info *coin,char *method,char *params) { retstr = bitcoind_passthru(coin->symbol,coin->serverport,coin->userpass,method,params); if ( strcmp("KMD",coin->symbol) == 0 ) - printf("%s: %s.%s -> (%s)\n",coin->symbol,method,params,retstr); + printf("%s.(%s %s): %s.%s -> (%s)\n",coin->symbol,coin->serverport,coin->userpass,method,params,retstr); if ( retstr != 0 && retstr[0] != 0 ) { retjson = cJSON_Parse(retstr); From 5cc219e5d4d05825ee2898d94caadb2e028cec45 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 12 Oct 2017 19:20:01 +0300 Subject: [PATCH 10/24] Test --- iguana/exchanges/LP_coins.c | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/iguana/exchanges/LP_coins.c b/iguana/exchanges/LP_coins.c index 627cbbe2a..079575fe3 100644 --- a/iguana/exchanges/LP_coins.c +++ b/iguana/exchanges/LP_coins.c @@ -54,9 +54,9 @@ char *parse_conf_line(char *line,char *field) return(clonestr(line)); } -void LP_userpassfp(char *symbol,char *username,char *password,FILE *fp) +uint16_t LP_userpassfp(char *symbol,char *username,char *password,FILE *fp) { - char *rpcuser,*rpcpassword,*str,line[8192]; + char *rpcuser,*rpcpassword,*str,line[8192]; uint16_t port = 0; rpcuser = rpcpassword = 0; username[0] = password[0] = 0; while ( fgets(line,sizeof(line),fp) != 0 ) @@ -68,6 +68,16 @@ void LP_userpassfp(char *symbol,char *username,char *password,FILE *fp) rpcuser = parse_conf_line(str,(char *)"rpcuser"); else if ( (str= strstr(line,(char *)"rpcpassword")) != 0 ) rpcpassword = parse_conf_line(str,(char *)"rpcpassword"); + else if ( (str= strstr(line,(char *)"rpcport")) != 0 ) + { + str = parse_conf_line(str,(char *)"rpcport"); + if ( str != 0 ) + { + port = atoi(str); + printf("RPCPORT.%u\n",port); + free(str); + } + } } if ( rpcuser != 0 && rpcpassword != 0 ) { @@ -79,6 +89,7 @@ void LP_userpassfp(char *symbol,char *username,char *password,FILE *fp) free(rpcuser); if ( rpcpassword != 0 ) free(rpcpassword); + return(port); } void LP_statefname(char *fname,char *symbol,char *assetname,char *str,char *name,char *confpath) @@ -143,9 +154,9 @@ void LP_statefname(char *fname,char *symbol,char *assetname,char *str,char *name strcat(fname,str); } -int32_t LP_userpass(char *userpass,char *symbol,char *assetname,char *confroot,char *name,char *confpath) +uint16_t LP_userpass(char *userpass,char *symbol,char *assetname,char *confroot,char *name,char *confpath,uint16_t origport) { - FILE *fp; char fname[512],username[512],password[512],confname[512]; + FILE *fp; char fname[512],username[512],password[512],confname[512]; uint16_t port = 0; userpass[0] = 0; sprintf(confname,"%s.conf",confroot); if ( 0 ) @@ -160,14 +171,15 @@ int32_t LP_userpass(char *userpass,char *symbol,char *assetname,char *confroot,c LP_statefname(fname,symbol,assetname,confname,name,confpath); if ( (fp= fopen(fname,"rb")) != 0 ) { - LP_userpassfp(symbol,username,password,fp); + if ( (port= LP_userpassfp(symbol,username,password,fp)) == 0 ) + port = origport; sprintf(userpass,"%s:%s",username,password); fclose(fp); if ( 0 ) printf("LP_statefname.(%s) <- %s %s %s (%s) (%s)\n",fname,name,symbol,assetname,userpass,confpath); - return((int32_t)strlen(userpass)); + return(port); } else printf("cant open.(%s)\n",fname); - return(-1); + return(0); } cJSON *LP_coinjson(struct iguana_info *coin,int32_t showwif) @@ -269,7 +281,7 @@ struct iguana_info *LP_coinadd(struct iguana_info *cdata) return(coin); } -int32_t LP_coininit(struct iguana_info *coin,char *symbol,char *name,char *assetname,int32_t isPoS,uint16_t port,uint8_t pubtype,uint8_t p2shtype,uint8_t wiftype,uint64_t txfee,double estimatedrate,int32_t longestchain,uint8_t wiftaddr,uint8_t taddr,uint16_t busport,char *confpath) +uint16_t LP_coininit(struct iguana_info *coin,char *symbol,char *name,char *assetname,int32_t isPoS,uint16_t port,uint8_t pubtype,uint8_t p2shtype,uint8_t wiftype,uint64_t txfee,double estimatedrate,int32_t longestchain,uint8_t wiftaddr,uint8_t taddr,uint16_t busport,char *confpath) { char *name2; memset(coin,0,sizeof(*coin)); @@ -296,7 +308,7 @@ int32_t LP_coininit(struct iguana_info *coin,char *symbol,char *name,char *asset coin->noimportprivkey_flag = 1; printf("truncate importprivkey for %s\n",symbol); } - return(LP_userpass(coin->userpass,symbol,assetname,name,name2,confpath)); + return(LP_userpass(coin->userpass,symbol,assetname,name,name2,confpath,port)); } int32_t LP_isdisabled(char *base,char *rel) @@ -339,7 +351,10 @@ struct iguana_info *LP_coinfind(char *symbol) else if ( strcmp(symbol,"KMD") == 0 ) name = "komodo"; else return(0); - isinactive = LP_coininit(&cdata,symbol,name,assetname,isPoS,port,pubtype,p2shtype,wiftype,txfee,estimatedrate,longestchain,0,0,busport,0) < 0; + port = LP_coininit(&cdata,symbol,name,assetname,isPoS,port,pubtype,p2shtype,wiftype,txfee,estimatedrate,longestchain,0,0,busport,0); + if ( port == 0 ) + isinactive = 1; + else isinactive = 0; if ( (coin= LP_coinadd(&cdata)) != 0 ) { coin->inactive = isinactive * (uint32_t)time(NULL); From 01811ccbb2f0b438efd8d41e25c45671a21719c8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 12 Oct 2017 19:23:17 +0300 Subject: [PATCH 11/24] Test --- iguana/exchanges/LP_coins.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/iguana/exchanges/LP_coins.c b/iguana/exchanges/LP_coins.c index 079575fe3..7cebd164f 100644 --- a/iguana/exchanges/LP_coins.c +++ b/iguana/exchanges/LP_coins.c @@ -286,7 +286,6 @@ uint16_t LP_coininit(struct iguana_info *coin,char *symbol,char *name,char *asse char *name2; memset(coin,0,sizeof(*coin)); safecopy(coin->symbol,symbol,sizeof(coin->symbol)); - sprintf(coin->serverport,"127.0.0.1:%u",port); coin->updaterate = (uint32_t)time(NULL); coin->isPoS = isPoS; coin->taddr = taddr; @@ -308,7 +307,9 @@ uint16_t LP_coininit(struct iguana_info *coin,char *symbol,char *name,char *asse coin->noimportprivkey_flag = 1; printf("truncate importprivkey for %s\n",symbol); } - return(LP_userpass(coin->userpass,symbol,assetname,name,name2,confpath,port)); + port = LP_userpass(coin->userpass,symbol,assetname,name,name2,confpath,port); + sprintf(coin->serverport,"127.0.0.1:%u",port); + return(port); } int32_t LP_isdisabled(char *base,char *rel) From 45bd5e6e709ea68d23c17f5eed86a814b7aea981 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 12 Oct 2017 19:27:34 +0300 Subject: [PATCH 12/24] Test --- iguana/exchanges/LP_coins.c | 2 +- iguana/exchanges/LP_rpc.c | 7 +------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/iguana/exchanges/LP_coins.c b/iguana/exchanges/LP_coins.c index 7cebd164f..224e3a435 100644 --- a/iguana/exchanges/LP_coins.c +++ b/iguana/exchanges/LP_coins.c @@ -74,7 +74,7 @@ uint16_t LP_userpassfp(char *symbol,char *username,char *password,FILE *fp) if ( str != 0 ) { port = atoi(str); - printf("RPCPORT.%u\n",port); + //printf("RPCPORT.%u\n",port); free(str); } } diff --git a/iguana/exchanges/LP_rpc.c b/iguana/exchanges/LP_rpc.c index b2c7cf73c..aa6296325 100644 --- a/iguana/exchanges/LP_rpc.c +++ b/iguana/exchanges/LP_rpc.c @@ -131,7 +131,7 @@ cJSON *bitcoin_json(struct iguana_info *coin,char *method,char *params) if ( coin->electrum == 0 ) { retstr = bitcoind_passthru(coin->symbol,coin->serverport,coin->userpass,method,params); - if ( strcmp("KMD",coin->symbol) == 0 ) + if ( 0 && strcmp("KMD",coin->symbol) == 0 ) printf("%s.(%s %s): %s.%s -> (%s)\n",coin->symbol,coin->serverport,coin->userpass,method,params,retstr); if ( retstr != 0 && retstr[0] != 0 ) { @@ -256,11 +256,6 @@ cJSON *LP_gettx(char *symbol,bits256 txid) { sprintf(buf,"[\"%s\", 1]",bits256_str(str,txid)); retjson = bitcoin_json(coin,"getrawtransaction",buf); - if ( strcmp(symbol,"CHIPS") != 0 && strcmp(symbol,"BTC") != 0 ) - { - //if ( jobj(retjson,"vin") == 0 ) - printf("%s getrawtransaction %s -> %s\n",symbol,buf,jprint(retjson,0)); - } return(retjson); } else From 7098200f6a6faed20a3ecd8ff5b48ea0d84ed26e Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 12 Oct 2017 19:42:38 +0300 Subject: [PATCH 13/24] Test --- iguana/exchanges/LP_remember.c | 12 +++++------- iguana/exchanges/LP_utxo.c | 6 +++--- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index 93df5b907..edaeb1701 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -622,10 +622,11 @@ int32_t LP_rswap_init(struct LP_swap_remember *rswap,uint32_t requestid,uint32_t return(rswap->iambob); } -int32_t _LP_refht_update(struct iguana_info *coin,int32_t refht) +int32_t _LP_refht_update(struct iguana_info *coin,bits256 txid,int32_t refht) { if ( refht > 0 && (coin->firstrefht == 0 || refht < coin->firstrefht) ) { + char str[65]; printf(">>>>>>>>. 1st refht %s %s <- %d, scan %d %d\n",coin->symbol,bits256_str(str,txid),refht,coin->firstscanht,coin->lastscanht); if ( coin->firstscanht == 0 || refht < coin->firstscanht ) coin->firstscanht = coin->lastscanht = refht; coin->firstrefht = refht; @@ -637,13 +638,10 @@ int32_t _LP_refht_update(struct iguana_info *coin,int32_t refht) int32_t LP_refht_update(char *symbol,bits256 txid) { int32_t refht; struct iguana_info *coin; - if ( (coin= LP_coinfind(symbol)) != 0 ) // && coin->electrum == 0 + if ( (coin= LP_coinfind(symbol)) != 0 && coin->electrum == 0 ) { if ( (refht= LP_txheight(coin,txid)) > 0 && refht > 0 ) - { - char str[65]; printf(">>>>>>>>. 1st refht %s %s <- %d, scan %d %d\n",coin->symbol,bits256_str(str,txid),refht,coin->firstscanht,coin->lastscanht); - return(_LP_refht_update(coin,refht)); - } + return(_LP_refht_update(coin,txid,refht)); } return(0); } @@ -783,7 +781,7 @@ int32_t LP_rswap_checktx(struct LP_swap_remember *rswap,char *symbol,int32_t txi if ( coin != 0 && (tx= LP_transactionfind(coin,rswap->txids[txi])) != 0 && tx->height > 0 ) { rswap->sentflags[txi] = 1; - _LP_refht_update(coin,tx->height); + _LP_refht_update(coin,rswap->txids[txi],tx->height); } else LP_refht_update(symbol,rswap->txids[txi]); } return(0); diff --git a/iguana/exchanges/LP_utxo.c b/iguana/exchanges/LP_utxo.c index 85f5cd9db..8fa11b1ab 100644 --- a/iguana/exchanges/LP_utxo.c +++ b/iguana/exchanges/LP_utxo.c @@ -671,9 +671,9 @@ int32_t LP_txheight(struct iguana_info *coin,bits256 txid) if ( bits256_nonz(blockhash) != 0 && (blockobj= LP_getblock(coin->symbol,blockhash)) != 0 ) { height = jint(blockobj,"height"); - char str[65]; - if ( strcmp(coin->symbol,"CHIPS") != 0 && strcmp(coin->symbol,"BTC") != 0 ) - printf("%s %s LP_txheight.%d\n",coin->symbol,bits256_str(str,txid),height); + //char str[65]; + //if ( strcmp(coin->symbol,"CHIPS") != 0 && strcmp(coin->symbol,"BTC") != 0 ) + // printf("%s %s LP_txheight.%d\n",coin->symbol,bits256_str(str,txid),height); free_json(blockobj); } // else printf("%s LP_txheight error (%s)\n",coin->symbol,jprint(txobj,0)); likely just unconfirmed free_json(txobj); From dd7e1e756ebba1c6fb7e91d946ba3bdb92b12a19 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 12 Oct 2017 20:12:27 +0300 Subject: [PATCH 14/24] Test --- iguana/exchanges/LP_nativeDEX.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/iguana/exchanges/LP_nativeDEX.c b/iguana/exchanges/LP_nativeDEX.c index 981a65e20..813d0e20f 100644 --- a/iguana/exchanges/LP_nativeDEX.c +++ b/iguana/exchanges/LP_nativeDEX.c @@ -416,7 +416,7 @@ int32_t LP_utxos_sync(struct LP_peerinfo *peer) int32_t LP_mainloop_iter(void *ctx,char *myipaddr,struct LP_peerinfo *mypeer,int32_t pubsock,char *pushaddr,uint16_t myport) { static uint32_t counter,numpeers; - struct iguana_info *coin,*ctmp; char *retstr,*origipaddr; struct LP_peerinfo *peer,*tmp; uint32_t now; bits256 zero; int32_t needpings,height,nonz = 0; + struct iguana_info *coin,*ctmp; char *retstr,*origipaddr; struct LP_peerinfo *peer,*tmp; uint32_t now; bits256 zero; int32_t needpings,j,height,nonz = 0; now = (uint32_t)time(NULL); if ( (origipaddr= myipaddr) == 0 ) origipaddr = "127.0.0.1"; @@ -511,12 +511,17 @@ int32_t LP_mainloop_iter(void *ctx,char *myipaddr,struct LP_peerinfo *mypeer,int } if ( (coin->lastscanht % 1000) == 0 ) printf("%s ref.%d scan.%d to %d, longest.%d\n",coin->symbol,coin->firstrefht,coin->firstscanht,coin->lastscanht,coin->longestchain); - if ( LP_blockinit(coin,coin->lastscanht) < 0 ) + for (j=0; j<100; j++) { - printf("blockinit.%s %d error\n",coin->symbol,coin->lastscanht); - continue; + if ( LP_blockinit(coin,coin->lastscanht) < 0 ) + { + printf("blockinit.%s %d error\n",coin->symbol,coin->lastscanht); + break; + } + coin->lastscanht++; } - coin->lastscanht++; + if ( j < 100 ) + continue; //LP_getestimatedrate(coin); break; } From b1ea59a6bff205eeb8101f97a4169eb7fdc8d406 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 12 Oct 2017 20:49:30 +0300 Subject: [PATCH 15/24] Skip coins without rpc access --- iguana/exchanges/LP_utxos.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_utxos.c b/iguana/exchanges/LP_utxos.c index 9a67d2cda..7dab46c3b 100644 --- a/iguana/exchanges/LP_utxos.c +++ b/iguana/exchanges/LP_utxos.c @@ -742,7 +742,7 @@ bits256 LP_privkeycalc(void *ctx,uint8_t *pubkey33,bits256 *pubkeyp,struct iguan userpub = curve25519(userpass,curve25519_basepoint9()); printf("userpass.(%s)\n",bits256_str(G.USERPASS,userpub)); } - if ( coin->electrum == 0 ) + if ( coin->electrum == 0 && coin->userpass[0] != 0 ) { LP_listunspent_issue(coin->symbol,coin->smartaddr); if ( (retjson= LP_importprivkey(coin->symbol,tmpstr,coin->smartaddr,-1)) != 0 ) From 70e327ac99506ddec424f52de901ffdafa3c91cf Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 12 Oct 2017 21:20:23 +0300 Subject: [PATCH 16/24] Test --- iguana/exchanges/LP_include.h | 2 +- iguana/exchanges/LP_remember.c | 19 ++++++++++++++++--- iguana/exchanges/LP_swap.c | 11 +++++++++-- iguana/exchanges/LP_utxos.c | 2 +- 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/iguana/exchanges/LP_include.h b/iguana/exchanges/LP_include.h index d1a85727e..5faed5c43 100644 --- a/iguana/exchanges/LP_include.h +++ b/iguana/exchanges/LP_include.h @@ -269,7 +269,7 @@ struct basilisk_swap struct basilisk_swapmessage *messages; int32_t nummessages,sentflag; char Bdeposit[64],Bpayment[64]; uint64_t otherdeck[INSTANTDEX_DECKSIZE][2],deck[INSTANTDEX_DECKSIZE][2]; - uint8_t persistent_pubkey33[33],changermd160[20],pad[15],verifybuf[100000]; + uint8_t persistent_pubkey33[33],persistent_other33[33],changermd160[20],pad[15],verifybuf[100000]; }; diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index edaeb1701..c50a47853 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -152,7 +152,10 @@ void basilisk_dontforget(struct basilisk_swap *swap,struct basilisk_rawtx *rawtx fprintf(fp,",\"otherfee\":\"%s\"",bits256_str(str,swap->otherfee.I.actualtxid)); if ( bits256_nonz(swap->myfee.I.actualtxid) != 0 ) fprintf(fp,",\"myfee\":\"%s\"",bits256_str(str,swap->myfee.I.actualtxid)); - fprintf(fp,",\"dest33\":\""); + fprintf(fp,",\"other33\":\""); + for (i=0; i<33; i++) + fprintf(fp,"%02x",swap->persistent_other33[i]); + fprintf(fp,"\",\"dest33\":\""); for (i=0; i<33; i++) fprintf(fp,"%02x",swap->persistent_pubkey33[i]); fprintf(fp,"\"}\n"); @@ -463,7 +466,7 @@ struct LP_swap_remember uint64_t Atxfee,Btxfee,srcamount,destamount; int64_t values[sizeof(txnames)/sizeof(*txnames)]; uint32_t requestid,quoteid,plocktime,dlocktime,expiration,state,otherstate; int32_t iambob,finishedflag,origfinishedflag,Predeemlen,Dredeemlen,sentflags[sizeof(txnames)/sizeof(*txnames)]; - uint8_t secretAm[20],secretAm256[32],secretBn[20],secretBn256[32],pubkey33[33],Predeemscript[1024],Dredeemscript[1024]; + uint8_t secretAm[20],secretAm256[32],secretBn[20],secretBn256[32],Predeemscript[1024],Dredeemscript[1024],pubkey33[33],other33[33]; char src[64],dest[64],destaddr[64],Adestaddr[64],alicepaymentaddr[64],bobpaymentaddr[64],bobdepositaddr[64],alicecoin[64],bobcoin[64],*txbytes[sizeof(txnames)/sizeof(*txnames)]; }; @@ -508,7 +511,7 @@ cJSON *LP_swap_json(struct LP_swap_remember *rswap) int32_t LP_rswap_init(struct LP_swap_remember *rswap,uint32_t requestid,uint32_t quoteid) { - char fname[1024],*fstr,*secretstr,*srcstr,*deststr,*dest33,*txname; long fsize; cJSON *item,*txobj,*array; bits256 privkey; uint32_t r,q; int32_t i,j,n; + char fname[1024],*fstr,*secretstr,*srcstr,*deststr,*dest33,*txname; long fsize; cJSON *item,*txobj,*array; bits256 privkey; uint32_t r,q; int32_t i,j,n; uint8_t other33[33]; memset(rswap,0,sizeof(*rswap)); rswap->requestid = requestid; rswap->quoteid = quoteid; @@ -537,6 +540,16 @@ int32_t LP_rswap_init(struct LP_swap_remember *rswap,uint32_t requestid,uint32_t // printf("%02x",pubkey33[i]); //printf(" <- %s dest33\n",dest33); } + if ( (dest33= jstr(item,"other33")) != 0 && strlen(dest33) == 66 ) + { + decode_hex(other33,33,dest33); + for (i=0; i<33; i++) + if ( other33[i] != 0 ) + break; + if ( i < 33 ) + memcpy(rswap->other33,other33,33); + //printf(" <- %s dest33\n",dest33); + } if ( (rswap->plocktime= juint(item,"plocktime")) == 0 ) rswap->plocktime = LP_extract(requestid,quoteid,fname,"plocktime"); if ( (rswap->dlocktime= juint(item,"dlocktime")) == 0 ) diff --git a/iguana/exchanges/LP_swap.c b/iguana/exchanges/LP_swap.c index 22bf882aa..79a495c59 100644 --- a/iguana/exchanges/LP_swap.c +++ b/iguana/exchanges/LP_swap.c @@ -177,6 +177,8 @@ uint32_t basilisk_requestid(struct basilisk_request *rp) int32_t LP_pubkeys_data(struct basilisk_swap *swap,uint8_t *data,int32_t maxlen) { int32_t i,datalen = 0; + for (i=0; i<33; i++) + data[datalen++] = swap->persistent_pubkey33[i]; for (i=0; ideck)/sizeof(swap->deck[0][0]); i++) datalen += iguana_rwnum(1,&data[datalen],sizeof(swap->deck[i>>1][i&1]),&swap->deck[i>>1][i&1]); return(datalen); @@ -184,9 +186,14 @@ int32_t LP_pubkeys_data(struct basilisk_swap *swap,uint8_t *data,int32_t maxlen) int32_t LP_pubkeys_verify(struct basilisk_swap *swap,uint8_t *data,int32_t datalen) { - int32_t i,len = 0; - if ( datalen == sizeof(swap->otherdeck) ) + int32_t i,nonz=0,len = 0; uint8_t other33[33]; + if ( datalen == sizeof(swap->otherdeck)+33 ) { + for (i=0; i<33; i++) + if ( (other33[i]= data[len++]) != 0 ) + nonz++; + if ( nonz > 8 ) + memcpy(swap->persistent_other33,other33,33); for (i=0; iotherdeck)/sizeof(swap->otherdeck[0][0]); i++) len += iguana_rwnum(0,&data[len],sizeof(swap->otherdeck[i>>1][i&1]),&swap->otherdeck[i>>1][i&1]); return(0); diff --git a/iguana/exchanges/LP_utxos.c b/iguana/exchanges/LP_utxos.c index 7dab46c3b..fadd1b6de 100644 --- a/iguana/exchanges/LP_utxos.c +++ b/iguana/exchanges/LP_utxos.c @@ -355,7 +355,7 @@ struct LP_utxoinfo *LP_utxoadd(int32_t iambob,char *symbol,bits256 txid,int32_t val2 = value2; } dispflag = 0; - if ( dispflag != 0 ) + //if ( dispflag != 0 ) printf("%.8f %.8f %s iambob.%d %s utxoadd.(%.8f %.8f) %s %s\n",dstr(val),dstr(val2),coinaddr,iambob,symbol,dstr(value),dstr(value2),bits256_str(str,txid),bits256_str(str2,txid2)); dispflag = 1; if ( (utxo= LP_utxofinds(iambob,txid,vout,txid2,vout2)) != 0 ) From 38440265eed9f38cf27d64db9b05da6dc0822eb8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 12 Oct 2017 21:32:07 +0300 Subject: [PATCH 17/24] Test --- iguana/exchanges/LP_utxos.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_utxos.c b/iguana/exchanges/LP_utxos.c index fadd1b6de..a69890fc6 100644 --- a/iguana/exchanges/LP_utxos.c +++ b/iguana/exchanges/LP_utxos.c @@ -726,7 +726,7 @@ bits256 LP_privkeycalc(void *ctx,uint8_t *pubkey33,bits256 *pubkeyp,struct iguan bitcoin_priv2wif(coin->wiftaddr,tmpstr,privkey,coin->wiftype); bitcoin_addr2rmd160(coin->taddr,&tmptype,G.LP_myrmd160,coin->smartaddr); LP_privkeyadd(privkey,G.LP_myrmd160); - if ( 0 && (coin->pubtype != 60 || strcmp(coin->symbol,"KMD") == 0) ) + if ( 1 && (coin->pubtype != 60 || strcmp(coin->symbol,"KMD") == 0) ) printf("%s (%s) %d wif.(%s) (%s)\n",coin->symbol,coin->smartaddr,coin->pubtype,tmpstr,passphrase); if ( G.counter++ == 0 ) { From 0057e22289cf3af7414365d17d01190987f1c1ad Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 12 Oct 2017 21:37:07 +0300 Subject: [PATCH 18/24] Test --- iguana/exchanges/LP_utxos.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_utxos.c b/iguana/exchanges/LP_utxos.c index a69890fc6..fadd1b6de 100644 --- a/iguana/exchanges/LP_utxos.c +++ b/iguana/exchanges/LP_utxos.c @@ -726,7 +726,7 @@ bits256 LP_privkeycalc(void *ctx,uint8_t *pubkey33,bits256 *pubkeyp,struct iguan bitcoin_priv2wif(coin->wiftaddr,tmpstr,privkey,coin->wiftype); bitcoin_addr2rmd160(coin->taddr,&tmptype,G.LP_myrmd160,coin->smartaddr); LP_privkeyadd(privkey,G.LP_myrmd160); - if ( 1 && (coin->pubtype != 60 || strcmp(coin->symbol,"KMD") == 0) ) + if ( 0 && (coin->pubtype != 60 || strcmp(coin->symbol,"KMD") == 0) ) printf("%s (%s) %d wif.(%s) (%s)\n",coin->symbol,coin->smartaddr,coin->pubtype,tmpstr,passphrase); if ( G.counter++ == 0 ) { From c93cdc8f0204fb4fa27f8362511d23a355012bc9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 12 Oct 2017 21:45:51 +0300 Subject: [PATCH 19/24] Test --- iguana/exchanges/LP_utxos.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_utxos.c b/iguana/exchanges/LP_utxos.c index fadd1b6de..a69890fc6 100644 --- a/iguana/exchanges/LP_utxos.c +++ b/iguana/exchanges/LP_utxos.c @@ -726,7 +726,7 @@ bits256 LP_privkeycalc(void *ctx,uint8_t *pubkey33,bits256 *pubkeyp,struct iguan bitcoin_priv2wif(coin->wiftaddr,tmpstr,privkey,coin->wiftype); bitcoin_addr2rmd160(coin->taddr,&tmptype,G.LP_myrmd160,coin->smartaddr); LP_privkeyadd(privkey,G.LP_myrmd160); - if ( 0 && (coin->pubtype != 60 || strcmp(coin->symbol,"KMD") == 0) ) + if ( 1 && (coin->pubtype != 60 || strcmp(coin->symbol,"KMD") == 0) ) printf("%s (%s) %d wif.(%s) (%s)\n",coin->symbol,coin->smartaddr,coin->pubtype,tmpstr,passphrase); if ( G.counter++ == 0 ) { From 56c23183544f2c785458d33c6d2d2c0bbf4bc140 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 12 Oct 2017 21:46:02 +0300 Subject: [PATCH 20/24] Test --- iguana/exchanges/LP_utxos.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_utxos.c b/iguana/exchanges/LP_utxos.c index a69890fc6..fadd1b6de 100644 --- a/iguana/exchanges/LP_utxos.c +++ b/iguana/exchanges/LP_utxos.c @@ -726,7 +726,7 @@ bits256 LP_privkeycalc(void *ctx,uint8_t *pubkey33,bits256 *pubkeyp,struct iguan bitcoin_priv2wif(coin->wiftaddr,tmpstr,privkey,coin->wiftype); bitcoin_addr2rmd160(coin->taddr,&tmptype,G.LP_myrmd160,coin->smartaddr); LP_privkeyadd(privkey,G.LP_myrmd160); - if ( 1 && (coin->pubtype != 60 || strcmp(coin->symbol,"KMD") == 0) ) + if ( 0 && (coin->pubtype != 60 || strcmp(coin->symbol,"KMD") == 0) ) printf("%s (%s) %d wif.(%s) (%s)\n",coin->symbol,coin->smartaddr,coin->pubtype,tmpstr,passphrase); if ( G.counter++ == 0 ) { From 37ae216909ee6e1e78547f5e19d8a28ddbdbc90e Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 12 Oct 2017 22:30:15 +0300 Subject: [PATCH 21/24] Test --- iguana/exchanges/LP_commands.c | 11 +++++++++-- iguana/exchanges/LP_utxo.c | 2 -- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/iguana/exchanges/LP_commands.c b/iguana/exchanges/LP_commands.c index ecf6de1a7..ec5a4eda7 100644 --- a/iguana/exchanges/LP_commands.c +++ b/iguana/exchanges/LP_commands.c @@ -372,8 +372,15 @@ dividends(coin, height, )\n\ else if ( strcmp(method,"listunspent") == 0 ) { if ( (ptr= LP_coinsearch(jstr(argjson,"coin"))) != 0 ) - return(jprint(LP_address_utxos(ptr,jstr(argjson,"address"),1),1)); - else return(clonestr("{\"error\":\"cant find coind\"}")); + { + char *coinaddr; + if ( (coinaddr= jstr(argjson,"address")) != 0 ) + { + if ( strcmp(coinaddr,ptr->smartaddr) == 0 && bits256_nonz(G.LP_mypriv25519) != 0 ) + LP_privkey_init(-1,ptr,G.LP_mypriv25519,G.LP_mypub25519); + return(jprint(LP_address_utxos(ptr,coinaddr,1),1)); + } else return(clonestr("{\"error\":\"no address specified\"}")); + } else return(clonestr("{\"error\":\"cant find coind\"}")); } else if ( strcmp(method,"balance") == 0 ) { diff --git a/iguana/exchanges/LP_utxo.c b/iguana/exchanges/LP_utxo.c index 8fa11b1ab..3572f7551 100644 --- a/iguana/exchanges/LP_utxo.c +++ b/iguana/exchanges/LP_utxo.c @@ -433,8 +433,6 @@ int32_t LP_unspents_array(struct iguana_info *coin,char *coinaddr,cJSON *array) v = jint(item,"tx_pos"); height = jint(item,"height"); val = j64bits(item,"value"); - //if ( strcmp(coin->symbol,"LBC") == 0 ) - // printf("(%s)\n",jprint(item,0)); if ( coin->electrum == 0 && (txobj= LP_gettxout(coin->symbol,coinaddr,txid,v)) != 0 ) { value = LP_value_extract(txobj,0); From 4fb9f0038c36a528aaabdb4987003a4b09ab2974 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 12 Oct 2017 22:46:53 +0300 Subject: [PATCH 22/24] Test --- iguana/exchanges/LP_utxo.c | 1 + 1 file changed, 1 insertion(+) diff --git a/iguana/exchanges/LP_utxo.c b/iguana/exchanges/LP_utxo.c index 3572f7551..d9ad2b012 100644 --- a/iguana/exchanges/LP_utxo.c +++ b/iguana/exchanges/LP_utxo.c @@ -157,6 +157,7 @@ int32_t LP_address_utxo_ptrs(int32_t iambob,struct LP_address_utxo **utxos,int32 portable_mutex_lock(&LP_utxomutex); DL_FOREACH_SAFE(ap->utxos,up,tmp) { + char str[65]; printf("LP_address_utxo_ptrs %s n.%d %.8f %s v%d\n",ap->coinaddr,n,dstr(up->U.value),bits256_str(str,up->U.txid),up->U.vout); if ( up->spendheight <= 0 ) { if ( LP_allocated(up->U.txid,up->U.vout) == 0 ) From 6c5fac6cf66a92a436133edbed1d792f642b2f40 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 12 Oct 2017 22:55:15 +0300 Subject: [PATCH 23/24] Test --- iguana/exchanges/LP_utxos.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_utxos.c b/iguana/exchanges/LP_utxos.c index fadd1b6de..7dab46c3b 100644 --- a/iguana/exchanges/LP_utxos.c +++ b/iguana/exchanges/LP_utxos.c @@ -355,7 +355,7 @@ struct LP_utxoinfo *LP_utxoadd(int32_t iambob,char *symbol,bits256 txid,int32_t val2 = value2; } dispflag = 0; - //if ( dispflag != 0 ) + if ( dispflag != 0 ) printf("%.8f %.8f %s iambob.%d %s utxoadd.(%.8f %.8f) %s %s\n",dstr(val),dstr(val2),coinaddr,iambob,symbol,dstr(value),dstr(value2),bits256_str(str,txid),bits256_str(str2,txid2)); dispflag = 1; if ( (utxo= LP_utxofinds(iambob,txid,vout,txid2,vout2)) != 0 ) From 933b24d687a3c7cb014e1e0d8bca703797909de9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 12 Oct 2017 22:59:36 +0300 Subject: [PATCH 24/24] Test --- iguana/exchanges/LP_nativeDEX.c | 1 + 1 file changed, 1 insertion(+) diff --git a/iguana/exchanges/LP_nativeDEX.c b/iguana/exchanges/LP_nativeDEX.c index 813d0e20f..694901cf4 100644 --- a/iguana/exchanges/LP_nativeDEX.c +++ b/iguana/exchanges/LP_nativeDEX.c @@ -450,6 +450,7 @@ int32_t LP_mainloop_iter(void *ctx,char *myipaddr,struct LP_peerinfo *mypeer,int if ( peer->diduquery == 0 ) { LP_peer_pricesquery(peer); + LP_utxos_sync(peer); peer->diduquery = now; } if ( peer->needping != 0 )