From 15d7fdaebbaec272dc00579fad01f7ed5e329f5a Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 17 Jan 2017 17:23:28 +0200 Subject: [PATCH] test --- iguana/dPoW.h | 1 + iguana/dpow/dpow_network.c | 6 +++++- iguana/dpow/dpow_rpc.c | 27 +++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/iguana/dPoW.h b/iguana/dPoW.h index 83795f083..fc7d7927e 100755 --- a/iguana/dPoW.h +++ b/iguana/dPoW.h @@ -181,5 +181,6 @@ char *_dex_alladdresses(struct supernet_info *myinfo,char *symbol); int32_t _dex_getheight(struct supernet_info *myinfo,char *symbol); char *_dex_getnotaries(struct supernet_info *myinfo,char *symbol); int32_t komodo_notaries(char *symbol,uint8_t pubkeys[64][33],int32_t height); +cJSON *dpow_checkaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *address); #endif diff --git a/iguana/dpow/dpow_network.c b/iguana/dpow/dpow_network.c index c7e768778..412c1bf0c 100755 --- a/iguana/dpow/dpow_network.c +++ b/iguana/dpow/dpow_network.c @@ -513,7 +513,11 @@ char *dex_response(int32_t *broadcastflagp,struct supernet_info *myinfo,struct d } else if ( dexreq.func == 'C' ) { - //retstr = dpow_checkaddress(myinfo,coin,(char *)&dexp->packet[datalen]); + if ( (retjson= dpow_checkaddress(myinfo,coin,(char *)&dexp->packet[datalen])) != 0 ) + { + dpow_randipbits(myinfo,coin,retjson); + retstr = jprint(retjson,1); + } } else if ( dexreq.func == 'A' ) { diff --git a/iguana/dpow/dpow_rpc.c b/iguana/dpow/dpow_rpc.c index 14b7e7fef..525d38441 100755 --- a/iguana/dpow/dpow_rpc.c +++ b/iguana/dpow/dpow_rpc.c @@ -475,6 +475,33 @@ void update_alladdresses(struct supernet_info *myinfo,struct iguana_info *coin,c } } +cJSON *dpow_checkaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *address) +{ + int32_t isvalid=0,doneflag=0; char *retstr; cJSON *validatejson,*retjson = cJSON_CreateObject(); + if ( (retstr= dpow_validateaddress(myinfo,coin,address)) != 0 ) + { + if ( (validatejson= cJSON_Parse(retstr)) != 0 ) + { + if ( (isvalid= is_cJSON_True(jobj(validatejson,"isvalid")) != 0) != 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 ( isvalid == 0 ) + jaddstr(retjson,"error","invalid address"); + else if ( doneflag != 0 ) + { + jaddstr(retjson,"coin",coin->symbol); + jaddstr(retjson,"address",address); + } + return(retjson); +} + char *dpow_importaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *address) { char buf[1024],*retstr; cJSON *validatejson; int32_t isvalid=0,doneflag = 0;