Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
e964fa6958
  1. 23
      basilisk/basilisk_bitcoin.c
  2. 2
      iguana/tests/balances

23
basilisk/basilisk_bitcoin.c

@ -299,7 +299,24 @@ int32_t basilisk_bitcoinavail(struct iguana_info *coin)
void *basilisk_bitcoinbalances(struct basilisk_item *Lptr,struct supernet_info *myinfo,struct iguana_info *coin,char *remoteaddr,uint32_t basilisktag,int32_t timeoutmillis,cJSON *vals) void *basilisk_bitcoinbalances(struct basilisk_item *Lptr,struct supernet_info *myinfo,struct iguana_info *coin,char *remoteaddr,uint32_t basilisktag,int32_t timeoutmillis,cJSON *vals)
{ {
return(0); int64_t balance,total = 0; int32_t i,n; cJSON *retjson,*item,*addresses,*array = cJSON_CreateArray();
if ( (addresses= jarray(&n,vals,"addresses")) != 0 )
{
for (i=0; i<n; i++)
{
balance = iguana_addressreceived(myinfo,coin,vals,remoteaddr,0,0,jstri(addresses,i),juint(vals,"minconf"));
item = cJSON_CreateObject();
jaddnum(item,jstri(addresses,i),dstr(balance));
jaddi(array,item);
total += balance;
}
}
retjson = cJSON_CreateObject();
jaddstr(retjson,"result","success");
jaddnum(retjson,"total",dstr(total));
jadd(retjson,"addresses",array);
Lptr->retstr = jprint(retjson,1);
return(Lptr);
} }
char *basilisk_valuestr(struct iguana_info *coin,char *coinaddr,uint64_t value,int32_t height,bits256 txid,int16_t vout) char *basilisk_valuestr(struct iguana_info *coin,char *coinaddr,uint64_t value,int32_t height,bits256 txid,int16_t vout)
@ -759,8 +776,10 @@ HASH_ARRAY_STRING(basilisk,balances,hash,vals,hexstr)
if ( (symbol= jstr(vals,"symbol")) != 0 || (symbol= jstr(vals,"coin")) != 0 ) if ( (symbol= jstr(vals,"symbol")) != 0 || (symbol= jstr(vals,"coin")) != 0 )
coin = iguana_coinfind(symbol); coin = iguana_coinfind(symbol);
} }
if ( coin != 0 ) if ( coin != 0 && vals != 0 )
{ {
if ( jobj(vals,"addresses") == 0 )
jadd(vals,"addresses",iguana_getaddressesbyaccount(myinfo,coin,"*"));
if ( (basilisktag= juint(vals,"basilisktag")) == 0 ) if ( (basilisktag= juint(vals,"basilisktag")) == 0 )
basilisktag = rand(); basilisktag = rand();
if ( (timeoutmillis= juint(vals,"timeout")) <= 0 ) if ( (timeoutmillis= juint(vals,"timeout")) <= 0 )

2
iguana/tests/balances

@ -1 +1 @@
curl --url "http://127.0.0.1:7778" --data "{\"timeout\":20000,\"agent\":\"basilisk\",\"method\":\"balances\",\"lastheight\":0,\"activecoin\":\"BTCD\",\"addresses\":[\"RRyBxbrAPRUBCUpiJgJZYrkxqrh8x5ta9Z\"]}" curl --url "http://127.0.0.1:7778" --data "{\"timeout\":20000,\"agent\":\"basilisk\",\"method\":\"balances\",\"vals\":{\"minconf\":1}}"

Loading…
Cancel
Save