diff --git a/basilisk/basilisk_bitcoin.c b/basilisk/basilisk_bitcoin.c index dff1e3779..ed94cd864 100755 --- a/basilisk/basilisk_bitcoin.c +++ b/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) { - 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; iretstr = 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) @@ -759,8 +776,10 @@ HASH_ARRAY_STRING(basilisk,balances,hash,vals,hexstr) if ( (symbol= jstr(vals,"symbol")) != 0 || (symbol= jstr(vals,"coin")) != 0 ) 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 ) basilisktag = rand(); if ( (timeoutmillis= juint(vals,"timeout")) <= 0 ) diff --git a/iguana/tests/balances b/iguana/tests/balances index 469771abc..4a899475f 100755 --- a/iguana/tests/balances +++ b/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}}"