From 07460b831d11a9eb45e00ebe8e89caaa25d5ae36 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 9 Jan 2017 16:53:06 +0200 Subject: [PATCH] test --- iguana/dPoW.h | 2 +- iguana/dpow/dpow_network.c | 4 +++- iguana/dpow/dpow_rpc.c | 43 ++++++++++++++++++++++---------------- iguana/iguana777.c | 2 +- iguana/m_notary | 2 +- 5 files changed, 31 insertions(+), 22 deletions(-) diff --git a/iguana/dPoW.h b/iguana/dPoW.h index a64777743..d098465aa 100755 --- a/iguana/dPoW.h +++ b/iguana/dPoW.h @@ -157,7 +157,7 @@ bits256 dpow_getblockhash(struct supernet_info *myinfo,struct iguana_info *coin, bits256 dpow_getbestblockhash(struct supernet_info *myinfo,struct iguana_info *coin); char *dpow_sendrawtransaction(struct supernet_info *myinfo,struct iguana_info *coin,char *signedtx); cJSON *dpow_gettxout(struct supernet_info *myinfo,struct iguana_info *coin,bits256 txid,int32_t vout); -char *dpow_importaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *address,int32_t forceflag); +char *dpow_importaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *address); char *dpow_validateaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *address); cJSON *dpow_listunspent(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr); cJSON *dpow_listtransactions(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr,int32_t count,int32_t skip); diff --git a/iguana/dpow/dpow_network.c b/iguana/dpow/dpow_network.c index 91d1ee478..ed29865f5 100755 --- a/iguana/dpow/dpow_network.c +++ b/iguana/dpow/dpow_network.c @@ -270,7 +270,7 @@ char *dex_response(int32_t *broadcastflagp,struct supernet_info *myinfo,struct d } else if ( dexreq.func == 'A' ) { - retstr = dpow_importaddress(myinfo,coin,(char *)&dexp->packet[datalen],0); + retstr = dpow_importaddress(myinfo,coin,(char *)&dexp->packet[datalen]); if ( retstr == 0 ) { *broadcastflagp = 1; @@ -935,6 +935,8 @@ void dpow_ratify_update(struct supernet_info *myinfo,struct dpow_info *dp,struct { if ( ((1LL << i) & matchesmask) != 0 ) { + if ( bp->notaries[i].pendingcrcs[bp->state < 1000] == 0 ) + continue; if ( numcrcs == 0 ) numcrcs++, crcval = bp->notaries[i].pendingcrcs[bp->state < 1000]; else if ( numcrcs > 0 && crcval == bp->notaries[i].pendingcrcs[bp->state < 1000] ) diff --git a/iguana/dpow/dpow_rpc.c b/iguana/dpow/dpow_rpc.c index 61c465333..54b61732b 100755 --- a/iguana/dpow/dpow_rpc.c +++ b/iguana/dpow/dpow_rpc.c @@ -434,9 +434,22 @@ char *dpow_alladdresses(struct supernet_info *myinfo,struct iguana_info *coin) return(retstr); } -char *dpow_importaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *address,int32_t forceflag) +char *dpow_importaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *address) { - char buf[1024],*retstr,*alladdresses,*outstr,fname[1024]; cJSON *alljson; int32_t i,n; FILE *fp; + char buf[1024],*retstr,*alladdresses,*outstr,fname[1024]; cJSON *alljson,*validatejson; int32_t i,n,doneflag = 0; FILE *fp; + if ( (retstr= dpow_validateaddress(myinfo,coin,address)) != 0 ) + { + if ( (validatejson= cJSON_Parse(retstr)) != 0 ) + { + if ( is_cJSON_True(jobj(validatejson,"iswatchonly")) != 0 || is_cJSON_True(jobj(validatejson,"ismine")) != 0 ) + doneflag = 1; + free_json(validatejson); + } + free(retstr); + retstr = 0; + } + if ( doneflag != 0 ) + return(0); // success if ( coin->FULLNODE < 0 ) { sprintf(buf,"[\"%s\", \"%s\", false]",address,address); @@ -448,27 +461,21 @@ char *dpow_importaddress(struct supernet_info *myinfo,struct iguana_info *coin,c { if ( is_cJSON_Array(alljson) != 0 && (n= cJSON_GetArraySize(alljson)) > 0 ) { - if ( forceflag == 0 ) - { - for (i=0; isymbol), OS_compatible_path(fname); + if ( (fp= fopen(fname,"wb")) != 0 ) { - outstr = jprint(alljson,0); - sprintf(fname,"%s/alladdresses.%s",GLOBAL_CONFSDIR,coin->symbol), OS_compatible_path(fname); - if ( (fp= fopen(fname,"wb")) != 0 ) - { - fwrite(outstr,1,strlen(outstr)+1,fp); - fclose(fp); - printf("importaddress.(%s) -> alladdresses.%s\n",address,coin->symbol); - } - free(outstr); + fwrite(outstr,1,strlen(outstr)+1,fp); + fclose(fp); + printf("importaddress.(%s) -> alladdresses.%s\n",address,coin->symbol); } + free(outstr); } } free_json(alljson); diff --git a/iguana/iguana777.c b/iguana/iguana777.c index ad0523099..0dc0b63f1 100755 --- a/iguana/iguana777.c +++ b/iguana/iguana777.c @@ -904,7 +904,7 @@ void iguana_coinloop(void *arg) if ( is_cJSON_Array(alljson) != 0 && (n= cJSON_GetArraySize(alljson)) > 0 ) { for (i=0; i