From 4a164ff1fc4ced443b59c155bfb0ba34310a2a11 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 31 Mar 2018 20:20:29 +0300 Subject: [PATCH] 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\"}"