Browse Source

test

etomic
jl777 8 years ago
parent
commit
e05bc95a03
  1. 3
      basilisk/basilisk.c
  2. 2
      iguana/iguana777.h
  3. 11
      iguana/iguana_notary.c
  4. 36
      iguana/kmd_lookup.h
  5. 1
      iguana/main.c
  6. 2
      iguana/tests/dexexplorer
  7. 1
      includes/iguana_apideclares.h
  8. 2
      includes/iguana_structs.h

3
basilisk/basilisk.c

@ -908,7 +908,6 @@ void basilisks_loop(void *arg)
}
endmilli = startmilli + 30;
}
kmd_bitcoinscan();
}
else
{
@ -918,6 +917,8 @@ void basilisks_loop(void *arg)
endmilli = startmilli + 500;
else endmilli = startmilli + 1000;
}
if ( myinfo->DEXEXPLORER != 0 )
kmd_bitcoinscan();
if ( myinfo->expiration != 0 && (myinfo->dexsock >= 0 || myinfo->IAMLP != 0 || myinfo->DEXactive > time(NULL)) )
{
//fprintf(stderr,"H ");

2
iguana/iguana777.h

@ -137,7 +137,7 @@ struct supernet_info
uint8_t logs[256],exps[510];
struct message_info msgids[8192];
double *svmfeatures;
uint8_t notaries[64][33]; int32_t numnotaries;
uint8_t notaries[64][33]; int32_t numnotaries,DEXEXPLORER;
};
#include "../includes/iguana_funcs.h"

11
iguana/iguana_notary.c

@ -756,6 +756,17 @@ TWO_STRINGS(dex,getbalance,symbol,address)
} else return(_dex_getbalance(myinfo,symbol,address));
}
STRING_ARG(dex,explorer,symbol)
{
if ( symbol != 0 && (coin= iguana_coinfind(symbol)) != 0 )
{
myinfo->DEXEXPLORER = 1;
coin->DEXEXPLORER = 1;
return(clonestr("{\"result\":\"success\"}"));
}
return(clonestr("{\"error\":\"coin not active\"}"));
}
#include "../includes/iguana_apiundefs.h"

36
iguana/kmd_lookup.h

