diff --git a/crypto777/iguana_serdes.c b/crypto777/iguana_serdes.c index 1f070716b..f8430ea2e 100755 --- a/crypto777/iguana_serdes.c +++ b/crypto777/iguana_serdes.c @@ -52,24 +52,6 @@ int32_t iguana_rwnum(int32_t rwflag,uint8_t *serialized,int32_t len,void *endian return(len); } -int32_t iguana_validatehdr(char *symbol,struct iguana_msghdr *H) -{ - int32_t i = 0,len = -1; - if ( strcmp(symbol,"VPN") != 0 ) - { - for (i=0; Iguana_validcommands[i]!=0&&Iguana_validcommands[i][0]!=0; i++) - if ( strcmp(H->command,Iguana_validcommands[i]) == 0 ) - break; - } - if ( Iguana_validcommands[i][0] != 0 ) - { - iguana_rwnum(0,H->serdatalen,sizeof(H->serdatalen),(uint32_t *)&len); - if ( len > IGUANA_MAXPACKETSIZE ) - return(-1); - } - return(len); -} - int32_t iguana_rwbignum(int32_t rwflag,uint8_t *serialized,int32_t len,uint8_t *endianedp) { int32_t i; diff --git a/crypto777/iguana_utils.c b/crypto777/iguana_utils.c index feaa13b3f..509ee5961 100755 --- a/crypto777/iguana_utils.c +++ b/crypto777/iguana_utils.c @@ -190,7 +190,7 @@ double dxblend(double *destp,double val,double decay) return(slope); } -int32_t TerminateQ_queued; +int32_t TerminateQ_queued; queue_t TerminateQ; /*void iguana_terminator(void *arg) { struct iguana_thread *t; uint32_t lastdisp = 0; int32_t terminated = 0; @@ -1062,3 +1062,10 @@ void calc_curve25519_str(char *hexstr,uint8_t *buf,uint8_t *msg,int32_t len) x = curve25519(priv,curve25519_basepoint9()); init_hexbytes_noT(hexstr,x.bytes,sizeof(x)); } + +void calc_rmd160_sha256(uint8_t rmd160[20],uint8_t *data,int32_t datalen) +{ + bits256 hash; + vcalc_sha256(0,hash.bytes,data,datalen); + calc_rmd160(0,rmd160,hash.bytes,sizeof(hash)); +} diff --git a/iguana/exchanges/bitcoin.c b/iguana/exchanges/bitcoin.c index 779b248cb..158b7d0cf 100755 --- a/iguana/exchanges/bitcoin.c +++ b/iguana/exchanges/bitcoin.c @@ -59,13 +59,6 @@ int32_t bitcoin_addr2rmd160(uint8_t *addrtypep,uint8_t rmd160[20],char *coinaddr return(0); } -void calc_rmd160_sha256(uint8_t rmd160[20],uint8_t *data,int32_t datalen) -{ - bits256 hash; - vcalc_sha256(0,hash.bytes,data,datalen); - calc_rmd160(0,rmd160,hash.bytes,sizeof(hash)); -} - char *bitcoin_address(char *coinaddr,uint8_t addrtype,uint8_t *pubkey,int32_t len) { int32_t i; uint8_t data[25]; bits256 hash;// char checkaddr[65]; diff --git a/iguana/iguana_peers.c b/iguana/iguana_peers.c index cdf345e26..076588f2b 100755 --- a/iguana/iguana_peers.c +++ b/iguana/iguana_peers.c @@ -18,6 +18,24 @@ #define _iguana_hashfind(coin,ipbits) _iguana_hashset(coin,ipbits,-1) struct iguana_iAddr *iguana_iAddrhashfind(struct iguana_info *coin,uint64_t ipbits,int32_t createflag); +int32_t iguana_validatehdr(char *symbol,struct iguana_msghdr *H) +{ + int32_t i = 0,len = -1; + if ( strcmp(symbol,"VPN") != 0 ) + { + for (i=0; Iguana_validcommands[i]!=0&&Iguana_validcommands[i][0]!=0; i++) + if ( strcmp(H->command,Iguana_validcommands[i]) == 0 ) + break; + } + if ( Iguana_validcommands[i][0] != 0 ) + { + iguana_rwnum(0,H->serdatalen,sizeof(H->serdatalen),(uint32_t *)&len); + if ( len > IGUANA_MAXPACKETSIZE ) + return(-1); + } + return(len); +} + struct iguana_iAddr *_iguana_hashset(struct iguana_info *coin,uint32_t ipbits,int32_t itemind) { struct iguana_iAddr *ptr = 0; int32_t allocsize; char str[65]; struct OS_memspace *mem = 0; diff --git a/iguana/main.c b/iguana/main.c index 33942aedd..4a8c790a4 100755 --- a/iguana/main.c +++ b/iguana/main.c @@ -61,7 +61,7 @@ struct iguana_info *Coins[IGUANA_MAXCOINS]; char Userhome[512]; int32_t USE_JAY,FIRST_EXTERNAL,IGUANA_disableNXT,Debuglevel,BIGENDIAN; uint32_t prices777_NXTBLOCK,MAX_DEPTH = 100; -queue_t helperQ,jsonQ,finishedQ,bundlesQ,emitQ,TerminateQ; +queue_t helperQ,jsonQ,finishedQ,bundlesQ,emitQ; struct supernet_info MYINFO,**MYINFOS; static int32_t initflag; int32_t HDRnet,netBLOCKS; diff --git a/iguana/tests/jsoncmp.c b/iguana/tests/jsoncmp.c new file mode 100644 index 000000000..05ae7cabe --- /dev/null +++ b/iguana/tests/jsoncmp.c @@ -0,0 +1,42 @@ +#include +#include +#include "../../includes/cJSON.h" +#include "../../crypto777/OS_portable.h" + +int32_t main(int32_t argc,char **argv) +{ + cJSON *argjson,*array,*filejson,*obj,*fobj; char *fname,*filestr,*fstr,*str,*field; int32_t i,n; long filesize; + if ( argc > 2 && (argjson= cJSON_Parse(argv[2])) != 0 ) + { + fname = argv[1]; + if ( (filestr= OS_filestr(&filesize,fname)) != 0 ) + { + if ( (filejson= cJSON_Parse(filestr)) != 0 ) + { + if ( (array= jarray(&n,argjson,"fields")) == 0 ) + obj = jobj(argjson,"field"), n = 1; + else obj = jitem(array,0); + for (i=0; i