From 4a164ff1fc4ced443b59c155bfb0ba34310a2a11 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 31 Mar 2018 20:20:29 +0300 Subject: [PATCH 1/5] Listtransactions --- iguana/exchanges/LP_commands.c | 6 ++++++ iguana/exchanges/LP_rpc.c | 21 +++++++++++++++++++++ iguana/exchanges/listtransactions | 3 +++ 3 files changed, 30 insertions(+) create mode 100755 iguana/exchanges/listtransactions diff --git a/iguana/exchanges/LP_commands.c b/iguana/exchanges/LP_commands.c index 90b74aa94..0284b7b25 100644 --- a/iguana/exchanges/LP_commands.c +++ b/iguana/exchanges/LP_commands.c @@ -607,6 +607,12 @@ jpg(srcfile, destfile, power2=7, password, data="", required, ind=0)\n\ { return(LP_unlockedspend(ctx,coin,jbits256(argjson,"txid"))); } + // cJSON *LP_listtransactions(char *symbol,char *coinaddr,int32_t count,int32_t skip) + else if ( strcmp(method,"listtransactions") == 0 ) + { + if ( (ptr= LP_coinfind(coin)) != 0 ) + return(jprint(LP_listtransactions(coin,ptr->smartaddr,juint(argjson,"count"),juint(argjson,"skip")),1)); + } else if ( strcmp(method,"getrawtransaction") == 0 ) { return(jprint(LP_gettx("stats_JSON",coin,jbits256(argjson,"txid"),0),1)); diff --git a/iguana/exchanges/LP_rpc.c b/iguana/exchanges/LP_rpc.c index 6228e48f7..e91676371 100644 --- a/iguana/exchanges/LP_rpc.c +++ b/iguana/exchanges/LP_rpc.c @@ -495,6 +495,27 @@ cJSON *LP_listreceivedbyaddress(char *symbol,char *coinaddr) } else return(electrum_address_gethistory(symbol,coin->electrum,&retjson,coinaddr,zero)); } + +cJSON *LP_listtransactions(char *symbol,char *coinaddr,int32_t count,int32_t skip) +{ + char buf[128],*addr; bits256 zero; cJSON *retjson,*array,*item; int32_t i,n; struct iguana_info *coin; + if ( symbol == 0 || symbol[0] == 0 ) + return(cJSON_Parse("{\"error\":\"null symbol\"}")); + coin = LP_coinfind(symbol); + if ( coin == 0 || (IAMLP == 0 && coin->inactive != 0) ) + return(cJSON_Parse("{\"error\":\"no coin\"}")); + memset(zero.bytes,0,sizeof(zero)); + if ( coin->electrum == 0 ) + { + if ( count == 0 ) + count = 10; + sprintf(buf,"[\"\", %d, %d, true]",count,skip); + if ( (array= bitcoin_json(coin,"listtransactions",buf)) != 0 ) + return(array); + elsereturn(cJSON_Parse("[]")); + } else return(electrum_address_gethistory(symbol,coin->electrum,&retjson,coinaddr,zero)); +} + int64_t LP_listunspent_parseitem(struct iguana_info *coin,bits256 *txidp,int32_t *voutp,int32_t *heightp,cJSON *item) { int64_t satoshis = 0; diff --git a/iguana/exchanges/listtransactions b/iguana/exchanges/listtransactions new file mode 100755 index 000000000..513a1647f --- /dev/null +++ b/iguana/exchanges/listtransactions @@ -0,0 +1,3 @@ +#!/bin/bash +source userpass +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"listtransactions\",\"coin\":\"CHIPS\",\"address\":\"RMfQwu5ey23eWJ4as2ckd8dqsQJwo836ny\"}" From 35843b2592e75b981a270f77abd5ccbc31919eb6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 31 Mar 2018 20:21:51 +0300 Subject: [PATCH 2/5] 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 e91676371..affa62038 100644 --- a/iguana/exchanges/LP_rpc.c +++ b/iguana/exchanges/LP_rpc.c @@ -512,7 +512,7 @@ cJSON *LP_listtransactions(char *symbol,char *coinaddr,int32_t count,int32_t ski sprintf(buf,"[\"\", %d, %d, true]",count,skip); if ( (array= bitcoin_json(coin,"listtransactions",buf)) != 0 ) return(array); - elsereturn(cJSON_Parse("[]")); + else return(cJSON_Parse("[]")); } else return(electrum_address_gethistory(symbol,coin->electrum,&retjson,coinaddr,zero)); } From 286eb0bf76af112eba91fb778a0517c7812dc090 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 31 Mar 2018 20:26:49 +0300 Subject: [PATCH 3/5] Test --- iguana/exchanges/LP_rpc.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/iguana/exchanges/LP_rpc.c b/iguana/exchanges/LP_rpc.c index affa62038..47ac3305d 100644 --- a/iguana/exchanges/LP_rpc.c +++ b/iguana/exchanges/LP_rpc.c @@ -510,9 +510,21 @@ cJSON *LP_listtransactions(char *symbol,char *coinaddr,int32_t count,int32_t ski if ( count == 0 ) count = 10; sprintf(buf,"[\"\", %d, %d, true]",count,skip); + retjson = cJSON_CreateArray(); if ( (array= bitcoin_json(coin,"listtransactions",buf)) != 0 ) - return(array); - else return(cJSON_Parse("[]")); + { + if ( (n= cJSON_GetArraySize(array)) > 0 ) + { + for (i=0; ielectrum,&retjson,coinaddr,zero)); } From 692dcefe1e3f9ed83891b1968223d00d86f808e3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 31 Mar 2018 20:27:29 +0300 Subject: [PATCH 4/5] 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 47ac3305d..b2b7da969 100644 --- a/iguana/exchanges/LP_rpc.c +++ b/iguana/exchanges/LP_rpc.c @@ -519,7 +519,7 @@ cJSON *LP_listtransactions(char *symbol,char *coinaddr,int32_t count,int32_t ski { item = jitem(array,i); if ( (addr= jstr(item,"address")) != 0 && strcmp(addr,coinaddr) == 0 ) - jaddi(retjso,jduplicate(item)); + jaddi(retjson,jduplicate(item)); } } free_json(array); From a23e248c333f7d2f52db7e53779364d05afde91c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 31 Mar 2018 20:31:23 +0300 Subject: [PATCH 5/5] Test --- iguana/exchanges/LP_commands.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/iguana/exchanges/LP_commands.c b/iguana/exchanges/LP_commands.c index 0284b7b25..aa105413d 100644 --- a/iguana/exchanges/LP_commands.c +++ b/iguana/exchanges/LP_commands.c @@ -168,10 +168,10 @@ timelock(coin, duration, destaddr=(tradeaddr), amount)\n\ unlockedspend(coin, txid)\n\ opreturndecrypt(coin, txid, passphrase)\n\ getendpoint(port=5555)\n\ +listtransactions(coin, address, count=10, skip=0)\n\ jpg(srcfile, destfile, power2=7, password, data="", required, ind=0)\n\ \"}")); - //sell(base, rel, price, basevolume, timeout=10, duration=3600)\n\ - + if ( (base= jstr(argjson,"base")) == 0 ) base = ""; if ((rel= jstr(argjson,"rel")) == 0 ) @@ -611,7 +611,7 @@ jpg(srcfile, destfile, power2=7, password, data="", required, ind=0)\n\ else if ( strcmp(method,"listtransactions") == 0 ) { if ( (ptr= LP_coinfind(coin)) != 0 ) - return(jprint(LP_listtransactions(coin,ptr->smartaddr,juint(argjson,"count"),juint(argjson,"skip")),1)); + return(jprint(LP_listtransactions(coin,jstr(argjson,"address"),juint(argjson,"count"),juint(argjson,"skip")),1)); } else if ( strcmp(method,"getrawtransaction") == 0 ) {