@ -108,7 +108,7 @@ int32_t kmd_transactionvin(struct iguana_info *coin,bits256 spendtxid,int32_t vi
ptr->tx->vouts[vout].spendvini = vini;
if ( coin->kmd_txidfp != 0 )
{
printf("write out spent ht.%d vout.%d\n",ptr->tx->height,vout);
//printf("write out spent ht.%d vout.%d\n",ptr->tx->height,vout);
savepos = ftell(coin->kmd_txidfp);
fseek(coin->kmd_txidfp,ptr->fpos + sizeof(*ptr->tx) + sizeof(*ptr->tx->vouts)*vout,SEEK_SET);
fwrite(&ptr->tx->vouts[vout],1,sizeof(ptr->tx->vouts[vout]),coin->kmd_txidfp);
@ -368,7 +368,7 @@ cJSON *kmd_listaddress(struct iguana_info *coin,char *coinaddr,int32_t mode)
if ( memcmp(ptr->tx->vouts[i].type_rmd160,type_rmd160,21) == 0 )
{
spent = ptr->ptrs[(i<<1) + 1];
if ( (mode == 0 && spent == 0) || (mode == 1 && spent != 0) )
if ( (mode == 0 && spent == 0) || (mode == 1 && spent != 0) || mode == 2 )
jaddi(array,kmd_unspentjson(ptr->tx,i));
if ( ptr->ptrs[i<<1] != 0 )
prev = ptr->ptrs[i<<1];
@ -390,10 +390,10 @@ cJSON *kmd_listspent(struct iguana_info *coin,char *coinaddr)
return(kmd_listaddress(coin,coinaddr,1));
}
int64_t _kmd_getbalance(struct iguana_info *coin,char *coinaddr,int64_t *unspentp,int64_t *spentp)
int64_t _kmd_getbalance(struct iguana_info *coin,char *coinaddr,int64_t *receivedp,int64_t *sentp)
{
int32_t iter,i,n; cJSON *array,*item; int64_t value;
for (iter=0; iter<2; iter++)
for (iter=1; iter<=2; iter++)
{
if ( (array= kmd_listaddress(coin,coinaddr,iter)) != 0 )
{
@ -404,37 +404,37 @@ int64_t _kmd_getbalance(struct iguana_info *coin,char *coinaddr,int64_t *unspent
item = jitem(array,i);
if ( (value= jdouble(item,"amount")*SATOSHIDEN) != 0 || (value= jdouble(item,"value")*SATOSHIDEN) != 0 )
{
if ( iter == 0 )
*unspentp += value;
else *spentp += value;
if ( iter == 2 )
*receivedp += value;
else *sentp += value;
}
}
}
free_json(array);
}
}
return(*unspentp - *spentp);
return(*receivedp - *sentp);
}
cJSON *kmd_getbalance(struct iguana_info *coin,char *coinaddr)
{
cJSON *retjson; int64_t s,u,spent=0,unspent=0,balance=0; struct kmd_addresshh *addr,*tmp; char address[64];
cJSON *retjson; int64_t s,r,sent=0,received=0,balance=0; struct kmd_addresshh *addr,*tmp; char address[64];
if ( strcmp(coinaddr,"*") == 0 )
{
HASH_ITER(hh,coin->kmd_addresses,addr,tmp)
{
bitcoin_address(address,addr->type_rmd160[0],&addr->type_rmd160[1],20);
s = u = 0;
balance += _kmd_getbalance(coin,address,&u,&s);
printf("%s (%.8f - %.8f) %.8f -> %.8f\n",address,dstr(u),dstr(s),dstr(u)-dstr(s),dstr(balance));
unspent += u;
spent += s;
s = r = 0;
balance += _kmd_getbalance(coin,address,&r,&s);
printf("%s (%.8f - %.8f) %.8f -> %.8f\n",address,dstr(r),dstr(s),dstr(r)-dstr(s),dstr(balance));
received += r;
sent += s;
}
} else balance = _kmd_getbalance(coin,coinaddr,&unspent,&spent);
} else balance = _kmd_getbalance(coin,coinaddr,&received,&sent);
retjson = cJSON_CreateObject();
jaddstr(retjson,"result","success");
jaddnum(retjson,"unspents",dstr(unspent));
jaddnum(retjson,"spents",dstr(spent));
jaddnum(retjson,"received",dstr(received));
jaddnum(retjson,"sent",dstr(sent));
jaddnum(retjson,"balance",dstr(balance));
return(retjson);
}
@ -588,7 +588,7 @@ int32_t _kmd_bitcoinscan(struct iguana_info *coin)
void kmd_bitcoinscan()
{
char *retstr; cJSON *array; int32_t i,n; struct iguana_info *coin;
char *retstr; cJSON *array; int32_t i,n; struct iguana_info *coin; // scan allcoins also
if ( (retstr= dpow_notarychains(0,0,0,0)) != 0 )
{
if ( (array= cJSON_Parse(retstr)) != 0 )

1
iguana/main.c

@ -1710,6 +1710,7 @@ void iguana_main(void *arg)
{
myinfo->rpcport = IGUANA_NOTARYPORT;
myinfo->IAMNOTARY = 1;
myinfo->DEXEXPLORER = 1;
}
}
#ifdef IGUANA_OSTESTS

2
iguana/tests/dexexplorer

@ -0,0 +1,2 @@
#!/bin/bash
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"dex\",\"method\":\"explorer\",\"symbol\":\"KMD\"}"

1
includes/iguana_apideclares.h

@ -47,6 +47,7 @@ TWO_STRINGS_AND_TWO_DOUBLES(dex,listtransactions2,symbol,address,count,skip);
HASH_AND_STRING_AND_INT(dex,gettxin,txid,symbol,vout);
TWO_STRINGS(dex,listspent,symbol,address);
TWO_STRINGS(dex,getbalance,symbol,address);
STRING_ARG(dex,explorer,symbol);
TWO_STRINGS(zcash,passthru,function,hex);
TWO_STRINGS(komodo,passthru,function,hex);

2
includes/iguana_structs.h

@ -536,7 +536,7 @@ struct iguana_info
struct iguana_block *RTblocks[65536]; uint8_t *RTrawdata[65536]; int32_t RTrecvlens[65536],RTnumtx[65536];
struct iguana_RTtxid *RTdataset; struct iguana_RTaddr *RTaddrs;
struct hashstr_item *alladdresses;
struct kmd_transactionhh *kmd_transactions; struct kmd_addresshh *kmd_addresses; portable_mutex_t kmdmutex; FILE *kmd_txidfp; int32_t kmd_didinit,kmd_height; uint32_t kmd_lasttime;
struct kmd_transactionhh *kmd_transactions; struct kmd_addresshh *kmd_addresses; portable_mutex_t kmdmutex; FILE *kmd_txidfp; int32_t kmd_didinit,kmd_height,DEXEXPLORER; uint32_t kmd_lasttime;
};
struct vin_signer { bits256 privkey; char coinaddr[64]; uint8_t siglen,sig[80],rmd160[20],pubkey[66]; };

Loading…
Cancel
Save