From c94dd2056f025cb8adf4a9f335ffbd1231b4f576 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 12 Sep 2017 13:03:31 +0200 Subject: [PATCH] Test --- iguana/exchanges/LP_rpc.c | 20 +++++++++++++++++--- iguana/exchanges/LP_socket.c | 4 ++-- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/iguana/exchanges/LP_rpc.c b/iguana/exchanges/LP_rpc.c index 0301a92f9..c62e2d688 100644 --- a/iguana/exchanges/LP_rpc.c +++ b/iguana/exchanges/LP_rpc.c @@ -112,7 +112,7 @@ char *LP_apicall(struct iguana_info *coin,char *method,char *params) cJSON *bitcoin_json(struct iguana_info *coin,char *method,char *params) { - cJSON *retjson = 0; char *retstr; + cJSON *resultjson,*retjson = 0; char *retstr; // "getinfo", "getrawmempool", "paxprice", "gettxout", "getrawtransaction", "getblock", "listunspent", "listtransactions", "validateaddress", "importprivkey" // bitcoind_passthru callers: "importaddress", "estimatefee", "getblockhash", "sendrawtransaction", "signrawtransaction" if ( coin != 0 ) @@ -134,6 +134,12 @@ cJSON *bitcoin_json(struct iguana_info *coin,char *method,char *params) { retjson = electrum_submit(coin->symbol,coin->electrum,0,method,params,LP_HTTP_TIMEOUT); printf("electrum %s.%s -> (%s)\n",method,params,jprint(retjson,0)); + if ( (resultjson= jobj(retjson,"result")) != 0 ) + { + resultjson = jduplicate(resultjson); + free_json(retjson); + retjson = resultjson; + } } } else retjson = cJSON_Parse("{\"result\":\"disabled\"}"); } else printf("bitcoin_json cant talk to NULL coin\n"); @@ -220,8 +226,16 @@ cJSON *LP_gettxout(char *symbol,bits256 txid,int32_t vout) cJSON *LP_gettx(char *symbol,bits256 txid) { char buf[128],str[65]; struct iguana_info *coin = LP_coinfind(symbol); - sprintf(buf,"[\"%s\", 1]",bits256_str(str,txid)); - return(bitcoin_json(coin,"getrawtransaction",buf)); + if ( coin->electrum == 0 ) + { + sprintf(buf,"[\"%s\", 1]",bits256_str(str,txid)); + return(bitcoin_json(coin,"getrawtransaction",buf)); + } + else + { + sprintf(buf,"[\"%s\"]",bits256_str(str,txid)); + return(bitcoin_json(coin,"blockchain.transaction.get",buf)); + } } cJSON *LP_getblock(char *symbol,bits256 txid) diff --git a/iguana/exchanges/LP_socket.c b/iguana/exchanges/LP_socket.c index cd23b0178..689d05df0 100644 --- a/iguana/exchanges/LP_socket.c +++ b/iguana/exchanges/LP_socket.c @@ -522,7 +522,7 @@ int32_t LP_recvfunc(struct electrum_info *ep,char *str,int32_t len) { *(ep->heightp) = height; *(ep->heighttimep) = (uint32_t)time(NULL); - printf(">>>>>>>>> set height.%d\n",height); + printf("ELECTRUM >>>>>>>>> set height.%d\n",height); } } idnum = juint(strjson,"id"); @@ -558,7 +558,7 @@ int32_t LP_recvfunc(struct electrum_info *ep,char *str,int32_t len) { // do callback stritem = (struct stritem *)item; - printf("callback.%p (%s) -> (%s)\n",strjson,stritem->str,jprint(strjson,0)); + //printf("callback.%p (%s) -> (%s)\n",strjson,stritem->str,jprint(strjson,0)); if ( stritem->retptrp != 0 ) { *((cJSON **)stritem->retptrp) = strjson;