From 8cd733469a00f60536503170226d702248be25d6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 8 Nov 2017 02:14:39 +0200 Subject: [PATCH 1/3] Test --- iguana/exchanges/LP_commands.c | 4 +++- iguana/exchanges/LP_utxo.c | 12 +++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/iguana/exchanges/LP_commands.c b/iguana/exchanges/LP_commands.c index af12cb1c2..7de090f22 100644 --- a/iguana/exchanges/LP_commands.c +++ b/iguana/exchanges/LP_commands.c @@ -557,7 +557,9 @@ bot_resume(botid)\n\ //printf("network invoked\n"); LP_privkey_init(-1,ptr,G.LP_privkey,G.LP_mypub25519); //LP_smartutxos_push(ptr); - return(jprint(LP_address_utxos(ptr,coinaddr,1),1)); + if ( ptr->electrum != 0 ) + return(LP_unspents_filestr(coin,ptr->smartaddr)); + else return(jprint(LP_address_utxos(ptr,coinaddr,1),1)); } else { diff --git a/iguana/exchanges/LP_utxo.c b/iguana/exchanges/LP_utxo.c index 4cbe86e58..161e19502 100644 --- a/iguana/exchanges/LP_utxo.c +++ b/iguana/exchanges/LP_utxo.c @@ -1087,13 +1087,19 @@ void LP_unspents_cache(char *symbol,char *addr,char *arraystr,int32_t updatedfla } } +char *LP_unspents_filestr(char *symbol,char *addr) +{ + char fname[1024]; long fsize; + sprintf(fname,"%s/UNSPENTS/%s_%s",GLOBAL_DBDIR,symbol,addr), OS_portable_path(fname); + return(OS_filestr(&fsize,fname)); +} + uint64_t LP_unspents_load(char *symbol,char *addr) { - char fname[1024],*arraystr; uint64_t balance = 0; int32_t i,n; long fsize; struct iguana_info *coin; cJSON *retjson,*item; + char *arraystr; uint64_t balance = 0; int32_t i,n; cJSON *retjson,*item; struct iguana_info *coin; if ( (coin= LP_coinfind(symbol)) != 0 ) { - sprintf(fname,"%s/UNSPENTS/%s_%s",GLOBAL_DBDIR,symbol,addr), OS_portable_path(fname); - if ( (arraystr= OS_filestr(&fsize,fname)) != 0 ) + if ( (arraystr= LP_unspents_filestr(symbol,addr)) != 0 ) { if ( (retjson= cJSON_Parse(arraystr)) != 0 ) { From 348b63705f73949e1e8893bf0e88dc23e8a0d92c Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 8 Nov 2017 02:27:03 +0200 Subject: [PATCH 2/3] 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 343106e90..975b25cd7 100644 --- a/iguana/exchanges/LP_rpc.c +++ b/iguana/exchanges/LP_rpc.c @@ -694,7 +694,7 @@ cJSON *LP_listunspent(char *symbol,char *coinaddr) sprintf(buf,"[%d, 99999999, [\"%s\"]]",numconfs,coinaddr); return(bitcoin_json(coin,"listunspent",buf)); } else return(LP_address_utxos(coin,coinaddr,0)); - } else return(electrum_address_listunspent(symbol,coin->electrum,&retjson,coinaddr,1)); + } else return(electrum_address_listunspent(symbol,coin->electrum,&retjson,coinaddr,2)); } int32_t LP_listunspent_issue(char *symbol,char *coinaddr,int32_t fullflag) From 3ecfc1abc6b5bdc14b8749c8acb3d8a84236bc98 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 8 Nov 2017 02:30:10 +0200 Subject: [PATCH 3/3] Test --- iguana/exchanges/LP_include.h | 1 + iguana/exchanges/LP_socket.c | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_include.h b/iguana/exchanges/LP_include.h index 444858583..517786bc9 100644 --- a/iguana/exchanges/LP_include.h +++ b/iguana/exchanges/LP_include.h @@ -425,6 +425,7 @@ cJSON *LP_gettxout(char *symbol,char *coinaddr,bits256 txid,int32_t vout); void LP_postutxos(char *symbol,char *coinaddr); int32_t LP_listunspent_both(char *symbol,char *coinaddr,int32_t fullflag); uint16_t LP_randpeer(char *destip); +char *LP_unspents_filestr(char *symbol,char *addr); cJSON *bitcoin_data2json(uint8_t taddr,uint8_t pubtype,uint8_t p2shtype,uint8_t isPoS,int32_t height,bits256 *txidp,struct iguana_msgtx *msgtx,uint8_t *extraspace,int32_t extralen,uint8_t *serialized,int32_t len,cJSON *vins,int32_t suppress_pubkeys,int32_t zcash); //int32_t LP_butxo_findeither(bits256 txid,int32_t vout); cJSON *LP_listunspent(char *symbol,char *coinaddr); diff --git a/iguana/exchanges/LP_socket.c b/iguana/exchanges/LP_socket.c index c459e725a..2024d0deb 100644 --- a/iguana/exchanges/LP_socket.c +++ b/iguana/exchanges/LP_socket.c @@ -622,7 +622,13 @@ cJSON *electrum_address_listunspent(char *symbol,struct electrum_info *ep,cJSON } } if ( retjson == 0 ) - retjson = LP_address_utxos(coin,addr,1); + { + if ( strcmp(addr,coin->smartaddr) == 0 && (retstr= LP_unspents_filestr(symbol,coin->smartaddr)) != 0 ) + { + retjson = LP_address_utxos(coin,addr,1); + free(retstr); + } else retjson = LP_address_utxos(coin,addr,1); + } return(retjson); }