Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
fe64294adc
  1. 30
      iguana/iguana_payments.c
  2. 23
      iguana/index.html
  3. 1
      iguana/tests/balances

30
iguana/iguana_payments.c

@ -567,18 +567,38 @@ char *iguana_createrawtx(struct supernet_info *myinfo,uint32_t rawtxtag,char *sy
INT_ARRAY_STRING(iguana,balances,lastheight,addresses,activecoin)
{
uint8_t *rmdarray; uint64_t total = 0; cJSON *array,*retjson,*hexjson; int32_t numrmds=0,minconf=0,maxconf=0,numunspents = 0; char *retstr;
uint64_t amount,total = 0; cJSON *item,*result,*array,*retjson,*hexjson; int32_t i,n,minconf=0; char *retstr,*balancestr,*coinaddr;
retjson = cJSON_CreateObject();
if ( activecoin != 0 && activecoin[0] != 0 && (coin= iguana_coinfind(activecoin)) != 0 )
{
if ( coin->RELAYNODE != 0 || coin->VALIDATENODE != 0 )
{
array = cJSON_CreateArray();
rmdarray = iguana_rmdarray(myinfo,coin,&numrmds,array,0);
total = iguana_unspents(myinfo,coin,retjson,minconf,maxconf,rmdarray,numrmds,lastheight,0,&numunspents);
if ( rmdarray != 0 )
free(rmdarray);
if ( (n= cJSON_GetArraySize(addresses)) > 0 )
{
for (i=0; i<n; i++)
{
coinaddr = jstri(addresses,i);
if ( (balancestr= iguana_balance(IGUANA_CALLARGS,activecoin,coinaddr,lastheight,minconf)) != 0 )
{
if ( (result= cJSON_Parse(balancestr)) != 0 )
{
if ( jobj(result,"balance") != 0 )
{
item = cJSON_CreateObject();
amount = SATOSHIDEN * jdouble(result,"balance");
total += amount;
jaddnum(item,coinaddr,dstr(amount));
jaddi(array,item);
}
free_json(result);
}
free(balancestr);
}
}
}
jadd(retjson,"balances",array);
jaddnum(retjson,"total",dstr(total));
if ( lastheight != 0 )
jaddnum(retjson,"lastheight",lastheight);
if ( remoteaddr != 0 && remoteaddr[0] != 0 && strcmp(remoteaddr,"127.0.0.1") != 0 )

23
iguana/index.html

@ -24,6 +24,28 @@
<script src="js/amcharts/plugins/dataloader/dataloader.min.js" type="text/javascript"></script>
<script>
var httpresult;
function http_handler()
{
if ( this.status == 200 && this.responseText != null )
{
alert(this.responseText);
httpresult = this.responseText;
}
}
function httpGet(url)
{
var client;
if ( window.XMLHttpRequest )
client = new XMLHttpRequest();
else client = new ActiveXObject(\"Microsoft.XMLHTTP\");
client.onload = http_handler;
client.open(\"GET\",url);
client.send();
}
AmCharts.ready(function () { createStockChart(); });
var interval,BASE= "BTCD",REL = "BTC";
@ -713,7 +735,6 @@ data-path="{tc}/{config}">
<!-- Default panel contents -->
<div class="panel-heading">
<h3>InstantDEX</h3>
<div class="chart">
<button id="start">Start</button>
<button id="stop" disabled="disabled">Stop </button>

1
iguana/tests/balances

@ -0,0 +1 @@
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"balances\",\"lastheight\":0,\"activecoin\":\"BTCD\",\"addresses\":[\"RRyBxbrAPRUBCUpiJgJZYrkxqrh8x5ta9Z\"]}"
Loading…
Cancel
Save