Browse Source

Merge pull request #736 from jl777/jl777

+listtransactions api
patch-3
jl777 7 years ago
committed by GitHub
parent
commit
b203ee2416
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      iguana/exchanges/LP_commands.c
  2. 33
      iguana/exchanges/LP_rpc.c
  3. 3
      iguana/exchanges/listtransactions

10
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 )
@ -612,6 +612,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,jstr(argjson,"address"),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));

33
iguana/exchanges/LP_rpc.c

@ -495,6 +495,39 @@ 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);
retjson = cJSON_CreateArray();
if ( (array= bitcoin_json(coin,"listtransactions",buf)) != 0 )
{
if ( (n= cJSON_GetArraySize(array)) > 0 )
{
for (i=0; i<n; i++)
{
item = jitem(array,i);
if ( (addr= jstr(item,"address")) != 0 && strcmp(addr,coinaddr) == 0 )
jaddi(retjson,jduplicate(item));
}
}
free_json(array);
}
return(retjson);
} 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;

3
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\"}"
Loading…
Cancel
Save