jl777 7 years ago
parent
commit
c61465be75
  1. 11
      iguana/exchanges/LP_signatures.c

11
iguana/exchanges/LP_signatures.c

@ -381,19 +381,22 @@ 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 LP_pubkey_sigcheck(struct LP_pubkeyinfo *pubp,cJSON *item)
{ {
int32_t i,siglen,len,retval=-1; uint8_t rmd160[20],pubsecp[33],sig[128],zeroes[20]; char *sigstr,*hexstr,*pubsecpstr; int32_t i,siglen,len,retval=-1; uint8_t rmd160[20],checkrmd160[20],pubsecp[33],sig[128],zeroes[20]; char *sigstr,*hexstr,*pubsecpstr;
if ( (hexstr= jstr(item,"rmd160")) != 0 && strlen(hexstr) == 2*sizeof(rmd160) ) if ( (hexstr= jstr(item,"rmd160")) != 0 && strlen(hexstr) == 2*sizeof(rmd160) )
{ {
decode_hex(rmd160,sizeof(rmd160),hexstr); decode_hex(rmd160,sizeof(rmd160),hexstr);
memset(zeroes,0,sizeof(zeroes)); memset(zeroes,0,sizeof(zeroes));
if ( memcmp(zeroes,rmd160,sizeof(rmd160)) != 0 && memcmp(rmd160,pubp->rmd160,20) != 0 ) if ( memcmp(zeroes,rmd160,sizeof(rmd160)) != 0 )
{
if ( memcmp(rmd160,pubp->rmd160,20) != 0 )
{ {
if ( (pubsecpstr= jstr(item,"pubsecp")) != 0 && is_hexstr(pubsecpstr,0) == 66 ) if ( (pubsecpstr= jstr(item,"pubsecp")) != 0 && is_hexstr(pubsecpstr,0) == 66 )
{ {
decode_hex(pubsecp,sizeof(pubsecp),pubsecpstr); decode_hex(pubsecp,sizeof(pubsecp),pubsecpstr);
calc_rmd160(0,checkrmd160,pubsecp,33);
//memcpy(pubp->rmd160,rmd160,sizeof(pubp->rmd160)); // transition //memcpy(pubp->rmd160,rmd160,sizeof(pubp->rmd160)); // transition
//memcpy(pubp->pubsecp,pubsecp,sizeof(pubp->pubsecp)); //memcpy(pubp->pubsecp,pubsecp,sizeof(pubp->pubsecp));
if ( (sigstr= jstr(item,"sig")) != 0 && (len= is_hexstr(sigstr,0)) == 65*2 ) if ( memcmp(checkrmd160,rmd160,20) == 0 && (sigstr= jstr(item,"sig")) != 0 && (len= is_hexstr(sigstr,0)) == 65*2 )
{ {
siglen = len >> 1; siglen = len >> 1;
decode_hex(sig,siglen,sigstr); decode_hex(sig,siglen,sigstr);
@ -405,9 +408,11 @@ int32_t LP_pubkey_sigcheck(struct LP_pubkeyinfo *pubp,cJSON *item)
memcpy(pubp->pubsecp,pubsecp,sizeof(pubp->pubsecp)); memcpy(pubp->pubsecp,pubsecp,sizeof(pubp->pubsecp));
char str[65]; printf(" -> rmd160.(%s) for %s (%s) sig.%s\n",hexstr,bits256_str(str,pubp->pubkey),pubsecpstr,sigstr); char str[65]; printf(" -> rmd160.(%s) for %s (%s) sig.%s\n",hexstr,bits256_str(str,pubp->pubkey),pubsecpstr,sigstr);
retval = 0; retval = 0;
pubp->timestamp = (uint32_t)time(NULL);
} //else printf("sig %s error pub33.%s\n",sigstr,pubsecpstr); } //else printf("sig %s error pub33.%s\n",sigstr,pubsecpstr);
} }
} }
} else pubp->timestamp = (uint32_t)time(NULL);
} }
} }
return(retval); return(retval);

Loading…
Cancel
Save