Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
25c0c345b5
  1. 3
      iguana/iguana777.h
  2. 2
      iguana/iguana_payments.c
  3. 10
      iguana/iguana_unspents.c
  4. 33
      iguana/iguana_wallet.c
  5. 2
      iguana/tests/gettransaction
  6. 2
      iguana/tests/listunspent

3
iguana/iguana777.h

@ -839,7 +839,7 @@ struct bitcoin_unspent *iguana_unspentsget(struct supernet_info *myinfo,struct i
void iguana_chainparms(struct iguana_chain *chain,cJSON *argjson);
int32_t iguana_pkhasharray(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *array,int32_t minconf,int32_t maxconf,int64_t *totalp,struct iguana_pkhash *P,int32_t max,uint8_t rmd160[20],char *coinaddr,uint8_t *pubkey33,int32_t lastheight,uint64_t *unspents,int32_t *numunspentsp,int32_t maxunspents);
long iguana_spentsfile(struct iguana_info *coin,int32_t n);
uint8_t *iguana_rmdarray(struct iguana_info *coin,int32_t *numrmdsp,cJSON *array,int32_t firsti);
uint8_t *iguana_rmdarray(struct supernet_info *myinfo,struct iguana_info *coin,int32_t *numrmdsp,cJSON *array,int32_t firsti);
int64_t iguana_unspents(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *array,int32_t minconf,int32_t maxconf,uint8_t *rmdarray,int32_t numrmds,int32_t lastheight,uint64_t *unspents,int32_t *numunspentsp);
uint8_t *iguana_walletrmds(struct supernet_info *myinfo,struct iguana_info *coin,int32_t *numrmdsp);
char *iguana_bundleaddrs(struct iguana_info *coin,int32_t hdrsi);
@ -969,6 +969,7 @@ int32_t instantdex_quoterequest(struct supernet_info *myinfo,struct iguana_info
int32_t instantdex_peerhas_clear(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_peer *addr);
int32_t instantdex_quote(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_peer *addr,uint8_t *serialized,int32_t recvlen);
void instantdex_update(struct supernet_info *myinfo);
cJSON *iguana_getaddressesbyaccount(struct supernet_info *myinfo,struct iguana_info *coin,char *account);
extern int32_t HDRnet,netBLOCKS;

2
iguana/iguana_payments.c

@ -935,7 +935,7 @@ TWOINTS_AND_ARRAY(bitcoinrpc,listunspent,minconf,maxconf,array)
minconf = 1;
if ( maxconf == 0 )
maxconf = 9999999;
rmdarray = iguana_rmdarray(coin,&numrmds,array,0);
rmdarray = iguana_rmdarray(myinfo,coin,&numrmds,array,0);
iguana_unspents(myinfo,coin,retjson,minconf,maxconf,rmdarray,numrmds,0,0,&numunspents);
if ( rmdarray != 0 )
free(rmdarray);

10
iguana/iguana_unspents.c

@ -250,7 +250,7 @@ int32_t iguana_pkhasharray(struct supernet_info *myinfo,struct iguana_info *coin
lastheight = IGUANA_MAXHEIGHT;
if ( max > coin->bundlescount )
max = coin->bundlescount;
for (total=n=0,i=max-1; i>=0; i--)
for (total=n=i=0; i<max; i++)
{
if ( (bp= coin->bundles[i]) == 0 )
continue;
@ -321,10 +321,12 @@ int64_t iguana_unspents(struct supernet_info *myinfo,struct iguana_info *coin,cJ
return(sum);
}
uint8_t *iguana_rmdarray(struct iguana_info *coin,int32_t *numrmdsp,cJSON *array,int32_t firsti)
uint8_t *iguana_rmdarray(struct supernet_info *myinfo,struct iguana_info *coin,int32_t *numrmdsp,cJSON *array,int32_t firsti)
{
int32_t i,n,j=0; char *coinaddr,rmdstr[41]; uint8_t *addrtypes,*rmdarray = 0;
int32_t i,n,flag=0,j=0; char *coinaddr,rmdstr[41]; uint8_t *addrtypes,*rmdarray = 0;
*numrmdsp = 0;
if ( array == 0 )
array = iguana_getaddressesbyaccount(myinfo,coin,"*");
if ( array != 0 && (n= cJSON_GetArraySize(array)) > 0 )
{
*numrmdsp = n - firsti;
@ -342,6 +344,8 @@ uint8_t *iguana_rmdarray(struct iguana_info *coin,int32_t *numrmdsp,cJSON *array
}
printf("rmdarray[%d]\n",n);
}
if ( flag != 0 )
free_json(array);
return(rmdarray);
}

33
iguana/iguana_wallet.c

@ -254,18 +254,31 @@ uint8_t *iguana_walletrmds(struct supernet_info *myinfo,struct iguana_info *coin
return(rmdarray);
}
cJSON *getaddressesbyaccount(struct supernet_info *myinfo,struct iguana_info *coin,char *account)
cJSON *iguana_getaddressesbyaccount(struct supernet_info *myinfo,struct iguana_info *coin,char *account)
{
struct iguana_waccount *subset; struct iguana_waddress *waddr,*tmp; cJSON *retjson,*array;
struct iguana_waccount *subset,*tmp; struct iguana_waddress *waddr,*tmp2; cJSON *retjson,*array;
retjson = cJSON_CreateObject();
array = cJSON_CreateArray();
if ( (subset= iguana_waccountfind(myinfo,coin,account)) != 0 )
if ( strcmp("*",account) != 0 )
{
HASH_ITER(hh,subset->waddr,waddr,tmp)
if ( (subset= iguana_waccountfind(myinfo,coin,account)) != 0 )
{
jaddistr(array,waddr->coinaddr);
HASH_ITER(hh,subset->waddr,waddr,tmp2)
{
jaddistr(array,waddr->coinaddr);
}
} else jaddstr(retjson,"result","cant find account");
}
else
{
HASH_ITER(hh,myinfo->wallet,subset,tmp)
{
HASH_ITER(hh,subset->waddr,waddr,tmp2)
{
jaddistr(array,waddr->coinaddr);
}
}
} else jaddstr(retjson,"result","cant find account");
}
return(array);
}
@ -773,7 +786,7 @@ int64_t iguana_waccountbalance(struct supernet_info *myinfo,struct iguana_info *
int64_t balance; int32_t numrmds=0,numunspents = 0; uint8_t *rmdarray=0;
if ( minconf == 0 )
minconf = 1;
rmdarray = iguana_rmdarray(coin,&numrmds,getaddressesbyaccount(myinfo,coin,wacct->account),0);
rmdarray = iguana_rmdarray(myinfo,coin,&numrmds,iguana_getaddressesbyaccount(myinfo,coin,wacct->account),0);
balance = iguana_unspents(myinfo,coin,0,minconf,(1 << 30),rmdarray,numrmds,lastheight,0,&numunspents);
if ( rmdarray != 0 )
free(rmdarray);
@ -1285,7 +1298,7 @@ STRING_AND_THREEINTS(bitcoinrpc,getbalance,account,minconf,includeempty,lastheig
if ( minconf == 0 )
minconf = 1;
if ( strcmp(account,"*") != 0 )
rmdarray = iguana_rmdarray(coin,&numrmds,getaddressesbyaccount(myinfo,coin,account),0);
rmdarray = iguana_rmdarray(myinfo,coin,&numrmds,iguana_getaddressesbyaccount(myinfo,coin,account),0);
numunspents = 0;
balance = iguana_unspents(myinfo,coin,0,minconf,(1 << 30),rmdarray,numrmds,lastheight,0,&numunspents);
if ( rmdarray != 0 )
@ -1303,7 +1316,7 @@ STRING_ARG(bitcoinrpc,getaddressesbyaccount,account)
if ( myinfo->expiration == 0 )
return(clonestr("{\"error\":\"need to unlock wallet\"}"));
retjson = cJSON_CreateObject();
jadd(retjson,"result",getaddressesbyaccount(myinfo,coin,account));
jadd(retjson,"result",iguana_getaddressesbyaccount(myinfo,coin,account));
return(jprint(retjson,1));
}
@ -1334,7 +1347,7 @@ STRING_AND_THREEINTS(bitcoinrpc,listtransactions,account,count,skip,includewatch
retarray = cJSON_CreateArray();
if ( (wacct= iguana_waccountfind(myinfo,coin,account)) != 0 )
{
if ( (array= getaddressesbyaccount(myinfo,coin,account)) != 0 )
if ( (array= iguana_getaddressesbyaccount(myinfo,coin,account)) != 0 )
{
if ( (n= cJSON_GetArraySize(array)) > 0 )
{

2
iguana/tests/gettransaction

@ -1,2 +1,2 @@
curl --url "http://127.0.0.1:7778" --data "{\"method\":\"gettransaction\",\"params\":[\"fe9ba49c411ee7b3ae16f8de6f2e32b4ea469a8ff64766be113817646100bb56\"]}"
curl --url "http://127.0.0.1:7778" --data "{\"method\":\"gettransaction\",\"params\":[\"4b5ba0f755c7bc322e32cdd957546bfa586e828eaeff9181cc72fe3fa0944f51\"]}"

2
iguana/tests/listunspent

@ -1 +1 @@
curl --url "http://127.0.0.1:7778" --data "{\"method\":\"listunspent\",\"params\":[\"185oPvxk7SxxSAe121r8pmFjQEHZNREYUc\"]}"
curl --url "http://127.0.0.1:7778" --data "{\"method\":\"listunspent\",\"params\":[1, 9999999, [\"RAoMou7euzvDwa9dQwjrNB5A41hrAWgvBt\"]]}"

Loading…
Cancel
Save