From 031792e445819ef9c74612904a995db738539312 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 22 Oct 2017 17:50:16 +0300 Subject: [PATCH] Test --- iguana/exchanges/LP_include.h | 2 +- iguana/exchanges/LP_prices.c | 33 +++++++------------------------- iguana/exchanges/LP_signatures.c | 4 +++- 3 files changed, 11 insertions(+), 28 deletions(-) diff --git a/iguana/exchanges/LP_include.h b/iguana/exchanges/LP_include.h index 75545f2d9..d054999ac 100644 --- a/iguana/exchanges/LP_include.h +++ b/iguana/exchanges/LP_include.h @@ -282,7 +282,7 @@ struct LP_pubkeyinfo bits256 pubkey; double matrix[LP_MAXPRICEINFOS][LP_MAXPRICEINFOS]; uint32_t timestamp,istrusted,numerrors; - uint8_t rmd160[20],sig[76],pubsecp[33],siglen; + uint8_t rmd160[20],sig[65],pubsecp[33],siglen; }; int32_t LP_pubkey_sigcheck(struct LP_pubkeyinfo *pubp,cJSON *item); diff --git a/iguana/exchanges/LP_prices.c b/iguana/exchanges/LP_prices.c index 6a5890f54..0c2535e16 100644 --- a/iguana/exchanges/LP_prices.c +++ b/iguana/exchanges/LP_prices.c @@ -248,7 +248,7 @@ uint64_t LP_unspents_metric(struct iguana_info *coin,char *coinaddr) cJSON *LP_pubkeyjson(struct LP_pubkeyinfo *pubp) { - int32_t baseid,relid,i,j; char *base,hexstr[67],hexstr2[67],sigstr[256]; double price; cJSON *item,*array,*obj; + int32_t baseid,relid; char *base,hexstr[67],hexstr2[67],sigstr[256]; double price; cJSON *item,*array,*obj; obj = cJSON_CreateObject(); array = cJSON_CreateArray(); for (baseid=0; baseidpubkey); - for (i=0; irmd160); i++) - { - if ( pubp->rmd160[i] != 0 ) - { - init_hexbytes_noT(hexstr,pubp->rmd160,sizeof(pubp->rmd160)); - jaddstr(obj,"rmd160",hexstr); - for (j=0; jpubsecp); j++) - { - if ( pubp->pubsecp[j] != 0 ) - { - init_hexbytes_noT(hexstr2,pubp->pubsecp,sizeof(pubp->pubsecp)); - jaddstr(obj,"pubsecp",hexstr2); - if ( pubp->siglen > 0 ) - { - init_hexbytes_noT(sigstr,pubp->sig,pubp->siglen); - jaddstr(obj,"sig",sigstr); - } - //printf("nonz rmd160 (%s %s)\n",hexstr,hexstr2); - //LP_pubkey_sigadd(obj,pubp->pubkey,pubp->rmd160,pubp->pubsecp); - break; - } - } - break; - } - } + init_hexbytes_noT(hexstr,pubp->rmd160,sizeof(pubp->rmd160)); + jaddstr(obj,"rmd160",hexstr); + init_hexbytes_noT(hexstr2,pubp->pubsecp,sizeof(pubp->pubsecp)); + jaddstr(obj,"pubsecp",hexstr2); + init_hexbytes_noT(sigstr,pubp->sig,pubp->siglen); + jaddstr(obj,"sig",sigstr); jaddnum(obj,"timestamp",pubp->timestamp); jadd(obj,"asks",array); if ( pubp->istrusted != 0 ) diff --git a/iguana/exchanges/LP_signatures.c b/iguana/exchanges/LP_signatures.c index 4ffc77c36..59d778901 100644 --- a/iguana/exchanges/LP_signatures.c +++ b/iguana/exchanges/LP_signatures.c @@ -381,7 +381,7 @@ int32_t LP_pubkey_sigadd(cJSON *item,bits256 priv,bits256 pub,uint8_t *rmd160,ui int32_t LP_pubkey_sigcheck(struct LP_pubkeyinfo *pubp,cJSON *item) { - int32_t i,siglen,len,retval=-1; uint8_t rmd160[20],checkrmd160[20],pubsecp[33],sig[128],zeroes[20]; char *sigstr,*hexstr,*pubsecpstr; + int32_t i,len,siglen,retval=-1; uint8_t rmd160[20],checkrmd160[20],pubsecp[33],sig[65],zeroes[20]; char *sigstr,*hexstr,*pubsecpstr; if ( (hexstr= jstr(item,"rmd160")) != 0 && strlen(hexstr) == 2*sizeof(rmd160) ) { decode_hex(rmd160,sizeof(rmd160),hexstr); @@ -406,6 +406,8 @@ int32_t LP_pubkey_sigcheck(struct LP_pubkeyinfo *pubp,cJSON *item) printf("%02x",pubp->rmd160[i]); memcpy(pubp->rmd160,rmd160,sizeof(pubp->rmd160)); memcpy(pubp->pubsecp,pubsecp,sizeof(pubp->pubsecp)); + memcpy(pubp->sig,sig,sizeof(pubp->sig)); + pubp->siglen = siglen; char str[65]; printf(" -> rmd160.(%s) for %s (%s) sig.%s\n",hexstr,bits256_str(str,pubp->pubkey),pubsecpstr,sigstr); retval = 0; pubp->timestamp = (uint32_t)time(NULL);