From 3e404c6f883048fd9d8daca49a4e0c4c40292cc5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 25 Feb 2017 21:49:25 +0200 Subject: [PATCH] Test --- iguana/dPoW.h | 8 ++++---- iguana/dpow/dpow_network.c | 4 ++-- iguana/dpow/dpow_rpc.c | 4 ++-- iguana/iguana_notary.c | 8 ++++---- iguana/kmd_lookup.h | 30 +++++++++++++++--------------- 5 files changed, 27 insertions(+), 27 deletions(-) diff --git a/iguana/dPoW.h b/iguana/dPoW.h index c7934feeb..e6e8f9d80 100755 --- a/iguana/dPoW.h +++ b/iguana/dPoW.h @@ -195,11 +195,11 @@ cJSON *dpow_checkaddress(struct supernet_info *myinfo,struct iguana_info *coin,c void dex_channelsend(struct supernet_info *myinfo,bits256 srchash,bits256 desthash,uint32_t channel,uint32_t msgid,uint8_t *data,int32_t datalen); void kmd_bitcoinscan(); -cJSON *kmd_getbalance(struct iguana_info *coin,char *coinaddr); +cJSON *kmd_getbalance(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr); struct iguana_info *iguana_coinfind(char *symbol); -cJSON *kmd_listtransactions(struct iguana_info *coin,char *coinaddr,int32_t count,int32_t skip); -cJSON *kmd_listunspent(struct iguana_info *coin,char *coinaddr); -cJSON *kmd_listspent(struct iguana_info *coin,char *coinaddr); +cJSON *kmd_listtransactions(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr,int32_t count,int32_t skip); +cJSON *kmd_listunspent(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr); +cJSON *kmd_listspent(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr); cJSON *kmd_gettxin(struct iguana_info *coin,bits256 txid,int32_t vout); cJSON *dpow_listspent(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr); diff --git a/iguana/dpow/dpow_network.c b/iguana/dpow/dpow_network.c index f4fb236f3..a6829e062 100755 --- a/iguana/dpow/dpow_network.c +++ b/iguana/dpow/dpow_network.c @@ -550,7 +550,7 @@ char *dex_response(int32_t *broadcastflagp,struct supernet_info *myinfo,struct d } else if ( dexreq.func == 'u' ) { - if ( (retjson= kmd_listunspent(coin,(char *)&dexp->packet[datalen])) != 0 ) + if ( (retjson= kmd_listunspent(myinfo,coin,(char *)&dexp->packet[datalen])) != 0 ) { dpow_randipbits(myinfo,coin,retjson); retstr = jprint(retjson,1); @@ -590,7 +590,7 @@ char *dex_response(int32_t *broadcastflagp,struct supernet_info *myinfo,struct d else if ( dexreq.func == '2' ) { //printf("call list.(%s %d %d)\n",(char *)&dexp->packet[datalen],dexreq.shortarg,dexreq.intarg); - if ( (retjson= kmd_listtransactions(coin,(char *)&dexp->packet[datalen],dexreq.shortarg,dexreq.intarg)) != 0 ) + if ( (retjson= kmd_listtransactions(myinfo,coin,(char *)&dexp->packet[datalen],dexreq.shortarg,dexreq.intarg)) != 0 ) { dpow_randipbits(myinfo,coin,retjson); retstr = jprint(retjson,1); diff --git a/iguana/dpow/dpow_rpc.c b/iguana/dpow/dpow_rpc.c index dae988c04..e73e17ee6 100755 --- a/iguana/dpow/dpow_rpc.c +++ b/iguana/dpow/dpow_rpc.c @@ -408,7 +408,7 @@ cJSON *dpow_listunspent(struct supernet_info *myinfo,struct iguana_info *coin,ch cJSON *dpow_listspent(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr) { if ( myinfo->DEXEXPLORER != 0 ) - return(kmd_listspent(coin,coinaddr)); + return(kmd_listspent(myinfo,coin,coinaddr)); else { return(0); @@ -418,7 +418,7 @@ cJSON *dpow_listspent(struct supernet_info *myinfo,struct iguana_info *coin,char cJSON *dpow_getbalance(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr) { if ( myinfo->DEXEXPLORER != 0 ) - return(kmd_getbalance(coin,coinaddr)); + return(kmd_getbalance(myinfo,coin,coinaddr)); else { return(0); diff --git a/iguana/iguana_notary.c b/iguana/iguana_notary.c index a7404948d..c9532e3c0 100755 --- a/iguana/iguana_notary.c +++ b/iguana/iguana_notary.c @@ -791,7 +791,7 @@ TWO_STRINGS(dex,listunspent2,symbol,address) coin->DEXEXPLORER = myinfo->DEXEXPLORER * myinfo->IAMNOTARY * (iguana_isnotarychain(coin->symbol) >= 0); if ( strcmp(coin->symbol,"BTC") == 0 || coin->DEXEXPLORER == 0 ) return(clonestr("[]")); - if ( (retjson= kmd_listunspent(coin,address)) != 0 ) + if ( (retjson= kmd_listunspent(myinfo,coin,address)) != 0 ) return(jprint(retjson,1)); } } @@ -811,7 +811,7 @@ TWO_STRINGS_AND_TWO_DOUBLES(dex,listtransactions2,symbol,address,count,skip) coin->DEXEXPLORER = myinfo->DEXEXPLORER * myinfo->IAMNOTARY * (iguana_isnotarychain(coin->symbol) >= 0); if ( strcmp(coin->symbol,"BTC") == 0 || coin->DEXEXPLORER == 0 ) return(clonestr("[]")); - if ( (retjson= kmd_listtransactions(coin,address,count,skip)) != 0 ) + if ( (retjson= kmd_listtransactions(myinfo,coin,address,count,skip)) != 0 ) return(jprint(retjson,1)); } } @@ -839,7 +839,7 @@ TWO_STRINGS(dex,listspent,symbol,address) if ( myinfo->DEXEXPLORER != 0 ) { if ( symbol != 0 && address != 0 && (coin= iguana_coinfind(symbol)) != 0 && coin->DEXEXPLORER != 0 ) - return(jprint(kmd_listspent(coin,address),1)); + return(jprint(kmd_listspent(myinfo,coin,address),1)); if ( coin != 0 ) coin->DEXEXPLORER = myinfo->DEXEXPLORER * myinfo->IAMNOTARY * (iguana_isnotarychain(coin->symbol) >= 0); } @@ -854,7 +854,7 @@ TWO_STRINGS(dex,getbalance,symbol,address) if ( myinfo->DEXEXPLORER != 0 ) { if ( symbol != 0 && address != 0 && (coin= iguana_coinfind(symbol)) != 0 && coin->DEXEXPLORER != 0 ) - return(jprint(kmd_getbalance(coin,address),1)); + return(jprint(kmd_getbalance(myinfo,coin,address),1)); if ( coin != 0 ) coin->DEXEXPLORER = myinfo->DEXEXPLORER * myinfo->IAMNOTARY * (iguana_isnotarychain(coin->symbol) >= 0); } diff --git a/iguana/kmd_lookup.h b/iguana/kmd_lookup.h index bce6c3976..db3798dfc 100755 --- a/iguana/kmd_lookup.h +++ b/iguana/kmd_lookup.h @@ -389,7 +389,7 @@ cJSON *kmd_gettxin(struct iguana_info *coin,bits256 txid,int32_t vout) return(cJSON_Parse("{\"error\":\"txid not found\"}")); } -cJSON *kmd_listaddress(struct iguana_info *coin,char *coinaddr,int32_t mode,cJSON *array) +cJSON *kmd_listaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr,int32_t mode,cJSON *array) { struct kmd_addresshh *addr; struct kmd_transactionhh *ptr=0,*spent,*prev=0; uint8_t type_rmd160[21]; int32_t i; if ( array == 0 ) @@ -423,14 +423,14 @@ cJSON *kmd_listaddress(struct iguana_info *coin,char *coinaddr,int32_t mode,cJSO //if ( fulltx == 0 ) { if ( mode == 0 ) - jaddi(array,kmd_unspentjson(coin,coin->kmd_height,ptr->tx,i,1)); + jaddi(array,kmd_unspentjson(myinfo,coin,coin->kmd_height,ptr->tx,i,1)); else if ( mode == 1 ) jaddi(array,kmd_spentjson(coin->kmd_height,ptr->tx,i,spent)); else if ( mode == 2 ) { if ( spent != 0 ) jaddi(array,kmd_spentjson(coin->kmd_height,ptr->tx,i,spent)); - else jaddi(array,kmd_unspentjson(coin,coin->kmd_height,ptr->tx,i,0)); + else jaddi(array,kmd_unspentjson(myinfo,coin,coin->kmd_height,ptr->tx,i,0)); } } /*else if ( flag == 0 ) @@ -466,34 +466,34 @@ cJSON *kmd_listaddress(struct iguana_info *coin,char *coinaddr,int32_t mode,cJSO return(array); } -cJSON *kmd_listunspent(struct iguana_info *coin,char *coinaddr) +cJSON *kmd_listunspent(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr) { - return(kmd_listaddress(coin,coinaddr,0,0)); + return(kmd_listaddress(myinfo,coin,coinaddr,0,0)); } -cJSON *kmd_listspent(struct iguana_info *coin,char *coinaddr) +cJSON *kmd_listspent(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr) { - return(kmd_listaddress(coin,coinaddr,1,0)); + return(kmd_listaddress(myinfo,coin,coinaddr,1,0)); } -cJSON *kmd_listtransactions(struct iguana_info *coin,char *coinaddr,int32_t count,int32_t skip) +cJSON *kmd_listtransactions(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr,int32_t count,int32_t skip) { cJSON *array = cJSON_CreateArray(); //if ( (height= kmd_height(coin)) > coin->kmd_height+KMD_EXPLORER_LAG ) // return(cJSON_Parse("[]")); if ( count == 0 ) count = 100; - array = kmd_listaddress(coin,coinaddr,0,0); - array = kmd_listaddress(coin,coinaddr,1,array); + array = kmd_listaddress(myinfo,coin,coinaddr,0,0); + array = kmd_listaddress(myinfo,coin,coinaddr,1,array); return(array); } -int64_t _kmd_getbalance(struct iguana_info *coin,char *coinaddr,uint64_t *receivedp,uint64_t *sentp,uint64_t *interestp) +int64_t _kmd_getbalance(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr,uint64_t *receivedp,uint64_t *sentp,uint64_t *interestp) { int32_t iter,i,n; cJSON *array,*item; uint64_t value; for (iter=1; iter<=2; iter++) { - if ( (array= kmd_listaddress(coin,coinaddr,iter,0)) != 0 ) + if ( (array= kmd_listaddress(myinfo,coin,coinaddr,iter,0)) != 0 ) { if ( (n= cJSON_GetArraySize(array)) > 0 ) { @@ -516,7 +516,7 @@ int64_t _kmd_getbalance(struct iguana_info *coin,char *coinaddr,uint64_t *receiv return(*receivedp - *sentp); } -cJSON *kmd_getbalance(struct iguana_info *coin,char *coinaddr) +cJSON *kmd_getbalance(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr) { cJSON *retjson; double netbalance=0.,fbalance; uint64_t interest,i,s,r,sent=0,received=0; int64_t balance=0; struct kmd_addresshh *addr,*tmp; char address[64]; int32_t height = coin->kmd_height+1; retjson = cJSON_CreateObject(); @@ -528,7 +528,7 @@ cJSON *kmd_getbalance(struct iguana_info *coin,char *coinaddr) { bitcoin_address(address,addr->type_rmd160[0],&addr->type_rmd160[1],20); s = r = i = 0; - balance += _kmd_getbalance(coin,address,&r,&s,&i); + balance += _kmd_getbalance(myinfo,coin,address,&r,&s,&i); netbalance += dstr(r); netbalance -= dstr(s); if ( (r - s) > 100000*SATOSHIDEN ) @@ -542,7 +542,7 @@ cJSON *kmd_getbalance(struct iguana_info *coin,char *coinaddr) } else { - balance = _kmd_getbalance(coin,coinaddr,&received,&sent,&interest); + balance = _kmd_getbalance(myinfo,coin,coinaddr,&received,&sent,&interest); netbalance = dstr(balance); } jaddstr(retjson,"result","success");